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); }
/** * 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; }
/** * 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); }
typeVertex = (TitanSchemaVertex) element; } else if (element instanceof TitanGraphIndex) { IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex(); assert index instanceof IndexTypeWrapper; SchemaSource base = ((IndexTypeWrapper) index).getSchemaBase();
&& !(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
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); }
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); }
/** * 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; }
/** * 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; }
/** * 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.getMultiplicity().isConstrained(), "Cannot apply FORK consistency mode to constraint relation type: %s",rv.getName()); } 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); }
/** * 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); }
typeVertex = (TitanSchemaVertex)element; } else if (element instanceof TitanGraphIndex) { IndexType index = ((TitanGraphIndexWrapper)element).getBaseIndex(); assert index instanceof IndexTypeWrapper; SchemaSource base = ((IndexTypeWrapper)index).getSchemaBase();
typeVertex = (TitanSchemaVertex) element; } else if (element instanceof TitanGraphIndex) { IndexType index = ((TitanGraphIndexWrapper) element).getBaseIndex(); assert index instanceof IndexTypeWrapper; SchemaSource base = ((IndexTypeWrapper) index).getSchemaBase();
&& !(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.getName()); Preconditions.checkArgument(indexType instanceof IndexTypeWrapper && key instanceof TitanSchemaVertex
&& !(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