@Override public TitanGraphIndex getGraphIndex(String name) { IndexType index = getGraphIndexDirect(name, transaction); return index == null ? null : new TitanGraphIndexWrapper(index); }
public TitanSchemaVertex getSchemaVertex(TitanSchemaElement element) { if (element instanceof RelationType) { Preconditions.checkArgument(element instanceof RelationTypeVertex, "Invalid schema element provided: %s", element); return (RelationTypeVertex) element; } else if (element instanceof RelationTypeIndex) { return (RelationTypeVertex) ((RelationTypeIndexWrapper) element).getWrappedType(); } else if (element instanceof VertexLabel) { Preconditions.checkArgument(element instanceof VertexLabelVertex, "Invalid schema element provided: %s", element); return (VertexLabelVertex) element; } else if (element instanceof TitanGraphIndex) { Preconditions.checkArgument(element instanceof TitanGraphIndexWrapper, "Invalid schema element provided: %s", element); IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex(); assert index instanceof IndexTypeWrapper; SchemaSource base = ((IndexTypeWrapper) index).getSchemaBase(); assert base instanceof TitanSchemaVertex; return (TitanSchemaVertex) base; } throw new IllegalArgumentException("Invalid schema element provided: " + element); }
@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(); }
@Override public String toString() { return name(); }
@Override public String toString() { return name(); }
/** * Retrieves the consistency level for a schema element (types and internal indexes) * * @param element * @return */ @Override public ConsistencyModifier getConsistency(TitanSchemaElement element) { Preconditions.checkArgument(element != null); if (element instanceof RelationType) return ((InternalRelationType) element).getConsistencyModifier(); else if (element instanceof TitanGraphIndex) { IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex(); if (index.isMixedIndex()) return ConsistencyModifier.DEFAULT; return ((CompositeIndexType) index).getConsistencyModifier(); } else return ConsistencyModifier.DEFAULT; }
public TitanSchemaElement getSchemaElement(long id) { TitanVertex v = transaction.getVertex(id); if (v == null) return null; if (v instanceof RelationType) { if (((InternalRelationType) v).getBaseType() == null) return (RelationType) v; return new RelationTypeIndexWrapper((InternalRelationType) v); } if (v instanceof TitanSchemaVertex) { TitanSchemaVertex sv = (TitanSchemaVertex) v; if (sv.getDefinition().containsKey(TypeDefinitionCategory.INTERNAL_INDEX)) { return new TitanGraphIndexWrapper(sv.asIndexType()); } } throw new IllegalArgumentException("Not a valid schema element vertex: " + id); }
@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(); }
/** * Sets the consistency level for those schema elements that support it (types and internal indexes) * </p> * Note, that it is possible to have a race condition here if two threads simultaneously try to change the * consistency level. However, this is resolved when the consistency level is being read by taking the * first one and deleting all existing attached consistency levels upon modification. * * @param element * @param consistency */ @Override public void setConsistency(TitanSchemaElement element, ConsistencyModifier consistency) { if (element instanceof RelationType) { RelationTypeVertex rv = (RelationTypeVertex) element; Preconditions.checkArgument(consistency != ConsistencyModifier.FORK || !rv.multiplicity().isConstrained(), "Cannot apply FORK consistency mode to constraint relation type: %s", rv.name()); } else if (element instanceof TitanGraphIndex) { IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex(); if (index.isMixedIndex()) throw new IllegalArgumentException("Cannot change consistency on mixed index: " + element); } else throw new IllegalArgumentException("Cannot change consistency of schema element: " + element); setTypeModifier(element, ModifierType.CONSISTENCY, consistency); }
TitanGraphIndexWrapper index = new TitanGraphIndexWrapper(indexVertex.asIndexType()); if (!oneNewKey) updateIndex(index, SchemaAction.REGISTER_INDEX); return index;
@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(); }
typeVertex = (TitanSchemaVertex) element; } else if (element instanceof TitanGraphIndex) { IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex(); assert index instanceof IndexTypeWrapper; SchemaSource base = ((IndexTypeWrapper) index).getSchemaBase();
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()); }
&& !(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
@Nullable @Override public TitanGraphIndex apply(@Nullable IndexType indexType) { return new TitanGraphIndexWrapper(indexType); } });
public TitanSchemaVertex getSchemaVertex(TitanSchemaElement element) { if (element instanceof RelationType) { Preconditions.checkArgument(element instanceof RelationTypeVertex,"Invalid schema element provided: %s",element); return (RelationTypeVertex)element; } else if (element instanceof RelationTypeIndex) { return (RelationTypeVertex)((RelationTypeIndexWrapper)element).getWrappedType(); } else if (element instanceof VertexLabel) { Preconditions.checkArgument(element instanceof VertexLabelVertex,"Invalid schema element provided: %s",element); return (VertexLabelVertex)element; } else if (element instanceof TitanGraphIndex) { Preconditions.checkArgument(element instanceof TitanGraphIndexWrapper,"Invalid schema element provided: %s",element); IndexType index = ((TitanGraphIndexWrapper)element).getBaseIndex(); assert index instanceof IndexTypeWrapper; SchemaSource base = ((IndexTypeWrapper)index).getSchemaBase(); assert base instanceof TitanSchemaVertex; return (TitanSchemaVertex)base; } throw new IllegalArgumentException("Invalid schema element provided: "+element); }
@Override public TitanGraphIndex getGraphIndex(String name) { IndexType index = getGraphIndexDirect(name, transaction); return index==null?null:new TitanGraphIndexWrapper(index); }
public TitanSchemaVertex getSchemaVertex(TitanSchemaElement element) { if (element instanceof RelationType) { Preconditions.checkArgument(element instanceof RelationTypeVertex, "Invalid schema element provided: %s", element); return (RelationTypeVertex) element; } else if (element instanceof RelationTypeIndex) { return (RelationTypeVertex) ((RelationTypeIndexWrapper) element).getWrappedType(); } else if (element instanceof VertexLabel) { Preconditions.checkArgument(element instanceof VertexLabelVertex, "Invalid schema element provided: %s", element); return (VertexLabelVertex) element; } else if (element instanceof TitanGraphIndex) { Preconditions.checkArgument(element instanceof TitanGraphIndexWrapper, "Invalid schema element provided: %s", element); IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex(); assert index instanceof IndexTypeWrapper; SchemaSource base = ((IndexTypeWrapper) index).getSchemaBase(); assert base instanceof TitanSchemaVertex; return (TitanSchemaVertex) base; } throw new IllegalArgumentException("Invalid schema element provided: " + element); }
@Override public TitanGraphIndex getGraphIndex(String name) { IndexType index = getGraphIndexDirect(name, transaction); return index == null ? null : new TitanGraphIndexWrapper(index); }
/** * Retrieves the consistency level for a schema element (types and internal indexes) * * @param element * @return */ @Override public ConsistencyModifier getConsistency(TitanSchemaElement element) { Preconditions.checkArgument(element!=null); if (element instanceof RelationType) return ((InternalRelationType)element).getConsistencyModifier(); else if (element instanceof TitanGraphIndex) { IndexType index = ((TitanGraphIndexWrapper)element).getBaseIndex(); if (index.isMixedIndex()) return ConsistencyModifier.DEFAULT; return ((CompositeIndexType)index).getConsistencyModifier(); } else return ConsistencyModifier.DEFAULT; }