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); }
if (index instanceof RelationTypeIndex) { RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper)index; InternalRelationType wrappedType = wrapper.getWrappedType(); EdgeSerializer edgeSerializer = writeTx.getEdgeSerializer(); List<Entry> additions = new ArrayList<>();
@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 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); }
if (index instanceof RelationTypeIndex) { RelationTypeIndexWrapper wrapper = (RelationTypeIndexWrapper)index; InternalRelationType wrappedType = wrapper.getWrappedType(); EdgeSerializer edgeSerializer = writeTx.getEdgeSerializer(); List<Entry> additions = new ArrayList<>();
@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(); } } }