JanusGraph / janusgraph

JanusGraph: an open-source, distributed graph database
https://janusgraph.org
Other
5.27k stars 1.16k forks source link

Janusgraph 0.3.0 buildEdgeIndex and call GraphIndexStatusWatcher get NullPointException #1446

Closed 12482 closed 5 years ago

12482 commented 5 years ago

i have a edge label 'publish',and the label has a property 'publish_time',i want to build edge index for query edge named 'publish' and sort by 'publish_time',so i build index :

        JanusGraph graph = janusGraphClient.getJanusGraphRWConnPool();
        JanusGraphManagement mgmt = graph.openManagement();
        String propertyKey = "publish_time";
        PropertyKeyMaker maker = mgmt.makePropertyKey(propertyKey).dataType(Long.class).cardinality(Cardinality.SINGLE);;
        maker.make();
        String edgeLabel = "publish";
        EdgeLabelMaker labelMaker = mgmt.makeEdgeLabel(edgeLabel).multiplicity(Multiplicity.SIMPLE);
        labelMaker.make();       
        PropertyKey publish_time = mgmt.getPropertyKey(propertyKey);
    EdgeLabel publish = mgmt.getEdgeLabel(edgeLabel);
        // create vertex-centric index
    mgmt.buildEdgeIndex(publish,"pubtimesort",Direction.BOTH,org.apache.tinkerpop.gremlin.process.traversal.Order.decr, publish_time);
    mgmt.commit();
    try {
        ManagementSystem.awaitGraphIndexStatus(graph, "pubtimesort").call();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    System.out.println("build success ..");
    System.exit(0);

but get error :

        Exception in thread "main" java.lang.NullPointerException
    at org.janusgraph.graphdb.database.management.GraphIndexStatusWatcher.call(GraphIndexStatusWatcher.java:67)
    at com.connection.test.JanusGraphAdminUtilsAllIndexTest.buildEdgeIndex(JanusGraphAdminUtilsAllIndexTest.java:395)
    at com.connection.test.JanusGraphAdminUtilsAllIndexTest.main(JanusGraphAdminUtilsAllIndexTest.java:370)

what is the reason ? and build edgeIndex can speed my query ? thanks

porunov commented 5 years ago

@12482 You should use ManagementSystem.awaitRelationIndexStatus(janusGraph, "pubtimesort", edgeLabel).call(); for vertex centric indexes and ManagementSystem.awaitGraphIndexStatus(graph, "pubtimesort").call(); for composite or mixed indexes.

Also, it looks like your issue isn't a bug report or feature request but rather a question about JanusGraph usage. You should ask those questions in the JanusGraph users group.