当前位置: 首页>>代码示例>>Java>>正文


Java MixedIndexType类代码示例

本文整理汇总了Java中com.thinkaurelius.titan.graphdb.types.MixedIndexType的典型用法代码示例。如果您正苦于以下问题:Java MixedIndexType类的具体用法?Java MixedIndexType怎么用?Java MixedIndexType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MixedIndexType类属于com.thinkaurelius.titan.graphdb.types包,在下文中一共展示了MixedIndexType类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addIndexKey

import com.thinkaurelius.titan.graphdb.types.MixedIndexType; //导入依赖的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: addIndexKey

import com.thinkaurelius.titan.graphdb.types.MixedIndexType; //导入依赖的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.getName());
    Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
        && ((IndexTypeWrapper)indexType).getSchemaBase() instanceof TitanSchemaVertex);
    Preconditions.checkArgument(key.getCardinality()==Cardinality.SINGLE || indexType.getElement()!=ElementCategory.VERTEX,
            "Can only index single-valued property keys on vertices [%s]",key);
    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.getName(),index.getName());

    //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();
    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,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:37,代码来源:ManagementSystem.java

示例3: add

import com.thinkaurelius.titan.graphdb.types.MixedIndexType; //导入依赖的package包/类
public void add(MixedIndexType index, IndexQuery query) {
    queries.add(new Subquery(index, query));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:4,代码来源:JointIndexQuery.java

示例4: getParametersFor

import com.thinkaurelius.titan.graphdb.types.MixedIndexType; //导入依赖的package包/类
@Override
public Parameter[] getParametersFor(PropertyKey key) {
    if (index.isCompositeIndex()) return new Parameter[0];
    return ((MixedIndexType)index).getField(key).getParameters();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:6,代码来源:TitanGraphIndexWrapper.java

示例5: getIndexStatus

import com.thinkaurelius.titan.graphdb.types.MixedIndexType; //导入依赖的package包/类
@Override
public SchemaStatus getIndexStatus(PropertyKey key) {
    Preconditions.checkArgument(Sets.newHashSet(getFieldKeys()).contains(key),"Provided key is not part of this index: %s",key);
    if (index.isCompositeIndex()) return ((CompositeIndexType)index).getStatus();
    else return ((MixedIndexType)index).getField(key).getStatus();
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:7,代码来源:TitanGraphIndexWrapper.java

示例6: getMixedIndexes

import com.thinkaurelius.titan.graphdb.types.MixedIndexType; //导入依赖的package包/类
private static Iterable<MixedIndexType> getMixedIndexes(RelationType type) {
    if (!type.isPropertyKey()) return Collections.EMPTY_LIST;
    return Iterables.filter(Iterables.filter(((InternalRelationType)type).getKeyIndexes(),MIXED_INDEX_FILTER),MixedIndexType.class);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:StandardTransactionLogProcessor.java

示例7: updateIndex

import com.thinkaurelius.titan.graphdb.types.MixedIndexType; //导入依赖的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.MixedIndexType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。