Java Code Examples for com.tinkerpop.blueprints.Direction#equals()

The following examples show how to use com.tinkerpop.blueprints.Direction#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 6 votes vote down vote up
/**
 * Return the edges incident to the vertex according to the provided direction
 * and edge labels.
 *
 * @param direction
 *            the direction of the edges to retrieve
 * @param labels
 *            the labels of the edges to retrieve
 * @return an iterable of incident edges
 */
public Iterable<CachedChronoEdge> getChronoEdges(final Direction direction, final BsonArray labels,
		final int branchFactor) {

	HashSet<Long> labelIdxSet = null;
	if (labels != null) {
		labelIdxSet = convertToLabelIdxSet(labels);
	}

	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoEdges(labelIdxSet, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoEdges(labelIdxSet, branchFactor);
	else {
		return new MultiIterable<CachedChronoEdge>(Arrays.asList(this.getInChronoEdges(labelIdxSet, branchFactor),
				this.getOutChronoEdges(labelIdxSet, branchFactor)));
	}
}
 
Example 2
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 6 votes vote down vote up
public Stream<CachedChronoVertex> getChronoVertexStream(final Direction direction, final BsonArray labels,
		final int branchFactor, final boolean setParallel) {

	HashSet<Long> labelIdxSet = null;
	if (labels != null) {
		labelIdxSet = convertToLabelIdxSet(labels);
	}

	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoVertexStream(labelIdxSet, branchFactor, setParallel);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoVertexStream(labelIdxSet, branchFactor, setParallel);
	else {
		Set<CachedChronoVertex> ret = this.getOutChronoVertexSet(labelIdxSet, branchFactor);
		ret.addAll(this.getInChronoVertexSet(labelIdxSet, branchFactor));
		if (setParallel)
			return ret.parallelStream();
		else
			return ret.stream();
	}
}
 
Example 3
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 6 votes vote down vote up
public Iterable<CachedChronoVertex> getChronoVertices(final Direction direction, final BsonArray labels,
		final int branchFactor) {

	HashSet<Long> labelIdxSet = null;
	if (labels != null) {
		labelIdxSet = convertToLabelIdxSet(labels);
	}

	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoVertices(labelIdxSet, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoVertices(labelIdxSet, branchFactor);
	else {
		return new MultiIterable<CachedChronoVertex>(
				Arrays.asList(this.getOutChronoVertices(labelIdxSet, branchFactor),
						this.getInChronoVertices(labelIdxSet, branchFactor)));
	}
}
 
Example 4
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 6 votes vote down vote up
public Set<CachedVertexEvent> getVertexEventSet(final Direction direction, final BsonArray labels, final Long left,
		final AC tt, final int branchFactor) {

	HashSet<Long> labelIdxSet = null;
	if (labels != null) {
		labelIdxSet = convertToLabelIdxSet(labels);
	}

	if (direction.equals(Direction.OUT)) {
		return this.getOutVertexEventSet(labelIdxSet, left, tt, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInVertexEventSet(labelIdxSet, left, tt, branchFactor);
	else {
		Set<CachedVertexEvent> ret = this.getOutVertexEventSet(labelIdxSet, left, tt, branchFactor);
		ret.addAll(this.getInVertexEventSet(labelIdxSet, left, tt, branchFactor));
		return ret;
	}
}
 
Example 5
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 6 votes vote down vote up
public Set<CachedEdgeEvent> getEdgeEventSet(final Direction direction, final BsonArray labels, final Long left,
		final AC tt, final int branchFactor) {

	HashSet<Long> labelIdxSet = null;
	if (labels != null) {
		labelIdxSet = convertToLabelIdxSet(labels);
	}

	if (direction.equals(Direction.OUT)) {
		return this.getOutEdgeEventSet(labelIdxSet, left, tt, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInEdgeEventSet(labelIdxSet, left, tt, branchFactor);
	else {
		Set<CachedEdgeEvent> ret = this.getOutEdgeEventSet(labelIdxSet, left, tt, branchFactor);
		ret.addAll(this.getInEdgeEventSet(labelIdxSet, left, tt, branchFactor));
		return ret;
	}
}
 
Example 6
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 6 votes vote down vote up
public Set<CachedChronoEdge> getChronoEdgeSet(final Direction direction, final BsonArray labels,
		final int branchFactor) {

	HashSet<Long> labelIdxSet = null;
	if (labels != null) {
		labelIdxSet = convertToLabelIdxSet(labels);
	}

	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoEdgeSet(labelIdxSet, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoEdgeSet(labelIdxSet, branchFactor);
	else {
		Set<CachedChronoEdge> ret = this.getOutChronoEdgeSet(labelIdxSet, branchFactor);
		ret.addAll(this.getInChronoEdgeSet(labelIdxSet, branchFactor));
		return ret;
	}
}
 
Example 7
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 6 votes vote down vote up
public Stream<CachedChronoEdge> getChronoEdgeStream(final Direction direction, final BsonArray labels,
		final int branchFactor, final boolean setParallel) {

	HashSet<Long> labelIdxSet = null;
	if (labels != null) {
		labelIdxSet = convertToLabelIdxSet(labels);
	}

	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoEdgeStream(labelIdxSet, branchFactor, setParallel);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoEdgeStream(labelIdxSet, branchFactor, setParallel);
	else {
		Set<CachedChronoEdge> ret = this.getOutChronoEdgeSet(labelIdxSet, branchFactor);
		ret.addAll(this.getInChronoEdgeSet(labelIdxSet, branchFactor));
		if (setParallel)
			return ret.parallelStream();
		else
			return ret.stream();
	}
}
 
Example 8
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
public Set<CachedChronoEdge> getChronoEdgeSet(final Direction direction, final String label,
		final int branchFactor) {

	Long labelIdx = convertToLabelIdx(label);

	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoEdgeSet(labelIdx, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoEdgeSet(labelIdx, branchFactor);
	else {
		Set<CachedChronoEdge> ret = this.getOutChronoEdgeSet(labelIdx, branchFactor);
		ret.addAll(this.getInChronoEdgeSet(labelIdx, branchFactor));
		return ret;
	}
}
 
Example 9
Source File: CachedChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
public Set<CachedChronoVertex> getChronoVertexSet(final Direction direction, final String label,
		final int branchFactor) {

	Long labelIdx = graph.getLabelIndex().get(label);

	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoVertexSet(labelIdx, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoVertexSet(labelIdx, branchFactor);
	else {
		Set<CachedChronoVertex> ret = this.getOutChronoVertexSet(labelIdx, branchFactor);
		ret.addAll(this.getInChronoVertexSet(labelIdx, branchFactor));
		return ret;
	}
}
 
Example 10
Source File: ChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
/**
 * Return the edges incident to the vertex according to the provided direction
 * and edge labels.
 *
 * @param direction
 *            the direction of the edges to retrieve
 * @param labels
 *            the labels of the edges to retrieve
 * @return an iterable of incident edges
 */
public Iterable<ChronoEdge> getChronoEdges(final Direction direction, final BsonArray labels,
		final int branchFactor) {
	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoEdges(labels, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoEdges(labels, branchFactor);
	else {
		return new MultiIterable<ChronoEdge>(Arrays.asList(this.getInChronoEdges(labels, branchFactor),
				this.getOutChronoEdges(labels, branchFactor)));
	}
}
 
Example 11
Source File: ChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
public Set<ChronoEdge> getChronoEdgeSet(final Direction direction, final BsonArray labels, final int branchFactor) {
	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoEdgeSet(labels, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoEdgeSet(labels, branchFactor);
	else {
		Set<ChronoEdge> edgeSet = this.getOutChronoEdgeSet(labels, branchFactor);
		edgeSet.addAll(this.getInChronoEdgeSet(labels, branchFactor));
		return edgeSet;
	}
}
 
Example 12
Source File: ChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
public Stream<ChronoEdge> getChronoEdgeStream(final Direction direction, final BsonArray labels,
		final int branchFactor, final boolean setParallel) {
	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoEdgeStream(labels, branchFactor, setParallel);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoEdgeStream(labels, branchFactor, setParallel);
	else {
		Set<ChronoEdge> ret = this.getOutChronoEdgeSet(labels, branchFactor);
		ret.addAll(this.getInChronoEdgeSet(labels, branchFactor));
		if (setParallel)
			return getChronoEdgeSet(direction, labels, branchFactor).parallelStream();
		else
			return getChronoEdgeSet(direction, labels, branchFactor).stream();
	}
}
 
Example 13
Source File: ChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
public Iterable<ChronoVertex> getChronoVertices(final Direction direction, final BsonArray labels,
		final int branchFactor) {
	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoVertices(labels, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoVertices(labels, branchFactor);
	else {
		return new MultiIterable<ChronoVertex>(Arrays.asList(this.getOutChronoVertices(labels, branchFactor),
				this.getInChronoVertices(labels, branchFactor)));
	}
}
 
Example 14
Source File: ChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
public Set<ChronoVertex> getChronoVertexSet(final Direction direction, final BsonArray labels,
		final int branchFactor) {
	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoVertexSet(labels, branchFactor);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoVertexSet(labels, branchFactor);
	else {
		Set<ChronoVertex> bothVSet = this.getOutChronoVertexSet(labels, branchFactor);
		bothVSet.addAll(this.getInChronoVertexSet(labels, branchFactor));
		return bothVSet;
	}
}
 
Example 15
Source File: ChronoVertex.java    From epcis with Apache License 2.0 5 votes vote down vote up
public Stream<ChronoVertex> getChronoVertexStream(final Direction direction, final BsonArray labels,
		final int branchFactor, final boolean setParallel) {
	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoVertexStream(labels, branchFactor, setParallel);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoVertexStream(labels, branchFactor, setParallel);
	else {
		Set<ChronoVertex> bothVSet = this.getOutChronoVertexSet(labels, branchFactor);
		bothVSet.addAll(this.getInChronoVertexSet(labels, branchFactor));
		if (setParallel)
			return bothVSet.parallelStream();
		else
			return bothVSet.stream();
	}
}
 
Example 16
Source File: VertexTableWrapper.java    From AccumuloGraph with Apache License 2.0 4 votes vote down vote up
public CloseableIterable<Edge> getEdges(Vertex vertex, Direction direction,
    String... labels) {
  Scanner scan = getScanner();
  scan.setRange(new Range(vertex.getId().toString()));
  if (direction.equals(Direction.IN)) {
    scan.fetchColumnFamily(new Text(Constants.IN_EDGE));
  } else if (direction.equals(Direction.OUT)) {
    scan.fetchColumnFamily(new Text(Constants.OUT_EDGE));
  } else {
    scan.fetchColumnFamily(new Text(Constants.IN_EDGE));
    scan.fetchColumnFamily(new Text(Constants.OUT_EDGE));
  }

  if (labels.length > 0) {
    applyEdgeLabelValueFilter(scan, labels);
  }

  return new ScannerIterable<Edge>(scan) {

    @Override
    public Edge next(PeekingIterator<Entry<Key,Value>> iterator) {
      // TODO better use of information readily available...
      // TODO could also check local cache before creating a new
      // instance?

      Entry<Key,Value> kv = iterator.next();

      String[] parts = kv.getKey().getColumnQualifier().toString().split(Constants.ID_DELIM);
      String label = (new String(kv.getValue().get())).split(Constants.ID_DELIM)[1];

      AccumuloEdge edge;
      if (kv.getKey().getColumnFamily().toString().equalsIgnoreCase(Constants.IN_EDGE)) {
        edge = new AccumuloEdge(globals, parts[1],
            new AccumuloVertex(globals, kv.getKey().getRow().toString()),
            new AccumuloVertex(globals, parts[0]), label);
      } else {
        edge = new AccumuloEdge(globals, parts[1],
            new AccumuloVertex(globals, parts[0]),
            new AccumuloVertex(globals, kv.getKey().getRow().toString()), label);
      }
      globals.getCaches().cache(edge, Edge.class);

      return edge;
    }
  };
}
 
Example 17
Source File: LinkPipe.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
private LinkPipe(final Direction direction, final String label) {
    this.direction = direction;
    this.label = label;
    if (direction.equals(Direction.BOTH))
        this.sideEffect = new ArrayList<Edge>();
}
 
Example 18
Source File: CachedChronoEdge.java    From epcis with Apache License 2.0 3 votes vote down vote up
/**
 * Return the tail/out or head/in vertex.
 *
 * @param direction
 *            whether to return the tail/out or head/in vertex
 * @return the tail/out or head/in vertex
 * @throws IllegalArgumentException
 *             is thrown if a direction of both is provided
 */
public CachedChronoVertex getChronoVertex(final Direction direction) throws IllegalArgumentException {
	if (direction.equals(Direction.IN))
		return this.inVertex;
	else if (direction.equals(Direction.OUT))
		return this.outVertex;
	else
		throw ExceptionFactory.bothIsNotSupported();
}
 
Example 19
Source File: ChronoEdge.java    From epcis with Apache License 2.0 3 votes vote down vote up
/**
 * Return the tail/out or head/in vertex.
 *
 * @param direction
 *            whether to return the tail/out or head/in vertex
 * @return the tail/out or head/in vertex
 * @throws IllegalArgumentException
 *             is thrown if a direction of both is provided
 */
public ChronoVertex getChronoVertex(final Direction direction) throws IllegalArgumentException {
	if (direction.equals(Direction.IN))
		return this.inVertex;
	else if (direction.equals(Direction.OUT))
		return this.outVertex;
	else
		throw ExceptionFactory.bothIsNotSupported();
}
 
Example 20
Source File: ChronoVertex.java    From epcis with Apache License 2.0 3 votes vote down vote up
/**
 * Return the vertices adjacent to the vertex according to the provided
 * direction and edge labels. This method does not remove duplicate vertices
 * (i.e. those vertices that are connected by more than one edge).
 *
 * @param direction
 *            the direction of the edges of the adjacent vertices
 * @param labels
 *            the labels of the edges of the adjacent vertices
 * @return an iterable of adjacent vertices
 */
public Iterable<ChronoVertex> getChronoVertices(final Direction direction, final BsonArray labels) {
	if (direction.equals(Direction.OUT)) {
		return this.getOutChronoVertices(labels, Integer.MAX_VALUE);
	} else if (direction.equals(Direction.IN))
		return this.getInChronoVertices(labels, Integer.MAX_VALUE);
	else {
		return new MultiIterable<ChronoVertex>(Arrays.asList(this.getOutChronoVertices(labels, Integer.MAX_VALUE),
				this.getInChronoVertices(labels, Integer.MAX_VALUE)));
	}
}