@GET @Timed @Produces(APPLICATION_JSON_WITH_CHARSET) public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("source") String sourceV, @QueryParam("direction") String direction, @QueryParam("label") String edgeLabel, @QueryParam("max_depth") int depth, @QueryParam("max_degree") @DefaultValue("-1") long degree, @QueryParam("capacity") @DefaultValue("-1") long capacity, @QueryParam("limit") @DefaultValue("-1") long limit) { LOG.debug("Graph [{}] get rays paths from '{}' with " + "direction '{}', edge label '{}', max depth '{}', " + "max degree '{}' and limit '{}'", graph, sourceV, direction, edgeLabel, depth, degree, limit); Id source = VertexAPI.checkAndParseVertexId(sourceV); Directions dir = Directions.convert(EdgeAPI.parseDirection(direction)); HugeGraph g = graph(manager, graph); HugeTraverser traverser = new HugeTraverser(g); List<HugeTraverser.Path> paths = traverser.rays(source, dir, edgeLabel, depth, degree, capacity, limit); return manager.serializer(g).writePaths("rays", paths, false); } }
@GET @Timed @Produces(APPLICATION_JSON_WITH_CHARSET) public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("source") String sourceV, @QueryParam("direction") String direction, @QueryParam("label") String edgeLabel, @QueryParam("max_depth") int depth, @QueryParam("max_degree") @DefaultValue("-1") long degree, @QueryParam("capacity") @DefaultValue("-1") long capacity, @QueryParam("limit") @DefaultValue("-1") long limit) { LOG.debug("Graph [{}] get rings paths reachable from '{}' with " + "direction '{}', edge label '{}', max depth '{}', " + "max degree '{}' and limit '{}'", graph, sourceV, direction, edgeLabel, depth, degree, limit); Id source = VertexAPI.checkAndParseVertexId(sourceV); Directions dir = Directions.convert(EdgeAPI.parseDirection(direction)); HugeGraph g = graph(manager, graph); HugeTraverser traverser = new HugeTraverser(g); List<HugeTraverser.Path> paths = traverser.rings(source, dir, edgeLabel, depth, degree, capacity, limit); return manager.serializer(g).writePaths("rings", paths, false); } }
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
@GET @Timed @Produces(APPLICATION_JSON_WITH_CHARSET) public String get(@Context GraphManager manager, @PathParam("graph") String graph, @QueryParam("source") String sourceV, @QueryParam("direction") String direction, @QueryParam("label") String edgeLabel, @QueryParam("max_depth") int depth, @QueryParam("max_degree") @DefaultValue("-1") long degree, @QueryParam("limit") @DefaultValue("-1") long limit) { LOG.debug("Graph [{}] get k-neighbor from '{}' with " + "direction '{}', edge label '{}', max depth '{}', " + "max degree '{}' and limit '{}'", graph, sourceV, direction, edgeLabel, depth, degree, limit); Id source = VertexAPI.checkAndParseVertexId(sourceV); Directions dir = Directions.convert(EdgeAPI.parseDirection(direction)); HugeGraph g = graph(manager, graph); HugeTraverser traverser = new HugeTraverser(g); Set<Id> ids = traverser.kneighbor(source, dir, edgeLabel, depth, degree, limit); return manager.serializer(g).writeIds("vertices", ids); } }
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
public static EdgeId parse(String id) throws NotFoundException { String[] idParts = SplicingIdGenerator.split(id); if (!(idParts.length == 4 || idParts.length == 5)) { throw new NotFoundException("Edge id must be formatted as 4~5 parts" + ", but got '%s'", id); } try { if (idParts.length == 4) { Id ownerVertexId = IdUtil.readString(idParts[0]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[1])); String sortValues = idParts[2]; Id otherVertexId = IdUtil.readString(idParts[3]); return new EdgeId(ownerVertexId, Directions.OUT, edgeLabelId, sortValues, otherVertexId); } else { assert idParts.length == 5; Id ownerVertexId = IdUtil.readString(idParts[0]); HugeType direction = HugeType.fromString(idParts[1]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[2])); String sortValues = idParts[3]; Id otherVertexId = IdUtil.readString(idParts[4]); return new EdgeId(ownerVertexId, Directions.convert(direction), edgeLabelId, sortValues, otherVertexId); } } catch (Exception e) { throw new NotFoundException("Invalid format of edge id '%s'", id); } }
@Watched(prefix = "vertex") @Override public Iterator<Edge> edges(Direction tinkerpopDir, String... edgeLabels) { Directions direction = Directions.convert(tinkerpopDir); // NOTE: get edges from memory if load all edges when loading vertex. if (this.existsEdges()) { return this.getEdges(direction, edgeLabels); } Id[] edgeLabelIds = this.graph().mapElName2Id(edgeLabels); Query query = GraphTransaction.constructEdgesQuery(this.id(), direction, edgeLabelIds); return this.tx().queryEdges(query); }
Directions direction = Directions.convert(this.getDirection()); String[] edgeLabels = this.getEdgeLabels();
@Watched(prefix = "vertex") @Override public Iterator<Edge> edges(Direction tinkerpopDir, String... edgeLabels) { Directions direction = Directions.convert(tinkerpopDir); // NOTE: get edges from memory if load all edges when loading vertex. if (this.existsEdges()) { return this.getEdges(direction, edgeLabels); } Id[] edgeLabelIds = this.graph().mapElName2Id(edgeLabels); Query query = GraphTransaction.constructEdgesQuery(this.id(), direction, edgeLabelIds); return this.tx().queryEdges(query); }
public static EdgeId parse(String id) throws NotFoundException { String[] idParts = SplicingIdGenerator.split(id); if (!(idParts.length == 4 || idParts.length == 5)) { throw new NotFoundException("Edge id must be formatted as 4~5 parts" + ", but got '%s'", id); } try { if (idParts.length == 4) { Id ownerVertexId = IdUtil.readString(idParts[0]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[1])); String sortValues = idParts[2]; Id otherVertexId = IdUtil.readString(idParts[3]); return new EdgeId(ownerVertexId, Directions.OUT, edgeLabelId, sortValues, otherVertexId); } else { assert idParts.length == 5; Id ownerVertexId = IdUtil.readString(idParts[0]); HugeType direction = HugeType.fromString(idParts[1]); Id edgeLabelId = IdGenerator.of(Long.parseLong(idParts[2])); String sortValues = idParts[3]; Id otherVertexId = IdUtil.readString(idParts[4]); return new EdgeId(ownerVertexId, Directions.convert(direction), edgeLabelId, sortValues, otherVertexId); } } catch (Exception e) { throw new NotFoundException("Invalid format of edge id '%s'", id); } }
Directions direction = Directions.convert(this.getDirection()); String[] edgeLabels = this.getEdgeLabels();