@Override public EdgeLabel make() { TypeDefinitionMap definition = makeDefinition(); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !getMultiplicity().isUnique(unidirectionality.opposite()), "Unidirectional labels cannot have restricted multiplicity at the other end"); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !hasSortKey() || !getMultiplicity().isUnique(unidirectionality), "Unidirectional labels with restricted multiplicity cannot have a sort key"); Preconditions.checkArgument(unidirectionality!=Direction.IN || definition.getValue(INVISIBLE,Boolean.class)); definition.setValue(UNIDIRECTIONAL, unidirectionality); return tx.makeEdgeLabel(getName(), definition); }
@Override public EdgeLabel make() { TypeDefinitionMap definition = makeDefinition(); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !getMultiplicity().isUnique(unidirectionality.opposite()), "Unidirectional labels cannot have restricted multiplicity at the other end"); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !hasSortKey() || !getMultiplicity().isUnique(unidirectionality), "Unidirectional labels with restricted multiplicity cannot have a sort key"); Preconditions.checkArgument(unidirectionality!=Direction.IN || definition.getValue(INVISIBLE,Boolean.class)); definition.setValue(UNIDIRECTIONAL, unidirectionality); return tx.makeEdgeLabel(getName(), definition); }
VertexStep vstep = (VertexStep)currentStep; if (vstep.returnsEdge() && (direction==Direction.BOTH || direction.equals(vstep.getDirection().opposite()))) {
VertexStep vertexStep = (VertexStep) currentStep; if (vertexStep.returnsEdge() && (direction == Direction.BOTH || direction.equals(vertexStep.getDirection().opposite()))) {
public void reverseDirection() { this.direction = this.direction.opposite(); }
public void reverseDirection() { this.direction = this.direction.opposite(); }
TitanVertex oth = edge.vertex(dir.opposite()); assert oth instanceof TitanSchemaVertex; TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc);
JanusGraphVertex oth = edge.vertex(dir.opposite()); assert oth instanceof JanusGraphSchemaVertex; TypeDefinitionDescription desc = edge.valueOrNull(BaseKey.SchemaDefinitionDesc);
private static Direction getOppositeDirection(final Traversal.Admin<Vertex, Edge> incidentTraversal) { final VertexStep step = TraversalHelper.getLastStepOfAssignableClass(VertexStep.class, incidentTraversal).get(); return step.getDirection().opposite(); } }
/** * Checks whether a given step is optimizable or not. * * @param step1 an edge-emitting step * @param step2 a vertex-emitting step * @return <code>true</code> if step1 is not labeled and emits edges and step2 emits vertices, * otherwise <code>false</code> */ private static boolean isOptimizable(final Step step1, final Step step2) { if (step1 instanceof VertexStep && ((VertexStep) step1).returnsEdge() && step1.getLabels().isEmpty()) { final Direction step1Dir = ((VertexStep) step1).getDirection(); if (step1Dir.equals(Direction.BOTH)) { return step2 instanceof EdgeOtherVertexStep; } return step2 instanceof EdgeOtherVertexStep || (step2 instanceof EdgeVertexStep && ((EdgeVertexStep) step2).getDirection().equals(step1Dir.opposite())); } return false; }
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { return TinkerHelper.inComputerMode(this.graph) ? direction.equals(Direction.BOTH) ? IteratorUtils.concat( IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex), IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex)) : IteratorUtils.map(this.edges(direction, edgeLabels), edge -> edge.vertices(direction.opposite()).next()) : (Iterator) TinkerHelper.getVertices(this, direction, edgeLabels); }
final Step<Edge, Vertex> someVStep = (addsPathRequirement = step.getDirection() == Direction.BOTH) ? new EdgeOtherVertexStep(traversal) : new EdgeVertexStep(traversal, step.getDirection().opposite());
private static Direction getOppositeDirection(final Traversal.Admin<Vertex, Edge> incidentTraversal) { final VertexStep step = TraversalHelper.getLastStepOfAssignableClass(VertexStep.class, incidentTraversal).get(); return step.getDirection().opposite(); } }
private Vertex getExactlyOneVertex(final String label, final Direction direction) { return getVertex(getExactlyOneEdge(label, direction), direction.opposite()); }
@Override public Map<String, Object> toFields(Edge edge) { Map<String, Object> parentFields = getVertexFields(edge, parentDirection); if (parentFields == null) return null; Map<String, Object> edgeFields = getFields(edge); Map<String, Object> childFields = getVertexFields(edge, parentDirection.opposite()); Map<String, Object> nestedFields = ConversionUtils.merge(Lists.newArrayList(edgeFields, childFields), this::mergeFields, false); if (nestedFields == null) return null; parentFields.put(this.path, new Object[]{nestedFields}); return parentFields; }
@Override public EdgeLabel make() { TypeDefinitionMap definition = makeDefinition(); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !getMultiplicity().isUnique(unidirectionality.opposite()), "Unidirectional labels cannot have restricted multiplicity at the other end"); Preconditions.checkArgument(unidirectionality==Direction.BOTH || !hasSortKey() || !getMultiplicity().isUnique(unidirectionality), "Unidirectional labels with restricted multiplicity cannot have a sort key"); Preconditions.checkArgument(unidirectionality!=Direction.IN || definition.getValue(INVISIBLE,Boolean.class)); definition.setValue(UNIDIRECTIONAL, unidirectionality); return tx.makeEdgeLabel(getName(), definition); }
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { return TinkerHelper.inComputerMode(this.graph) ? direction.equals(Direction.BOTH) ? IteratorUtils.concat( IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex), IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex)) : IteratorUtils.map(this.edges(direction, edgeLabels), edge -> edge.vertices(direction.opposite()).next()) : (Iterator) TinkerHelper.getVertices(this, direction, edgeLabels); }
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { return TinkerHelper.inComputerMode(this.graph) ? direction.equals(Direction.BOTH) ? IteratorUtils.concat( IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex), IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex)) : IteratorUtils.map(this.edges(direction, edgeLabels), edge -> edge.vertices(direction.opposite()).next()) : (Iterator) TinkerHelper.getVertices(this, direction, edgeLabels); }