private void setStatusEdges(TitanSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) { Preconditions.checkArgument(vertex.asIndexType().isMixedIndex()); for (TitanEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) { if (!keys.contains(edge.vertex(Direction.IN))) continue; //Only address edges with matching keys TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc); assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD; Parameter[] parameters = (Parameter[]) desc.getModifier(); assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName()); if (parameters[parameters.length - 1].value().equals(status)) continue; Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length); paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status); edge.remove(); addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy); } for (PropertyKeyVertex prop : keys) prop.resetCache(); }
for (int i = 0; i < keys.length; i++) { Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)}; addSchemaEdge(indexVertex, keys[i], TypeDefinitionCategory.INDEX_FIELD, paras); addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
addSchemaEdge(type, typeIndex, TypeDefinitionCategory.RELATIONTYPE_INDEX, null); RelationTypeIndexWrapper index = new RelationTypeIndexWrapper((InternalRelationType) typeIndex); if (!type.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
def.setValue(cat, value); TitanSchemaVertex cVertex = transaction.makeSchemaVertex(TitanSchemaCategory.TYPE_MODIFIER, null, def); addSchemaEdge(typeVertex, cVertex, TypeDefinitionCategory.TYPE_MODIFIER, null);
private TitanGraphIndex createMixedIndex(String indexName, ElementCategory elementCategory, TitanSchemaType constraint, String backingIndex) { Preconditions.checkArgument(graph.getIndexSerializer().containsIndex(backingIndex), "Unknown external index backend: %s", backingIndex); checkIndexName(indexName); TypeDefinitionMap def = new TypeDefinitionMap(); def.setValue(TypeDefinitionCategory.INTERNAL_INDEX, false); def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY, elementCategory); def.setValue(TypeDefinitionCategory.BACKING_INDEX, backingIndex); def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME, indexName); def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, Cardinality.LIST); def.setValue(TypeDefinitionCategory.STATUS, SchemaStatus.ENABLED); TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX, indexName, def); Preconditions.checkArgument(constraint == null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex)); if (constraint != null) { addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null); } updateSchemaVertex(indexVertex); return new TitanGraphIndexWrapper(indexVertex.asIndexType()); }
extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew() ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED); addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas); updateSchemaVertex(indexVertex); indexType.resetCache();
private void setStatusEdges(TitanSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) { Preconditions.checkArgument(vertex.asIndexType().isMixedIndex()); for (TitanEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD,Direction.OUT)) { if (!keys.contains(edge.getVertex(Direction.IN))) continue; //Only address edges with matching keys TypeDefinitionDescription desc = edge.getProperty(BaseKey.SchemaDefinitionDesc); assert desc.getCategory()==TypeDefinitionCategory.INDEX_FIELD; Parameter[] parameters = (Parameter[])desc.getModifier(); assert parameters[parameters.length-1].getKey().equals(ParameterType.STATUS.getName()); if (parameters[parameters.length-1].getValue().equals(status)) continue; Parameter[] paraCopy = Arrays.copyOf(parameters,parameters.length); paraCopy[parameters.length-1]=ParameterType.STATUS.getParameter(status); edge.remove(); addSchemaEdge(vertex,edge.getVertex(Direction.IN),TypeDefinitionCategory.INDEX_FIELD,paraCopy); } for (PropertyKeyVertex prop : keys) prop.resetCache(); }
private void setStatusEdges(TitanSchemaVertex vertex, SchemaStatus status, Set<PropertyKeyVertex> keys) { Preconditions.checkArgument(vertex.asIndexType().isMixedIndex()); for (TitanEdge edge : vertex.getEdges(TypeDefinitionCategory.INDEX_FIELD, Direction.OUT)) { if (!keys.contains(edge.vertex(Direction.IN))) continue; //Only address edges with matching keys TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc); assert desc.getCategory() == TypeDefinitionCategory.INDEX_FIELD; Parameter[] parameters = (Parameter[]) desc.getModifier(); assert parameters[parameters.length - 1].key().equals(ParameterType.STATUS.getName()); if (parameters[parameters.length - 1].value().equals(status)) continue; Parameter[] paraCopy = Arrays.copyOf(parameters, parameters.length); paraCopy[parameters.length - 1] = ParameterType.STATUS.getParameter(status); edge.remove(); addSchemaEdge(vertex, edge.vertex(Direction.IN), TypeDefinitionCategory.INDEX_FIELD, paraCopy); } for (PropertyKeyVertex prop : keys) prop.resetCache(); }
addSchemaEdge(type, typeIndex, TypeDefinitionCategory.RELATIONTYPE_INDEX, null); RelationTypeIndexWrapper index = new RelationTypeIndexWrapper((InternalRelationType)typeIndex); if (!type.isNew()) updateIndex(index,SchemaAction.REGISTER_INDEX);
for (int i = 0; i < keys.length; i++) { Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)}; addSchemaEdge(indexVertex, keys[i], TypeDefinitionCategory.INDEX_FIELD, paras); addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null);
def.setValue(cat, value); TitanSchemaVertex cVertex = transaction.makeSchemaVertex(TitanSchemaCategory.TYPE_MODIFIER, null, def); addSchemaEdge(typeVertex, cVertex, TypeDefinitionCategory.TYPE_MODIFIER, null); updateSchemaVertex(typeVertex); updatedTypes.add(typeVertex);
for (int i = 0; i <keys.length; i++) { Parameter[] paras = {ParameterType.INDEX_POSITION.getParameter(i)}; addSchemaEdge(indexVertex,keys[i],TypeDefinitionCategory.INDEX_FIELD,paras); addSchemaEdge(indexVertex,(TitanSchemaVertex)constraint,TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT,null);
addSchemaEdge(type, typeIndex, TypeDefinitionCategory.RELATIONTYPE_INDEX, null); RelationTypeIndexWrapper index = new RelationTypeIndexWrapper((InternalRelationType) typeIndex); if (!type.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX);
def.setValue(cat, value); TitanSchemaVertex cVertex = transaction.makeSchemaVertex(TitanSchemaCategory.TYPE_MODIFIER, null, def); addSchemaEdge(typeVertex, cVertex, TypeDefinitionCategory.TYPE_MODIFIER, null);
extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew()?SchemaStatus.ENABLED:SchemaStatus.INSTALLED); addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas); updateSchemaVertex(indexVertex); indexType.resetCache();
private TitanGraphIndex createMixedIndex(String indexName, ElementCategory elementCategory, TitanSchemaType constraint, String backingIndex) { Preconditions.checkArgument(graph.getIndexSerializer().containsIndex(backingIndex),"Unknown external index backend: %s",backingIndex); checkIndexName(indexName); TypeDefinitionMap def = new TypeDefinitionMap(); def.setValue(TypeDefinitionCategory.INTERNAL_INDEX,false); def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY,elementCategory); def.setValue(TypeDefinitionCategory.BACKING_INDEX,backingIndex); def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME,indexName); def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, Cardinality.LIST); def.setValue(TypeDefinitionCategory.STATUS,SchemaStatus.ENABLED); TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX,indexName,def); Preconditions.checkArgument(constraint==null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex)); if (constraint!=null) { addSchemaEdge(indexVertex,(TitanSchemaVertex)constraint,TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT,null); } updateSchemaVertex(indexVertex); return new TitanGraphIndexWrapper(indexVertex.asIndexType()); }
private TitanGraphIndex createMixedIndex(String indexName, ElementCategory elementCategory, TitanSchemaType constraint, String backingIndex) { Preconditions.checkArgument(graph.getIndexSerializer().containsIndex(backingIndex), "Unknown external index backend: %s", backingIndex); checkIndexName(indexName); TypeDefinitionMap def = new TypeDefinitionMap(); def.setValue(TypeDefinitionCategory.INTERNAL_INDEX, false); def.setValue(TypeDefinitionCategory.ELEMENT_CATEGORY, elementCategory); def.setValue(TypeDefinitionCategory.BACKING_INDEX, backingIndex); def.setValue(TypeDefinitionCategory.INDEXSTORE_NAME, indexName); def.setValue(TypeDefinitionCategory.INDEX_CARDINALITY, Cardinality.LIST); def.setValue(TypeDefinitionCategory.STATUS, SchemaStatus.ENABLED); TitanSchemaVertex indexVertex = transaction.makeSchemaVertex(TitanSchemaCategory.GRAPHINDEX, indexName, def); Preconditions.checkArgument(constraint == null || (elementCategory.isValidConstraint(constraint) && constraint instanceof TitanSchemaVertex)); if (constraint != null) { addSchemaEdge(indexVertex, (TitanSchemaVertex) constraint, TypeDefinitionCategory.INDEX_SCHEMA_CONSTRAINT, null); } updateSchemaVertex(indexVertex); return new TitanGraphIndexWrapper(indexVertex.asIndexType()); }
extendedParas[arrPosition++] = ParameterType.STATUS.getParameter(key.isNew() ? SchemaStatus.ENABLED : SchemaStatus.INSTALLED); addSchemaEdge(indexVertex, key, TypeDefinitionCategory.INDEX_FIELD, extendedParas); updateSchemaVertex(indexVertex); indexType.resetCache();