public static String n(Object obj) { if (obj instanceof RelationType) return ((RelationType)obj).name(); else return obj.toString(); }
@Override public Q types(RelationType... types) { String[] ts = new String[types.length]; for (int i = 0; i < types.length; i++) { ts[i] = types[i].name(); } return types(ts); }
public Q type(RelationType type) { return types(type.name()); }
private IndexIdentifier(TitanIndex index) { Preconditions.checkArgument(index != null); indexName = index.name(); if (index instanceof RelationTypeIndex) relationTypeName = ((RelationTypeIndex) index).getType().name(); else relationTypeName = null; Preconditions.checkArgument(StringUtils.isNotBlank(indexName)); hashcode = new HashCodeBuilder().append(indexName).append(relationTypeName).hashCode(); }
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isEdge() && titanRelation.isIncidentOn(vertex) && (dir==Direction.BOTH || ((TitanEdge)titanRelation).vertex(dir).equals(vertex)) && (stypes.isEmpty() || stypes.contains(titanRelation.getType().name())); } });
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isProperty() && titanRelation.isIncidentOn(vertex) && (stypes.isEmpty() || stypes.contains(titanRelation.getType().name())); } });
final String relationTypeName = RelationTypeIndex.class.isAssignableFrom(index.getClass()) ? ((RelationTypeIndex)index).getType().name() : ""; Preconditions.checkNotNull(indexName);
@Override public boolean evaluate(E element) { RelationType type; if (key instanceof String) { type = ((InternalElement) element).tx().getRelationType((String) key); if (type == null) return satisfiesCondition(null); } else { type = (RelationType) key; } Preconditions.checkNotNull(type); if (type.isPropertyKey()) { Iterator<Object> iter = ElementHelper.getValues(element,(PropertyKey)type).iterator(); if (iter.hasNext()) { while (iter.hasNext()) { if (satisfiesCondition(iter.next())) return true; } return false; } return satisfiesCondition(null); } else { assert ((InternalRelationType)type).multiplicity().isUnique(Direction.OUT); return satisfiesCondition((TitanVertex)element.value(type.name())); } }
VertexProperty.Cardinality card = getPropertyKeyCardinality(type.name()); tv.property(card, type.name(), value, T.id, relation.relationId); } else { assert type.isEdgeLabel(); "Read edge incident on a partitioned vertex, but partitioned vertex filtering is disabled. " + "Relation ID: %s. This vertex ID: %s. Other vertex ID: %s. Edge label: %s.", relation.relationId, vertexId, relation.getOtherVertexId(), type.name()); log.debug("Skipping edge with ID {} incident on partitioned vertex with ID {} (and nonpartitioned vertex with ID {})", relation.relationId, relation.getOtherVertexId(), vertexId); te = (TinkerEdge)outV.addEdge(type.name(), tv, T.id, relation.relationId); } else if (relation.direction.equals(Direction.OUT)) { te = (TinkerEdge)tv.addEdge(type.name(), inV, T.id, relation.relationId); } else { throw new RuntimeException("Direction.BOTH is not supported"); te.property(rt.name(), next.value); } else { throw new RuntimeException("Metaedges are not supported");
@Override public Q types(RelationType... types) { String[] ts = new String[types.length]; for (int i = 0; i < types.length; i++) { ts[i] = types[i].name(); } return types(ts); }
public Q type(RelationType type) { return types(type.name()); }
private IndexIdentifier(TitanIndex index) { Preconditions.checkArgument(index != null); indexName = index.name(); if (index instanceof RelationTypeIndex) relationTypeName = ((RelationTypeIndex) index).getType().name(); else relationTypeName = null; Preconditions.checkArgument(StringUtils.isNotBlank(indexName)); hashcode = new HashCodeBuilder().append(indexName).append(relationTypeName).hashCode(); }
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isProperty() && titanRelation.isIncidentOn(vertex) && (stypes.isEmpty() || stypes.contains(titanRelation.getType().name())); } });
@Override public boolean apply(@Nullable TitanRelation titanRelation) { return titanRelation.isEdge() && titanRelation.isIncidentOn(vertex) && (dir==Direction.BOTH || ((TitanEdge)titanRelation).vertex(dir).equals(vertex)) && (stypes.isEmpty() || stypes.contains(titanRelation.getType().name())); } });
final String relationTypeName = RelationTypeIndex.class.isAssignableFrom(index.getClass()) ? ((RelationTypeIndex)index).getType().name() : ""; Preconditions.checkNotNull(indexName);
@Override public boolean evaluate(E element) { RelationType type; if (key instanceof String) { type = ((InternalElement) element).tx().getRelationType((String) key); if (type == null) return satisfiesCondition(null); } else { type = (RelationType) key; } Preconditions.checkNotNull(type); if (type.isPropertyKey()) { Iterator<Object> iter = ElementHelper.getValues(element,(PropertyKey)type).iterator(); if (iter.hasNext()) { while (iter.hasNext()) { if (satisfiesCondition(iter.next())) return true; } return false; } return satisfiesCondition(null); } else { assert ((InternalRelationType)type).multiplicity().isUnique(Direction.OUT); return satisfiesCondition((TitanVertex)element.value(type.name())); } }
VertexProperty.Cardinality card = getPropertyKeyCardinality(type.name()); tv.property(card, type.name(), value, T.id, relation.relationId); } else { assert type.isEdgeLabel(); "Read edge incident on a partitioned vertex, but partitioned vertex filtering is disabled. " + "Relation ID: %s. This vertex ID: %s. Other vertex ID: %s. Edge label: %s.", relation.relationId, vertexId, relation.getOtherVertexId(), type.name()); log.debug("Skipping edge with ID {} incident on partitioned vertex with ID {} (and nonpartitioned vertex with ID {})", relation.relationId, relation.getOtherVertexId(), vertexId); te = (TinkerEdge)outV.addEdge(type.name(), tv, T.id, relation.relationId); } else if (relation.direction.equals(Direction.OUT)) { te = (TinkerEdge)tv.addEdge(type.name(), inV, T.id, relation.relationId); } else { throw new RuntimeException("Direction.BOTH is not supported"); te.property(rt.name(), next.value); } else { throw new RuntimeException("Metaedges are not supported");