@Override protected void validateIndexStatus() { if (index instanceof RelationTypeIndex) { //Nothing specific to be done } else if (index instanceof TitanGraphIndex) { TitanGraphIndex gindex = (TitanGraphIndex)index; if (gindex.isMixedIndex()) throw new UnsupportedOperationException("Cannot remove mixed indexes through Titan. This can " + "only be accomplished in the indexing system directly."); CompositeIndexType indexType = (CompositeIndexType)mgmt.getSchemaVertex(index).asIndexType(); graphIndexId = indexType.getID(); } else throw new UnsupportedOperationException("Unsupported index found: "+index); //Must be a relation type index or a composite graph index TitanSchemaVertex schemaVertex = mgmt.getSchemaVertex(index); SchemaStatus actualStatus = schemaVertex.getStatus(); Preconditions.checkArgument(actualStatus==SchemaStatus.DISABLED,"The index [%s] must be disabled before it can be removed",indexName); }
TitanSchemaVertex schemaVertex = mgmt.getSchemaVertex(index); Set<SchemaStatus> acceptableStatuses = SchemaAction.REINDEX.getApplicableStatus(); boolean isValidIndex = true;
@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); }
Preconditions.checkArgument(updateAction != null, "Need to provide update action"); TitanSchemaVertex schemaVertex = getSchemaVertex(index); Set<TitanSchemaVertex> dependentTypes; Set<PropertyKeyVertex> keySubset = ImmutableSet.of();
metrics.incrementCustom(ADDED_RECORDS_COUNT, additions.size()); } else if (index instanceof TitanGraphIndex) { IndexType indexType = mgmt.getSchemaVertex(index).asIndexType(); assert indexType!=null; IndexSerializer indexSerializer = graph.getIndexSerializer();
@Override public void getQueries(QueryContainer queries) { if (index instanceof RelationTypeIndex) { queries.addQuery().types(indexRelationTypeName).direction(Direction.OUT).relations(); } else if (index instanceof TitanGraphIndex) { IndexType indexType = mgmt.getSchemaVertex(index).asIndexType(); switch (indexType.getElement()) { case PROPERTY: addIndexSchemaConstraint(queries.addQuery(),indexType).properties(); break; case VERTEX: queries.addQuery().properties(); queries.addQuery().type(BaseLabel.VertexLabelEdge).direction(Direction.OUT).edges(); break; case EDGE: indexType.hasSchemaTypeConstraint(); addIndexSchemaConstraint(queries.addQuery().direction(Direction.OUT),indexType).edges(); break; default: throw new AssertionError("Unexpected category: " + indexType.getElement()); } } else throw new UnsupportedOperationException("Unsupported index found: "+index); }
@Override protected void validateIndexStatus() { if (index instanceof RelationTypeIndex) { //Nothing specific to be done } else if (index instanceof TitanGraphIndex) { TitanGraphIndex gindex = (TitanGraphIndex)index; if (gindex.isMixedIndex()) throw new UnsupportedOperationException("Cannot remove mixed indexes through Titan. This can " + "only be accomplished in the indexing system directly."); CompositeIndexType indexType = (CompositeIndexType)mgmt.getSchemaVertex(index).asIndexType(); graphIndexId = indexType.getID(); } else throw new UnsupportedOperationException("Unsupported index found: "+index); //Must be a relation type index or a composite graph index TitanSchemaVertex schemaVertex = mgmt.getSchemaVertex(index); SchemaStatus actualStatus = schemaVertex.getStatus(); Preconditions.checkArgument(actualStatus==SchemaStatus.DISABLED,"The index [%s] must be disabled before it can be removed",indexName); }
TitanSchemaVertex schemaVertex = mgmt.getSchemaVertex(index); Set<SchemaStatus> acceptableStatuses = SchemaAction.REINDEX.getApplicableStatus(); boolean isValidIndex = true;
Preconditions.checkArgument(updateAction!=SchemaAction.REMOVE_INDEX); TitanSchemaVertex schemaVertex = getSchemaVertex(index); Set<TitanSchemaVertex> dependentTypes; Set<PropertyKeyVertex> keySubset = ImmutableSet.of();
@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); }
Preconditions.checkArgument(updateAction != null, "Need to provide update action"); TitanSchemaVertex schemaVertex = getSchemaVertex(index); Set<TitanSchemaVertex> dependentTypes; Set<PropertyKeyVertex> keySubset = ImmutableSet.of();
metrics.incrementCustom(ADDED_RECORDS_COUNT, additions.size()); } else if (index instanceof TitanGraphIndex) { IndexType indexType = mgmt.getSchemaVertex(index).asIndexType(); assert indexType!=null; IndexSerializer indexSerializer = graph.getIndexSerializer();
@Override public void getQueries(QueryContainer queries) { if (index instanceof RelationTypeIndex) { queries.addQuery().types(indexRelationTypeName).direction(Direction.OUT).relations(); } else if (index instanceof TitanGraphIndex) { IndexType indexType = mgmt.getSchemaVertex(index).asIndexType(); switch (indexType.getElement()) { case PROPERTY: addIndexSchemaConstraint(queries.addQuery(),indexType).properties(); break; case VERTEX: queries.addQuery().properties(); queries.addQuery().type(BaseLabel.VertexLabelEdge).direction(Direction.OUT).edges(); break; case EDGE: indexType.hasSchemaTypeConstraint(); addIndexSchemaConstraint(queries.addQuery().direction(Direction.OUT),indexType).edges(); break; default: throw new AssertionError("Unexpected category: " + indexType.getElement()); } } else throw new UnsupportedOperationException("Unsupported index found: "+index); }