@Override public RelationTypeIndex getRelationIndex(RelationType type, String name) { Preconditions.checkArgument(type != null); Preconditions.checkArgument(StringUtils.isNotBlank(name)); String composedName = composeRelationTypeIndexName(type, name); //Don't use SchemaCache to make code more compact and since we don't need the extra performance here TitanVertex v = Iterables.getOnlyElement(QueryUtil.getVertices(transaction, BaseKey.SchemaName, TitanSchemaCategory.getRelationTypeName(composedName)), null); if (v == null) return null; assert v instanceof InternalRelationType; return new RelationTypeIndexWrapper((InternalRelationType) v); }
@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); }
"The relation type [%s] has a multiplicity or cardinality constraint in direction [%s] and can therefore not be indexed", type, direction); String composedName = composeRelationTypeIndexName(type, name); StandardRelationTypeMaker maker; if (type.isEdgeLabel()) {
@Override public RelationTypeIndex getRelationIndex(RelationType type, String name) { Preconditions.checkArgument(type != null); Preconditions.checkArgument(StringUtils.isNotBlank(name)); String composedName = composeRelationTypeIndexName(type, name); //Don't use SchemaCache to make code more compact and since we don't need the extra performance here TitanVertex v = Iterables.getOnlyElement(QueryUtil.getVertices(transaction, BaseKey.SchemaName, TitanSchemaCategory.getRelationTypeName(composedName)), null); if (v == null) return null; assert v instanceof InternalRelationType; return new RelationTypeIndexWrapper((InternalRelationType) v); }
@Override public RelationTypeIndex getRelationIndex(RelationType type, String name) { Preconditions.checkArgument(type!=null); Preconditions.checkArgument(StringUtils.isNotBlank(name)); String composedName = composeRelationTypeIndexName(type, name); //Don't use SchemaCache to make code more compact and since we don't need the extra performance here TitanVertex v = Iterables.getOnlyElement(transaction.getVertices(BaseKey.SchemaName,TitanSchemaCategory.getRelationTypeName(composedName)),null); if (v==null) return null; assert v instanceof InternalRelationType; return new RelationTypeIndexWrapper((InternalRelationType)v); }
@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); }
"The relation type [%s] has a multiplicity or cardinality constraint in direction [%s] and can therefore not be indexed",type,direction); String composedName = composeRelationTypeIndexName(type,name); StandardRelationTypeMaker maker; if (type.isEdgeLabel()) {
"The relation type [%s] has a multiplicity or cardinality constraint in direction [%s] and can therefore not be indexed", type, direction); String composedName = composeRelationTypeIndexName(type, name); StandardRelationTypeMaker maker; if (type.isEdgeLabel()) {