当前位置: 首页>>代码示例>>Java>>正文


Java Direction.BOTH属性代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Direction.BOTH属性的典型用法代码示例。如果您正苦于以下问题:Java Direction.BOTH属性的具体用法?Java Direction.BOTH怎么用?Java Direction.BOTH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.tinkerpop.gremlin.structure.Direction的用法示例。


在下文中一共展示了Direction.BOTH属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:21,代码来源:Artist.java

示例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();
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:25,代码来源:HDTVertexQuery.java

示例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();
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:25,代码来源:HDTVertexQuery.java

示例4: 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;
}
 
开发者ID:blazegraph,项目名称:tinkerpop3,代码行数:21,代码来源:SparqlGenerator.java

示例5: applyEdgeLabelsRowFilter

private FilterList applyEdgeLabelsRowFilter(Vertex vertex, Direction direction, String key, String... labels) {
    FilterList rowFilters = new FilterList(FilterList.Operator.MUST_PASS_ONE);
    if (labels.length > 0) {
        for (String label : labels) {
            if (direction == Direction.BOTH) {
                applyEdgeLabelRowFilter(rowFilters, vertex, Direction.IN, key, label);
                applyEdgeLabelRowFilter(rowFilters, vertex, Direction.OUT, key, label);
            } else {
                applyEdgeLabelRowFilter(rowFilters, vertex, direction, key, label);
            }
        }
    } else {
        if (direction == Direction.BOTH) {
            applyEdgeLabelRowFilter(rowFilters, vertex, Direction.IN, key, null);
            applyEdgeLabelRowFilter(rowFilters, vertex, Direction.OUT, key, null);
        } else {
            applyEdgeLabelRowFilter(rowFilters, vertex, direction, key, null);
        }
    }
    return rowFilters;
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:21,代码来源:EdgeIndexModel.java

示例6: 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();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:GraphSONReader.java

示例7: 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);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:28,代码来源:Song.java

示例8: vertices

@Override
public Iterator<Vertex> vertices(Direction dir) {
    tx.validateForQuery(this);

    if (dir != Direction.BOTH) {
        Vertex ans = inOrOutVertex(dir);

        return Collections.singleton(ans).iterator();
    } else {
        return bothVertices();
    }
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:12,代码来源:BitsyEdge.java

示例9: 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;
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:11,代码来源:HDTEdge.java

示例10: 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;
}
 
开发者ID:blackducksoftware,项目名称:bdio,代码行数:33,代码来源:BlackDuckIoReader.java

示例11: makeVCIndex

/**
 * Create vertex-centric index
 *
 * {
 *     "name": "indexName",
 *     "edge": "edgeLebel",
 *     "propertyKeys": [ "propertyKey1", "propertyKey2" ],
 *     "order": "incr|decr",
 *     "direction": "BOTH|IN|OUT"
 * }
 */
void makeVCIndex(JanusGraphManagement mgmt, JsonNode node) {
    if (!node.has("name")) {
        log.info("missing 'name' property, not able to create an index");
        return;
    }

    if (!node.has("edge")) {
        log.info("vertex-centric index needs 'edge' property to specify a edge label");
        return;
    }

    String edgeName = node.get("edge").asText();
    EdgeLabel elabel = mgmt.getEdgeLabel(edgeName);

    if (elabel == null) {
        log.info("edge: " + edgeName + " doesn't exist");
        return;
    }

    String name = node.get("name").asText();
    if (mgmt.containsRelationIndex(elabel, name)) {
        log.info("index: " + name + " exists");
        return;
    }

    if (!node.has("propertyKeys")) {
        log.info("missing 'propertyKeys property, not able to create an index");
        return;
    }

    JsonNode properties = node.findValue("propertyKeys");
    if (properties == null || properties.size() == 0) {
        log.info("index: " + name + " needs 'propertyKeys' properties");
        return;
    }

    Direction dir = node.has("direction") ? Direction.valueOf(node.get("direction").asText()) : Direction.BOTH;
    Order order = node.has("order") ? Order.valueOf(node.get("order").asText()) : Order.incr;

    PropertyKey[] keys = new PropertyKey[properties.size()];
    int counter = 0;
    for (JsonNode property : properties) {
        PropertyKey key = mgmt.getPropertyKey(property.asText());
        if (key == null) {
            log.info("propertyKey:${property.asText()} doesn't exist, can't create ${name} vertex-centric index");
            return;
        }
        keys[counter++] = mgmt.getPropertyKey(property.asText());
    }

    mgmt.buildEdgeIndex(elabel, name, dir, order, keys);

    log.info("vertex-centric index: ${name} creation is done");
}
 
开发者ID:tedhtchang,项目名称:JanusGraphBench,代码行数:65,代码来源:SchemaLoader.java

示例12: vertices

@Override
public Iterator<Vertex> vertices(final Direction direction) {
    return direction == Direction.BOTH
            ? IteratorUtils.of(getVertex(Direction.OUT), getVertex(Direction.IN))
            : IteratorUtils.of(getVertex(direction));
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:6,代码来源:HBaseEdge.java

示例13: withGraphFilter

public static StarGraphGryoSerializer withGraphFilter(final GraphFilter graphFilter) {
    final StarGraphGryoSerializer serializer = new StarGraphGryoSerializer(Direction.BOTH, graphFilter.clone());
    return serializer;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:4,代码来源:StarGraphGryoSerializer.java


注:本文中的org.apache.tinkerpop.gremlin.structure.Direction.BOTH属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。