@Override public void changeName(TitanSchemaElement element, String newName) { Preconditions.checkArgument(StringUtils.isNotBlank(newName), "Invalid name: %s", newName); TitanSchemaVertex schemaVertex = getSchemaVertex(element); if (schemaVertex.name().equals(newName)) return; TitanSchemaCategory schemaCategory = schemaVertex.valueOrNull(BaseKey.SchemaCategory); Preconditions.checkArgument(schemaCategory.hasName(), "Invalid schema element: %s", element); if (schemaVertex instanceof RelationType) { InternalRelationType relType = (InternalRelationType) schemaVertex; if (relType.getBaseType() != null) { newName = composeRelationTypeIndexName(relType.getBaseType(), newName); } else assert !(element instanceof RelationTypeIndex); TitanSchemaCategory cat = relType.isEdgeLabel() ? TitanSchemaCategory.EDGELABEL : TitanSchemaCategory.PROPERTYKEY; SystemTypeManager.isNotSystemName(cat, newName); } else if (element instanceof VertexLabel) { SystemTypeManager.isNotSystemName(TitanSchemaCategory.VERTEXLABEL, newName); } else if (element instanceof TitanGraphIndex) { checkIndexName(newName); } transaction.addProperty(schemaVertex, BaseKey.SchemaName, schemaCategory.getSchemaName(newName)); updateSchemaVertex(schemaVertex); schemaVertex.resetCache(); updatedTypes.add(schemaVertex); }
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) { checkIndexName(indexName); Preconditions.checkArgument(keys != null && keys.length > 0, "Need to provide keys to index [%s]", indexName); Preconditions.checkArgument(!unique || elementCategory == ElementCategory.VERTEX, "Unique indexes can only be created on vertices [%s]", indexName);
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()); }
@Override public void changeName(TitanSchemaElement element, String newName) { Preconditions.checkArgument(StringUtils.isNotBlank(newName),"Invalid name: %s",newName); TitanSchemaVertex schemaVertex = getSchemaVertex(element); if (schemaVertex.getName().equals(newName)) return; TitanSchemaCategory schemaCategory = schemaVertex.getProperty(BaseKey.SchemaCategory); Preconditions.checkArgument(schemaCategory.hasName(),"Invalid schema element: %s",element); if (schemaVertex instanceof RelationType) { InternalRelationType relType = (InternalRelationType)schemaVertex; if (relType.getBaseType()!=null) { newName = composeRelationTypeIndexName(relType.getBaseType(),newName); } else assert !(element instanceof RelationTypeIndex); StandardRelationTypeMaker.checkName(newName); } else if (element instanceof VertexLabel) { StandardVertexLabelMaker.checkName(newName); } else if (element instanceof TitanGraphIndex) { checkIndexName(newName); } transaction.addProperty(schemaVertex, BaseKey.SchemaName, schemaCategory.getSchemaName(newName)); updateSchemaVertex(schemaVertex); schemaVertex.resetCache(); updatedTypes.add(schemaVertex); }
@Override public void changeName(TitanSchemaElement element, String newName) { Preconditions.checkArgument(StringUtils.isNotBlank(newName), "Invalid name: %s", newName); TitanSchemaVertex schemaVertex = getSchemaVertex(element); if (schemaVertex.name().equals(newName)) return; TitanSchemaCategory schemaCategory = schemaVertex.valueOrNull(BaseKey.SchemaCategory); Preconditions.checkArgument(schemaCategory.hasName(), "Invalid schema element: %s", element); if (schemaVertex instanceof RelationType) { InternalRelationType relType = (InternalRelationType) schemaVertex; if (relType.getBaseType() != null) { newName = composeRelationTypeIndexName(relType.getBaseType(), newName); } else assert !(element instanceof RelationTypeIndex); TitanSchemaCategory cat = relType.isEdgeLabel() ? TitanSchemaCategory.EDGELABEL : TitanSchemaCategory.PROPERTYKEY; SystemTypeManager.isNotSystemName(cat, newName); } else if (element instanceof VertexLabel) { SystemTypeManager.isNotSystemName(TitanSchemaCategory.VERTEXLABEL, newName); } else if (element instanceof TitanGraphIndex) { checkIndexName(newName); } transaction.addProperty(schemaVertex, BaseKey.SchemaName, schemaCategory.getSchemaName(newName)); updateSchemaVertex(schemaVertex); schemaVertex.resetCache(); updatedTypes.add(schemaVertex); }
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) { checkIndexName(indexName); Preconditions.checkArgument(keys!=null && keys.length>0,"Need to provide keys to index [%s]",indexName); Preconditions.checkArgument(!unique || elementCategory==ElementCategory.VERTEX,"Unique indexes can only be created on vertices [%s]",indexName);
private TitanGraphIndex createCompositeIndex(String indexName, ElementCategory elementCategory, boolean unique, TitanSchemaType constraint, PropertyKey... keys) { checkIndexName(indexName); Preconditions.checkArgument(keys != null && keys.length > 0, "Need to provide keys to index [%s]", indexName); Preconditions.checkArgument(!unique || elementCategory == ElementCategory.VERTEX, "Unique indexes can only be created on vertices [%s]", indexName);
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()); }