Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
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);
};
}
}