@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); }
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 String toString() { return name(); } }
@Override public String toString() { return getName(); } }
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); }
if (index instanceof RelationTypeIndex) { RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper)index; InternalRelationType wrappedType = wrapper.getWrappedType(); EdgeSerializer edgeSerializer = writeTx.getEdgeSerializer(); List<Entry> additions = new ArrayList<>();
@Override public String toString() { return name(); } }
RelationTypeIndexWrapper index = new RelationTypeIndexWrapper((InternalRelationType) typeIndex); if (!type.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX); return index;
@Override public List<SliceQuery> getQueries() { if (isGlobalGraphIndex()) { //Everything return ImmutableList.of(new SliceQuery(BufferUtil.zeroBuffer(1), BufferUtil.oneBuffer(128))); } else { RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper)index; InternalRelationType wrappedType = wrapper.getWrappedType(); Direction direction=null; for (Direction dir : Direction.values()) if (wrappedType.isUnidirected(dir)) direction=dir; assert direction!=null; StandardTitanTx tx = (StandardTitanTx)graph.get().buildTransaction().readOnly().start(); try { QueryContainer qc = new QueryContainer(tx); qc.addQuery().type(wrappedType).direction(direction).relations(); return qc.getSliceQueries(); } finally { tx.rollback(); } } }
@Nullable @Override public RelationTypeIndex apply(@Nullable InternalRelationType internalType) { return new RelationTypeIndexWrapper(internalType); } });
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 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); }
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 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); }
if (index instanceof RelationTypeIndex) { RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper)index; InternalRelationType wrappedType = wrapper.getWrappedType(); EdgeSerializer edgeSerializer = writeTx.getEdgeSerializer(); List<Entry> additions = new ArrayList<>();
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 List<SliceQuery> getQueries() { if (isGlobalGraphIndex()) { //Everything return ImmutableList.of(new SliceQuery(BufferUtil.zeroBuffer(1), BufferUtil.oneBuffer(128))); } else { RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper)index; InternalRelationType wrappedType = wrapper.getWrappedType(); Direction direction=null; for (Direction dir : Direction.values()) if (wrappedType.isUnidirected(dir)) direction=dir; assert direction!=null; StandardTitanTx tx = (StandardTitanTx)graph.get().buildTransaction().readOnly().start(); try { QueryContainer qc = new QueryContainer(tx); qc.addQuery().type(wrappedType).direction(direction).relations(); return qc.getSliceQueries(); } finally { tx.rollback(); } } }
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); }
RelationTypeIndexWrapper index = new RelationTypeIndexWrapper((InternalRelationType)typeIndex); if (!type.isNew()) updateIndex(index,SchemaAction.REGISTER_INDEX); return index;
RelationTypeIndexWrapper index = new RelationTypeIndexWrapper((InternalRelationType) typeIndex); if (!type.isNew()) updateIndex(index, SchemaAction.REGISTER_INDEX); return index;