diff --git a/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example1.java b/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example1.java index b99e57b7d4..3d79446993 100644 --- a/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example1.java +++ b/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example1.java @@ -165,8 +165,10 @@ public static void loadSchema(final HugeGraph graph) { // schemaManager.getVertexLabel("author").index("byName").secondary().by("name").add(); // schemaManager.getVertexLabel("recipe").index("byRecipe").materialized().by("name").add(); // schemaManager.getVertexLabel("meal").index("byMeal").materialized().by("name").add(); - // schemaManager.getVertexLabel("ingredient").index("byIngredient").materialized().by("name").add(); - // schemaManager.getVertexLabel("reviewer").index("byReviewer").materialized().by("name").add(); + // schemaManager.getVertexLabel("ingredient").index("byIngredient").materialized() + // .by("name").add(); + // schemaManager.getVertexLabel("reviewer").index("byReviewer").materialized() + // .by("name").add(); LOG.info("=============== edgeLabel ================"); @@ -268,20 +270,19 @@ public static void testQuery(final HugeGraph graph) { GraphTraversal vertices = graph.traversal().V(); int size = vertices.toList().size(); assert size == 12; - System.out.println(">>>> query all vertices: size=" + size); + LOG.info(">>>> query all vertices: size {}", size); // query by label vertices = graph.traversal().V().hasLabel("person"); size = vertices.toList().size(); assert size == 5; - System.out.println(">>>> query all persons: size=" + size); + LOG.info(">>>> query all persons: size {}", size); // query vertex by primary-values vertices = graph.traversal().V().hasLabel("author").has("id", 1); List vertexList = vertices.toList(); assert vertexList.size() == 1; - System.out.println(">>>> query vertices by primary-values: " + - vertexList); + LOG.info(">>>> query vertices by primary-values: {}", vertexList); VertexLabel author = graph.schema().getVertexLabel("author"); String authorId = String.format("%s:%s", author.id().asString(), "11"); @@ -291,20 +292,19 @@ public static void testQuery(final HugeGraph graph) { GraphTraversal edgesOfVertex = vertices.outE("created"); List edgeList = edgesOfVertex.toList(); assert edgeList.size() == 1; - System.out.println(">>>> query edges of vertex: " + edgeList); + LOG.info(">>>> query edges of vertex: {}", edgeList); vertices = graph.traversal().V(authorId); vertexList = vertices.out("created").toList(); assert vertexList.size() == 1; - System.out.println(">>>> query vertices of vertex: " + vertexList); + LOG.info(">>>> query vertices of vertex: {}", vertexList); // query edge by sort-values vertices = graph.traversal().V(authorId); edgesOfVertex = vertices.outE("write").has("time", "2017-4-28"); edgeList = edgesOfVertex.toList(); assert edgeList.size() == 2; - System.out.println(">>>> query edges of vertex by sort-values: " + - edgeList); + LOG.info(">>>> query edges of vertex by sort-values: {}", edgeList); // query vertex by condition (filter by property name) ConditionQuery q = new ConditionQuery(HugeType.VERTEX); @@ -314,9 +314,9 @@ public static void testQuery(final HugeGraph graph) { .supportsQueryWithContainsKey()) { Iterator iter = graph.vertices(q); assert iter.hasNext(); - System.out.println(">>>> queryVertices(age): " + iter.hasNext()); + LOG.info(">>>> queryVertices(age): {}", iter.hasNext()); while (iter.hasNext()) { - System.out.println(">>>> queryVertices(age): " + iter.next()); + LOG.info(">>>> queryVertices(age): {}", iter.next()); } } @@ -324,7 +324,7 @@ public static void testQuery(final HugeGraph graph) { GraphTraversal edges = graph.traversal().E().limit(2); size = edges.toList().size(); assert size == 2; - System.out.println(">>>> query all edges with limit 2: size=" + size); + LOG.info(">>>> query all edges with limit 2: size {}", size); // query edge by id EdgeLabel authored = graph.edgeLabel("authored"); @@ -337,13 +337,13 @@ public static void testQuery(final HugeGraph graph) { edges = graph.traversal().E(edgeId); edgeList = edges.toList(); assert edgeList.size() == 1; - System.out.println(">>>> query edge by id: " + edgeList); + LOG.info(">>>> query edge by id: {}", edgeList); Edge edge = edgeList.get(0); edges = graph.traversal().E(edge.id()); edgeList = edges.toList(); assert edgeList.size() == 1; - System.out.println(">>>> query edge by id: " + edgeList); + LOG.info(">>>> query edge by id: {}", edgeList); // query edge by condition q = new ConditionQuery(HugeType.EDGE); @@ -355,11 +355,9 @@ public static void testQuery(final HugeGraph graph) { Iterator edges2 = graph.edges(q); assert edges2.hasNext(); - System.out.println(">>>> queryEdges(id-condition): " + - edges2.hasNext()); + LOG.info(">>>> queryEdges(id-condition): {}", edges2.hasNext()); while (edges2.hasNext()) { - System.out.println(">>>> queryEdges(id-condition): " + - edges2.next()); + LOG.info(">>>> queryEdges(id-condition): {}", edges2.next()); } // NOTE: query edge by has-key just supported by Cassandra @@ -368,11 +366,9 @@ public static void testQuery(final HugeGraph graph) { q.key(HugeKeys.PROPERTIES, contribution.id()); Iterator edges3 = graph.edges(q); assert edges3.hasNext(); - System.out.println(">>>> queryEdges(contribution): " + - edges3.hasNext()); + LOG.info(">>>> queryEdges(contribution): {}", edges3.hasNext()); while (edges3.hasNext()) { - System.out.println(">>>> queryEdges(contribution): " + - edges3.next()); + LOG.info(">>>> queryEdges(contribution): {}", edges3.next()); } } @@ -380,40 +376,39 @@ public static void testQuery(final HugeGraph graph) { vertices = graph.traversal().V().hasLabel("book"); size = vertices.toList().size(); assert size == 5; - System.out.println(">>>> query all books: size=" + size); + LOG.info(">>>> query all books: size {}", size); // query by vertex label and key-name vertices = graph.traversal().V().hasLabel("person").has("age"); size = vertices.toList().size(); assert size == 5; - System.out.println(">>>> query all persons with age: size=" + size); + LOG.info(">>>> query all persons with age: size {}", size); // query by vertex props vertices = graph.traversal().V().hasLabel("person") .has("city", "Taipei"); vertexList = vertices.toList(); assert vertexList.size() == 1; - System.out.println(">>>> query all persons in Taipei: " + vertexList); + LOG.info(">>>> query all persons in Taipei: {}", vertexList); vertices = graph.traversal().V().hasLabel("person").has("age", 19); vertexList = vertices.toList(); assert vertexList.size() == 1; - System.out.println(">>>> query all persons age==19: " + vertexList); + LOG.info(">>>> query all persons age==19: {}", vertexList); vertices = graph.traversal().V().hasLabel("person") .has("age", P.lt(19)); vertexList = vertices.toList(); assert vertexList.size() == 1; assert vertexList.get(0).property("age").value().equals(3); - System.out.println(">>>> query all persons age<19: " + vertexList); + LOG.info(">>>> query all persons age<19: {}", vertexList); String addr = "Bay Area"; vertices = graph.traversal().V().hasLabel("author") .has("lived", Text.contains(addr)); vertexList = vertices.toList(); assert vertexList.size() == 1; - System.out.println(String.format(">>>> query all authors lived %s: %s", - addr, vertexList)); + LOG.info(">>>> query all authors lived {}: {}", addr, vertexList); } public static void testRemove(final HugeGraph graph) { @@ -427,7 +422,7 @@ public static void testRemove(final HugeGraph graph) { james.addEdge("look", book6, "timestamp", "2017-5-3 12:00:08.0"); graph.tx().commit(); assert graph.traversal().V(book6.id()).bothE().hasNext(); - System.out.println(">>>> removing vertex: " + james); + LOG.info(">>>> removing vertex: {}", james); james.remove(); graph.tx().commit(); assert !graph.traversal().V(james.id()).hasNext(); @@ -443,10 +438,10 @@ public static void testRemove(final HugeGraph graph) { String edgeId = String.format("S%s>%s>%s>S%s", authorId, authored.id(), "", book2Id); - List edges = graph.traversal().E(edgeId).toList(); + List edges = graph.traversal().E(edgeId).toList(); assert edges.size() == 1; Edge edge = edges.get(0); - System.out.println(">>>> removing edge: " + edge); + LOG.info(">>>> removing edge: {}", edge); edge.remove(); graph.tx().commit(); assert !graph.traversal().E(edgeId).hasNext(); diff --git a/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example2.java b/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example2.java index 28588c0912..dfcafb967d 100644 --- a/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example2.java +++ b/hugegraph-example/src/main/java/com/baidu/hugegraph/example/Example2.java @@ -58,16 +58,14 @@ public static void traversal(final HugeGraph graph) { GraphTraversalSource g = graph.traversal(); GraphTraversal vertices = g.V(); - System.out.println(">>>> query all vertices: size=" + - vertices.toList().size()); + LOG.info(">>>> query all vertices: size {}", vertices.toList().size()); List edges = g.E().toList(); - System.out.println(">>>> query all edges: size=" + - edges.size()); + LOG.info(">>>> query all edges: size {}", edges.size()); List names = g.V().inE("knows").limit(2) .outV().values("name").toList(); - System.out.println(">>>> query vertex(with props) of edges: " + names); + LOG.info(">>>> query vertex(with props) of edges: {}", names); assert names.size() == 2 : names.size(); names = g.V().as("a") @@ -75,11 +73,11 @@ public static void traversal(final HugeGraph graph) { .and() .out("created").in("created").as("a").values("name") .toList(); - System.out.println(">>>> query with AND: " + names); + LOG.info(">>>> query with AND: {}", names); assert names.size() == 1 : names.size(); List vertex = g.V().has("age", 29).toList(); - System.out.println(">>>> age = 29: " + vertex); + LOG.info(">>>> age = 29: {}", vertex); assert vertex.size() == 1 && vertex.get(0).value("name").equals("marko"); @@ -87,12 +85,12 @@ public static void traversal(final HugeGraph graph) { .has("age", 29) .has("city", "Beijing") .toList(); - System.out.println(">>>> age = 29 and city is Beijing: " + vertex); + LOG.info(">>>> age = 29 and city is Beijing: {}", vertex); assert vertex.size() == 1 && vertex.get(0).value("name").equals("marko"); edges = g.E().has("weight", P.lt(1.0)).toList(); - System.out.println(">>>> edges with weight < 1.0: " + edges); + LOG.info(">>>> edges with weight < 1.0: {}", edges); assert edges.size() == 4; String person = graph.schema().getVertexLabel("person").id().asString(); @@ -107,12 +105,11 @@ public static void traversal(final HugeGraph graph) { .has("weight", P.lt(1.0)) .otherV() .toList(); - System.out.println(">>>> josh's both edges with weight < 1.0: " + - vertex); + LOG.info(">>>> josh's both edges with weight < 1.0: ", vertex); assert vertex.size() == 1 && vertex.get(0).value("name").equals("lop"); List paths = g.V(markoId).out().out().path().by("name").toList(); - System.out.println(">>>> test out path: " + paths); + LOG.info(">>>> test out path: {}", paths); assert paths.size() == 2; assert paths.get(0).get(0).equals("marko"); assert paths.get(0).get(1).equals("josh"); @@ -122,17 +119,17 @@ public static void traversal(final HugeGraph graph) { assert paths.get(1).get(2).equals("ripple"); paths = shortestPath(graph, markoId, lopId, 5); - System.out.println(">>>> test shortest path: " + paths.get(0)); + LOG.info(">>>> test shortest path: {}", paths.get(0)); assert paths.get(0).get(0).equals("marko"); assert paths.get(0).get(1).equals("lop"); - System.out.println(">>>> query with out() optimize: " + + LOG.info(">>>> query with out() optimize: {}", graph.traversal().V(markoId) .out() .out() .values("name").toList()); - System.out.println(">>>> query with out() optimize and path(): " + + LOG.info(">>>> query with out() optimize and path(): {}", graph.traversal().V() .out("knows") .out("created")