io.sirix.index.IndexDefs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirix-core Show documentation
Show all versions of sirix-core Show documentation
SirixDB is a hybrid on-disk and in-memory document oriented, versioned database system. It has a lightweight buffer manager, stores everything in a huge persistent and durable tree and allows efficient reconstruction of every revision. Furthermore, SirixDB implements change tracking, diffing and supports time travel queries.
package io.sirix.index;
import com.google.common.collect.ImmutableSet;
import io.brackit.query.atomic.QNm;
import io.brackit.query.jdm.Type;
import io.brackit.query.util.path.Path;
import io.sirix.page.PageConstants;
import java.util.Set;
/**
* {@link IndexDef} factory.
*
* @author Johannes Lichtenberger
*/
public final class IndexDefs {
/**
* Private constructor.
*/
private IndexDefs() {
throw new AssertionError("May never be instantiated!");
}
/**
* Create a CAS {@link IndexDef} instance.
*
* @param unique determine if it's unique
* @param optType an optional type
* @param paths the paths to index
* @return a new {@link IndexDef} instance
*/
public static IndexDef createCASIdxDef(final boolean unique, final Type optType, final Set> paths,
final int indexDefNo, final IndexDef.DbType dbType) {
final Type type = optType == null ? Type.STR : optType;
return new IndexDef(type, paths, unique, indexDefNo, dbType);
}
/**
* Create a path {@link IndexDef}.
*
* @param paths the paths to index
* @return a new path {@link IndexDef} instance
*/
public static IndexDef createPathIdxDef(final Set> paths, final int indexDefNo,
final IndexDef.DbType dbType) {
return new IndexDef(paths, indexDefNo, dbType);
}
public static IndexDef createNameIdxDef(final int indexDefNo, final IndexDef.DbType dbType) {
return switch (dbType) {
case JSON -> new IndexDef(ImmutableSet.of(),
ImmutableSet.of(),
PageConstants.JSON_NAME_INDEX_OFFSET + indexDefNo,
dbType);
case XML -> new IndexDef(ImmutableSet.of(),
ImmutableSet.of(),
PageConstants.XML_NAME_INDEX_OFFSET + indexDefNo,
dbType);
};
}
public static IndexDef createFilteredNameIdxDef(final Set excluded, final int indexDefNo,
final IndexDef.DbType dbType) {
return switch (dbType) {
case JSON -> new IndexDef(ImmutableSet.of(), excluded, PageConstants.JSON_NAME_INDEX_OFFSET + indexDefNo, dbType);
case XML -> new IndexDef(ImmutableSet.of(), excluded, PageConstants.XML_NAME_INDEX_OFFSET + indexDefNo, dbType);
};
}
public static IndexDef createSelectiveNameIdxDef(final Set included, final int indexDefNo,
final IndexDef.DbType dbType) {
return switch (dbType) {
case JSON -> new IndexDef(included, ImmutableSet.of(), PageConstants.JSON_NAME_INDEX_OFFSET + indexDefNo, dbType);
case XML -> new IndexDef(included, ImmutableSet.of(), PageConstants.XML_NAME_INDEX_OFFSET + indexDefNo, dbType);
};
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy