imbajin commented on code in PR #2241: URL: https://github.com/apache/incubator-hugegraph/pull/2241#discussion_r1263300821
########## hugegraph-dist/README.md: ########## Review Comment: docker compose aimed for multi process this step mark as WIP & review it later ########## hugegraph-dist/src/assembly/static/scripts/example-preload.groovy: ########## @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +import org.apache.hugegraph.HugeFactory +import org.apache.hugegraph.backend.id.IdGenerator +import org.apache.hugegraph.dist.RegisterUtil +import org.apache.hugegraph.type.define.NodeRole +import org.apache.tinkerpop.gremlin.structure.T + +conf = "conf/graphs/hugegraph.properties" +graph = HugeFactory.open(conf) +schema = graph.schema() + +schema.propertyKey("name").asText().ifNotExist().create() +schema.propertyKey("age").asInt().ifNotExist().create() +schema.propertyKey("city").asText().ifNotExist().create() +schema.propertyKey("weight").asDouble().ifNotExist().create() +schema.propertyKey("lang").asText().ifNotExist().create() +schema.propertyKey("date").asText().ifNotExist().create() +schema.propertyKey("price").asInt().ifNotExist().create() + +schema.vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create() +schema.vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").ifNotExist().create() +schema.indexLabel("personByCity").onV("person").by("city").secondary().ifNotExist().create() +schema.indexLabel("personByAgeAndCity").onV("person").by("age", "city").secondary().ifNotExist().create() +schema.indexLabel("softwareByPrice").onV("software").by("price").range().ifNotExist().create() +schema.edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date", "weight").ifNotExist().create() +schema.edgeLabel("created").sourceLabel("person").targetLabel("software").properties("date", "weight").ifNotExist().create() +schema.indexLabel("createdByDate").onE("created").by("date").secondary().ifNotExist().create() +schema.indexLabel("createdByWeight").onE("created").by("weight").range().ifNotExist().create() +schema.indexLabel("knowsByWeight").onE("knows").by("weight").range().ifNotExist().create() + +marko = graph.addVertex(T.label, "person", "name", "marko", "age", 29, "city", "Beijing") +vadas = graph.addVertex(T.label, "person", "name", "vadas", "age", 27, "city", "Hongkong") +lop = graph.addVertex(T.label, "software", "name", "lop", "lang", "java", "price", 328) +josh = graph.addVertex(T.label, "person", "name", "josh", "age", 32, "city", "Beijing") +ripple = graph.addVertex(T.label, "software", "name", "ripple", "lang", "java", "price", 199) +peter = graph.addVertex(T.label, "person", "name", "peter", "age", 35, "city", "Shanghai") + +marko.addEdge("knows", vadas, "date", "20160110", "weight", 0.5) +marko.addEdge("knows", josh, "date", "20130220", "weight", 1.0) +marko.addEdge("created", lop, "date", "20171210", "weight", 0.4) +josh.addEdge("created", lop, "date", "20091111", "weight", 0.4) +josh.addEdge("created", ripple, "date", "20171210", "weight", 1.0) +peter.addEdge("created", lop, "date", "20170324", "weight", 0.2) + +graph.tx().commit() + +g = graph.traversal() + +System.out.println(">>>> query all vertices: size=" + g.V().toList().size()) +System.out.println(">>>> query all edges: size=" + g.E().toList().size()) Review Comment: lack one empty line ########## hugegraph-dist/src/assembly/static/conf/gremlin-server-preload.yaml: ########## @@ -0,0 +1,126 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# host and port of gremlin server, need to be consistent with host and port in rest-server.properties +#host: 127.0.0.1 +#port: 8182 + +# timeout in ms of gremlin query +evaluationTimeout: 30000 + +channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer +# don't set graph at here, this happens after support for dynamically adding graph +graphs: { +} +scriptEngines: { + gremlin-groovy: { + staticImports: [ + org.opencypher.gremlin.process.traversal.CustomPredicates.*', + org.opencypher.gremlin.traversal.CustomFunctions.* + ], + plugins: { + org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {}, + org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: { + classImports: [ + java.lang.Math, + org.apache.hugegraph.backend.id.IdGenerator, + org.apache.hugegraph.type.define.Directions, + org.apache.hugegraph.type.define.NodeRole, + org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser, + org.apache.hugegraph.traversal.algorithm.CountTraverser, + org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser, + org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser, + org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser, + org.apache.hugegraph.traversal.algorithm.HugeTraverser, + org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser, + org.apache.hugegraph.traversal.algorithm.KneighborTraverser, + org.apache.hugegraph.traversal.algorithm.KoutTraverser, + org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser, + org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser, + org.apache.hugegraph.traversal.algorithm.PathsTraverser, + org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser, + org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser, + org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser, + org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser, + org.apache.hugegraph.traversal.algorithm.SubGraphTraverser, + org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser, + org.apache.hugegraph.traversal.algorithm.steps.EdgeStep, + org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep, + org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep, + org.apache.hugegraph.traversal.optimize.ConditionP, + org.apache.hugegraph.traversal.optimize.Text, + org.apache.hugegraph.traversal.optimize.TraversalUtil, + org.apache.hugegraph.util.DateUtil, + org.opencypher.gremlin.traversal.CustomFunctions, + org.opencypher.gremlin.traversal.CustomPredicate + ], + methodImports: [ + java.lang.Math#*, + org.opencypher.gremlin.traversal.CustomPredicate#*, + org.opencypher.gremlin.traversal.CustomFunctions#* + ] + }, + org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: { + files: [scripts/example-preload.groovy] + } Review Comment: if we only modify one line, consider use `sed` before load the file? so as the `pre-load` groovy file (could show the differ) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
