本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Direction.IN属性的典型用法代码示例。如果您正苦于以下问题:Java Direction.IN属性的具体用法?Java Direction.IN怎么用?Java Direction.IN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.tinkerpop.gremlin.structure.Direction
的用法示例。
在下文中一共展示了Direction.IN属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: specificEdges
@Override
protected Iterator<Edge> specificEdges(Direction direction, String... edgeLabels) {
List<Iterator<?>> iterators = new LinkedList<>();
if (edgeLabels.length == 0) {
edgeLabels = ALL_EDGES;
}
for (String label : edgeLabels) {
if (label == WrittenBy.label) {
if (direction == Direction.IN || direction == Direction.BOTH) {
iterators.add(getWrittenByIn().iterator());
}
} else if (label == SungBy.label) {
if (direction == Direction.IN || direction == Direction.BOTH) {
iterators.add(getSungByIn().iterator());
}
}
}
Iterator<Edge>[] iteratorsArray = iterators.toArray(new Iterator[iterators.size()]);
return IteratorUtils.concat(iteratorsArray);
}
示例2: edges
public Iterable<Edge> edges() {
Iterable<Edge> in = null;
Iterable<Edge> out = null;
if(direction==Direction.IN || direction==Direction.BOTH) {
if(vertex.getRole()==TripleComponentRole.OBJECT || vertex.getInternalId()<=vertex.getHDTGraph().getBaseGraph().getDictionary().getNshared()) {
in = getEdges(new TripleID(0,0,vertex.getInternalId()));
}
}
if(direction==Direction.OUT || direction==Direction.BOTH) {
if(vertex.getRole()==TripleComponentRole.SUBJECT || vertex.getInternalId()<=vertex.getHDTGraph().getBaseGraph().getDictionary().getNshared()) {
out = getEdges(new TripleID(vertex.getInternalId(),0,0));
}
}
if(in!=null && out!=null) {
return IteratorConcat.concat(in, out);
} else if(in!=null) {
return in;
} else if(out!=null){
return out;
}
return Collections.emptySet();
}
示例3: vertices
public Iterable<Vertex> vertices() {
Iterable<Vertex> in = null;
Iterable<Vertex> out = null;
if(direction==Direction.IN || direction==Direction.BOTH) {
if(vertex.getRole()==TripleComponentRole.OBJECT || vertex.getInternalId()<=vertex.getHDTGraph().getBaseGraph().getDictionary().getNshared()) {
in = Iter.mapIterable(getEdges(new TripleID(0,0,vertex.getInternalId())), new EdgeToVertex(Direction.OUT));
}
}
if(direction==Direction.OUT || direction==Direction.BOTH) {
if(vertex.getRole()==TripleComponentRole.SUBJECT || vertex.getInternalId()<=vertex.getHDTGraph().getBaseGraph().getDictionary().getNshared()) {
out = Iter.mapIterable(getEdges(new TripleID(vertex.getInternalId(),0,0)), new EdgeToVertex(Direction.IN));
}
}
if(in!=null && out!=null) {
return IteratorConcat.concat(in, out);
} else if(in!=null) {
return in;
} else if(out!=null){
return out;
}
return Collections.emptySet();
}
示例4: readVertex
/**
* Read a {@link Vertex} from output generated by any of the {@link GraphSONWriter} {@code writeVertex} or
* {@code writeVertices} methods or by {@link GraphSONWriter#writeGraph(OutputStream, Graph)}.
*
* @param inputStream a stream containing at least one {@link Vertex} as defined by the accompanying
* {@link GraphWriter#writeVertices(OutputStream, Iterator, Direction)} method.
* @param vertexAttachMethod a function that creates re-attaches a {@link Vertex} to a {@link Host} object.
* @param edgeAttachMethod a function that creates re-attaches a {@link Edge} to a {@link Host} object.
* @param attachEdgesOfThisDirection only edges of this direction are passed to the {@code edgeMaker}.
*/
@Override
public Vertex readVertex(final InputStream inputStream,
final Function<Attachable<Vertex>, Vertex> vertexAttachMethod,
final Function<Attachable<Edge>, Edge> edgeAttachMethod,
final Direction attachEdgesOfThisDirection) throws IOException {
final Map<String, Object> vertexData = mapper.readValue(inputStream, mapTypeReference);
final StarGraph starGraph = StarGraphGraphSONSerializer.readStarGraphVertex(vertexData);
if (vertexAttachMethod != null) vertexAttachMethod.apply(starGraph.getStarVertex());
if (vertexData.containsKey(GraphSONTokens.OUT_E) && (attachEdgesOfThisDirection == Direction.BOTH || attachEdgesOfThisDirection == Direction.OUT))
StarGraphGraphSONSerializer.readStarGraphEdges(edgeAttachMethod, starGraph, vertexData, GraphSONTokens.OUT_E);
if (vertexData.containsKey(GraphSONTokens.IN_E) && (attachEdgesOfThisDirection == Direction.BOTH || attachEdgesOfThisDirection == Direction.IN))
StarGraphGraphSONSerializer.readStarGraphEdges(edgeAttachMethod, starGraph, vertexData, GraphSONTokens.IN_E);
return starGraph.getStarVertex();
}
示例5: specificEdges
@Override
protected Iterator<Edge> specificEdges(Direction direction, String... edgeLabels) {
List<Iterator<?>> iterators = new LinkedList<>();
if (edgeLabels.length == 0) {
edgeLabels = ALL_EDGES;
}
for (String label : edgeLabels) {
if (label == FollowedBy.label) {
if (direction == Direction.IN || direction == Direction.BOTH) {
iterators.add(getFollowedByIn().iterator());
}
if (direction == Direction.OUT || direction == Direction.BOTH) {
iterators.add(getFollowedByOut().iterator());
}
} else if (label == WrittenBy.label) {
if (direction == Direction.OUT) {
iterators.add(getWrittenByOut().iterator());
}
} else if (label == SungBy.label) {
if (direction == Direction.OUT) {
iterators.add(getSungByOut().iterator());
}
}
}
Iterator<Edge>[] iteratorsArray = iterators.toArray(new Iterator[iterators.size()]);
return IteratorUtils.concat(iteratorsArray);
}
示例6: getVertexId
public UUID getVertexId(Direction dir) {
if (dir == Direction.IN) {
return inVertexId;
} else if (dir == Direction.OUT) {
return outVertexId;
} else {
throw new IllegalArgumentException("Unsupported direction " + dir);
}
}
示例7: getEdges
public List<UUID> getEdges(UUID vertexId, Direction dir, String[] edgeLabels) {
NavigableMap<Endpoint, Integer> map = (dir == Direction.IN) ? inV.get(vertexId) : outV.get(vertexId);
if (map == null) {
return Collections.emptyList();
}
Endpoint[] matches;
// Var-args appear as empty arrays
if ((edgeLabels == null) || edgeLabels.length == 0) {
matches = new Endpoint[] { new Endpoint(null, null) };
} else {
int len = edgeLabels.length;
matches = new Endpoint[len];
for (int i=0; i < len; i++) {
matches[i] = new Endpoint(edgeLabels[i], null);
}
}
List<UUID> edgeIds = new ArrayList<UUID>();
for (Endpoint match : matches) {
findMatchingValues(map, match, edgeIds);
}
return edgeIds;
}
示例8: vertices
@Override
public Iterator<Vertex> vertices(Direction direction) {
if(direction==Direction.OUT) {
return Iter.<Vertex>single(outVertex());
} else if(direction==Direction.IN) {
return Iter.<Vertex>single(inVertex());
} else if(direction==Direction.BOTH) {
return bothVertices();
}
return null;
}
示例9: deserialize
public Edge deserialize(Result result) {
byte[] bytes = result.getRow();
PositionedByteRange buffer = new SimplePositionedByteRange(bytes);
Object vertexId1 = ValueUtils.deserializeWithSalt(buffer);
Direction direction = OrderedBytes.decodeInt8(buffer) == 1 ? Direction.IN : Direction.OUT;
boolean isUnique = OrderedBytes.decodeInt8(buffer) == 1;
String key = OrderedBytes.decodeString(buffer);
String label = OrderedBytes.decodeString(buffer);
Object value = ValueUtils.deserialize(buffer);
Object vertexId2;
Object edgeId;
if (isUnique) {
Cell vertexId2Cell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.VERTEX_ID_BYTES);
vertexId2 = ValueUtils.deserialize(CellUtil.cloneValue(vertexId2Cell));
Cell edgeIdCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.EDGE_ID_BYTES);
edgeId = ValueUtils.deserialize(CellUtil.cloneValue(edgeIdCell));
} else {
vertexId2 = ValueUtils.deserialize(buffer);
edgeId = ValueUtils.deserialize(buffer);
}
Cell createdAttsCell = result.getColumnLatestCell(Constants.DEFAULT_FAMILY_BYTES, Constants.CREATED_AT_BYTES);
Long createdAt = ValueUtils.deserialize(CellUtil.cloneValue(createdAttsCell));
Map<String, Object> properties = new HashMap<>();
properties.put(key, value);
HBaseEdge newEdge;
if (direction == Direction.IN) {
newEdge = new HBaseEdge(graph, edgeId, label, createdAt, null, properties, false,
graph.findOrCreateVertex(vertexId1),
graph.findOrCreateVertex(vertexId2));
} else {
newEdge = new HBaseEdge(graph, edgeId, label, createdAt, null, properties, false,
graph.findOrCreateVertex(vertexId2),
graph.findOrCreateVertex(vertexId1));
}
HBaseEdge edge = (HBaseEdge) graph.findOrCreateEdge(edgeId);
edge.copyFrom(newEdge);
edge.setIndexKey(new IndexMetadata.Key(ElementType.EDGE, label, key));
edge.setIndexTs(createdAttsCell.getTimestamp());
return edge;
}
示例10: constructPut
private Put constructPut(Direction direction, Map.Entry<String, Boolean> entry) {
long timestamp = ts != null ? ts : HConstants.LATEST_TIMESTAMP;
boolean isUnique = entry.getValue();
Put put = new Put(graph.getEdgeIndexModel().serializeForWrite(edge, direction, isUnique, entry.getKey()));
put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.CREATED_AT_BYTES,
timestamp, ValueUtils.serialize(((HBaseEdge) edge).createdAt()));
if (isUnique) {
Object vertexId = direction == Direction.IN ? edge.outVertex().id() : edge.inVertex().id();
put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.VERTEX_ID_BYTES, timestamp, ValueUtils.serialize(vertexId));
put.addColumn(Constants.DEFAULT_FAMILY_BYTES, Constants.EDGE_ID_BYTES, timestamp, ValueUtils.serialize(edge.id()));
}
put.setAttribute(Mutators.IS_UNIQUE, Bytes.toBytes(isUnique));
return put;
}
示例11: vertices
/**
* {@inheritDoc}
*/
@Override
public Iterator<Vertex> vertices(Direction direction) {
// transaction should be ready for io operations
graph.tx().readWrite();
// out direction
if (direction == Direction.OUT)
return Stream.of((Vertex)out).iterator();
// in direction
if (direction == Direction.IN)
return Stream.of((Vertex)in).iterator();
// both
return Stream.of((Vertex)out, in).iterator();
}