當前位置: 首頁>>代碼示例>>Java>>正文


Java ParameterIndexField類代碼示例

本文整理匯總了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);
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:41,代碼來源:ManagementSystem.java

示例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);
    }
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:59,代碼來源:ManagementSystem.java


注:本文中的com.thinkaurelius.titan.graphdb.types.ParameterIndexField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。