本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Direction.OUT属性的典型用法代码示例。如果您正苦于以下问题:Java Direction.OUT属性的具体用法?Java Direction.OUT怎么用?Java Direction.OUT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.tinkerpop.gremlin.structure.Direction
的用法示例。
在下文中一共展示了Direction.OUT属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: edgesFromVertex
/**
* @see {@link Templates#EDGES_FROM_VERTEX}
*/
String edgesFromVertex(final BlazeVertex src, final Direction dir,
final List<URI> edgeLabels) {
final URI id = src.rdfId();
final StringBuilder vc = buildValuesClause(
new StringBuilder(), "?src", asList(id));
if (!edgeLabels.isEmpty()) {
buildValuesClause(vc, "?label", edgeLabels);
}
final String queryStr;
if (dir == Direction.BOTH) {
queryStr = EDGES_FROM_VERTEX_BOTH.replace(Templates.VALUES, vc.toString());
} else {
final String DIRECTION = dir == Direction.OUT ? FORWARD : REVERSE;
queryStr = EDGES_FROM_VERTEX.replace(Templates.VALUES, vc.toString())
.replace(Templates.DIRECTION, DIRECTION);
}
return queryStr;
}
示例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: 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;
}
示例8: toVertex
/**
* Creates an in-memory vertex from the supplied node data.
*/
private StarVertex toVertex(Map<String, Object> node,
@Nullable Function<Attachable<Vertex>, Vertex> vertexAttachMethod,
@Nullable Function<Attachable<Edge>, Edge> edgeAttachMethod,
Direction attachEdgesOfThisDirection,
ReadGraphContext context) {
// Create a new StarGraph whose primary vertex is the converted node
StarGraph starGraph = StarGraph.open();
StarVertex vertex = (StarVertex) starGraph.addVertex(context.getNodeProperties(node, true));
if (vertexAttachMethod != null) {
vertex.attach(vertexAttachMethod);
}
// Add outgoing edges for object properties (if requested)
if (attachEdgesOfThisDirection == Direction.BOTH || attachEdgesOfThisDirection == Direction.OUT) {
for (Map.Entry<String, Object> property : node.entrySet()) {
if (context.topology().isObjectPropertyKey(property.getKey())) {
context.mapper().valueObjectMapper().fromReferenceValueObject(property.getValue())
.map(id -> starGraph.addVertex(T.id, context.generateId(id)))
.map(inVertex -> (StarEdge) vertex.addEdge(property.getKey(), inVertex))
.forEach(edge -> {
if (edgeAttachMethod != null) {
edge.attach(edgeAttachMethod);
}
});
}
}
}
return vertex;
}
示例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: 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();
}
示例11: getEdges
public List<EdgeBean> getEdges(VertexBean vBean, Direction dir, String[] edgeLabels) {
if (vBean == null) {
return Collections.emptyList();
}
boolean outDirection = (dir == Direction.OUT);
Object edges = outDirection ? vBean.outEdges : vBean.inEdges;
if (edges == null) {
return Collections.emptyList();
}
// Need a new list
List<EdgeBean> ans = new ArrayList<EdgeBean>();
boolean origMatch = (edgeLabels == null) || edgeLabels.length == 0;
boolean multiSet = (edges instanceof CompactMultiSetMax<?, ?>);
String[] edgeLabelsToQuery = (multiSet && (!origMatch)) ? edgeLabels : new String[] {null};
for (String edgeLabelToQuery : edgeLabelsToQuery) {
Object[] edgeBeans;
if (multiSet) {
edgeBeans = ((CompactMultiSetMax<String, EdgeBean>)edges).getSuperSetWithClassifier(edgeLabelToQuery);
} else {
edgeBeans = CompactSet.getElements(edges);
}
for (Object obj : edgeBeans) {
// Always check for nulls on getElements() because reads don't acquire locks
if (obj == null) {
continue;
}
boolean match = origMatch;
EdgeBean eBean = (EdgeBean)obj;
if (!match) {
String eLabel = eBean.getLabel();
if (edgeLabelToQuery != null) {
match = eLabel.equals(edgeLabelToQuery);
} else {
for (String label : edgeLabels) {
if (eLabel.equals(label)) {
match = true;
break;
}
}
}
}
if (match) {
// Always copy objects that are directly picked up from the memory store
// These objects can be updated later while the query is in progress
ans.add(new EdgeBean(eBean));
}
}
}
return ans;
}
示例12: removeMatchingKeys
private boolean removeMatchingKeys(NavigableMap<Endpoint, Integer> map, Endpoint endpoint, Map<UUID, TreeMap<Endpoint, Integer>> otherMap, Direction dir) {
if (map == null) {
return false;
}
// Mark this endpoint as a marker, because it is used to do a tailMap traversal to remove matching edges
endpoint.setMarker();
// Find the first key
Endpoint floorKey = map.floorKey(endpoint);
Map<Endpoint, Integer> view;
if (floorKey == null) {
// This means that the element being searched is the minimum
view = map;
} else {
view = map.tailMap(floorKey);
}
Iterator<Map.Entry<Endpoint, Integer>> entryIter = view.entrySet().iterator();
boolean isFirst = true;
while (entryIter.hasNext()) {
Map.Entry<Endpoint, Integer> entry = entryIter.next();
Endpoint key = entry.getKey();
if (endpoint.isMatch(key)) {
// Remove it from this index
entryIter.remove();
// and from the underlying edge map if necessary
if (dir != null) { // Direction is null if this is a recursive all
// Remove the edge if the map is provided for this purpose
UUID edgeId = key.getEdgeId();
IEdge edge = edgeRemover.removeEdge(edgeId);
assert (edge != null);
// Remove the other endpoint of this edge. NOTE: Self loops are not allowed.
Endpoint otherEndpoint;
UUID otherVertexId;
if (dir == Direction.OUT) {
otherVertexId = edge.getInVertexId();
otherEndpoint = new Endpoint(key.getEdgeLabel(), key.getEdgeId());
} else {
otherVertexId = edge.getOutVertexId();
otherEndpoint = new Endpoint(key.getEdgeLabel(), key.getEdgeId());
}
if (removeMatchingKeys(otherMap.get(otherVertexId), otherEndpoint, null, null)) {
otherMap.remove(otherVertexId);
}
}
} else {
// Done with removes -- the tree map is sorted
if (isFirst) {
// continue
} else {
break;
}
}
isFirst = false;
}
return (map.size() == 0);
}