本文整理汇总了Java中com.thinkaurelius.titan.graphdb.types.ParameterIndexField类的典型用法代码示例。如果您正苦于以下问题:Java ParameterIndexField类的具体用法?Java ParameterIndexField怎么用?Java ParameterIndexField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParameterIndexField类属于com.thinkaurelius.titan.graphdb.types包,在下文中一共展示了ParameterIndexField类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addIndexKey
import com.thinkaurelius.titan.graphdb.types.ParameterIndexField; //导入依赖的package包/类
@Override
public void addIndexKey(final TitanGraphIndex index, final PropertyKey key, Parameter... parameters) {
Preconditions.checkArgument(index != null && key != null && index instanceof TitanGraphIndexWrapper
&& !(key instanceof BaseKey), "Need to provide valid index and key");
if (parameters == null) parameters = new Parameter[0];
IndexType indexType = ((TitanGraphIndexWrapper) index).getBaseIndex();
Preconditions.checkArgument(indexType instanceof MixedIndexType, "Can only add keys to an external index, not %s", index.name());
Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
&& ((IndexTypeWrapper) indexType).getSchemaBase() instanceof TitanSchemaVertex);
TitanSchemaVertex indexVertex = (TitanSchemaVertex) ((IndexTypeWrapper) indexType).getSchemaBase();
for (IndexField field : indexType.getFieldKeys())
Preconditions.checkArgument(!field.getFieldKey().equals(key), "Key [%s] has already been added to index %s", key.name(), index.name());
//Assemble parameters
boolean addMappingParameter = !ParameterType.MAPPED_NAME.hasParameter(parameters);
Parameter[] extendedParas = new Parameter[parameters.length + 1 + (addMappingParameter ? 1 : 0)];
System.arraycopy(parameters, 0, extendedParas, 0, parameters.length);
int arrPosition = parameters.length;
if (addMappingParameter) extendedParas[arrPosition++] = ParameterType.MAPPED_NAME.getParameter(
graph.getIndexSerializer().getDefaultFieldName(key, parameters, indexType.getBackingIndexName()));
extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew() ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED);
addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas);
updateSchemaVertex(indexVertex);
indexType.resetCache();
//Check to see if the index supports this
if (!graph.getIndexSerializer().supports((MixedIndexType) indexType, ParameterIndexField.of(key, parameters))) {
throw new TitanException("Could not register new index field '" + key.name() + "' with index backend as the data type, cardinality or parameter combination is not supported.");
}
try {
IndexSerializer.register((MixedIndexType) indexType, key, transaction.getTxHandle());
} catch (BackendException e) {
throw new TitanException("Could not register new index field with index backend", e);
}
if (!indexVertex.isNew()) updatedTypes.add(indexVertex);
if (!key.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
}
示例2: updateIndex
import com.thinkaurelius.titan.graphdb.types.ParameterIndexField; //导入依赖的package包/类
@Override
public void updateIndex(TitanIndex index, SchemaAction updateAction) {
Preconditions.checkArgument(updateAction!=null,"Need to provide update action");
Preconditions.checkArgument(updateAction!=SchemaAction.REMOVE_INDEX);
TitanSchemaVertex schemaVertex = getSchemaVertex(index);
Set<TitanSchemaVertex> dependentTypes;
Set<PropertyKeyVertex> keySubset = ImmutableSet.of();
if (index instanceof RelationTypeIndex) {
dependentTypes = ImmutableSet.of((TitanSchemaVertex)((InternalRelationType)schemaVertex).getBaseType());
Preconditions.checkArgument(updateAction.getApplicableStatus().contains(schemaVertex.getStatus()),
"Update action [%s] does not apply for index with status [%s]",updateAction,schemaVertex.getStatus());
} else if (index instanceof TitanGraphIndex) {
IndexType indexType = schemaVertex.asIndexType();
dependentTypes = Sets.newHashSet();
if (indexType.isCompositeIndex()) {
Preconditions.checkArgument(updateAction.getApplicableStatus().contains(schemaVertex.getStatus()),
"Update action [%s] does not apply for index with status [%s]",updateAction,schemaVertex.getStatus());
for (PropertyKey key : ((TitanGraphIndex)index).getFieldKeys()) {
dependentTypes.add((PropertyKeyVertex)key);
}
} else {
keySubset = Sets.newHashSet();
MixedIndexType cindexType = (MixedIndexType)indexType;
Set<SchemaStatus> applicableStatus = updateAction.getApplicableStatus();
for (ParameterIndexField field : cindexType.getFieldKeys()) {
if (applicableStatus.contains(field.getStatus())) keySubset.add((PropertyKeyVertex)field.getFieldKey());
}
Preconditions.checkArgument(!keySubset.isEmpty(),"Update action [%s] does not apply to any fields for index [%s]",updateAction,index);
dependentTypes.addAll(keySubset);
}
} else throw new UnsupportedOperationException("Updates not supported for index: " + index);
switch(updateAction) {
case REGISTER_INDEX:
setStatus(schemaVertex,SchemaStatus.INSTALLED,keySubset);
updatedTypes.add(schemaVertex);
updatedTypes.addAll(dependentTypes);
setUpdateTrigger(new UpdateStatusTrigger(graph, schemaVertex, SchemaStatus.REGISTERED, keySubset));
break;
case REINDEX:
throw new UnsupportedOperationException(updateAction + " requires a manual step: run a MapReduce reindex on index name \"" + index.getName() + "\"");
case ENABLE_INDEX:
setStatus(schemaVertex,SchemaStatus.ENABLED,keySubset);
updatedTypes.add(schemaVertex);
if (!keySubset.isEmpty()) updatedTypes.addAll(dependentTypes);
break;
case DISABLE_INDEX:
setStatus(schemaVertex,SchemaStatus.INSTALLED,keySubset);
updatedTypes.add(schemaVertex);
if (!keySubset.isEmpty()) updatedTypes.addAll(dependentTypes);
setUpdateTrigger(new UpdateStatusTrigger(graph, schemaVertex, SchemaStatus.DISABLED, keySubset));
break;
case REMOVE_INDEX:
throw new UnsupportedOperationException("Removing indexes is not yet supported");
default: throw new UnsupportedOperationException("Update action not supported: " + updateAction);
}
}