在Cassandra中创建JanusGraph .graphml文件架构问题

时间:2019-09-11 02:14:15

标签: cassandra gremlin janusgraph

我正在尝试从.graphml文件创建架构,并使用Cassandra作为后端存储。尝试将数据加载到为附件.graphml文件创建的架构中时,出现以下问题。模式定义如下。

    private static void setAirRouteSchema(JanusGraphManagement mgmt, JanusGraph graph) throws IOException {

//        System.out.println("Inside setAirRouteSchema  "+mgmt);
        // Define edge labels and usage
        mgmt = graph.openManagement();
        mgmt.makeEdgeLabel("Frederick Douglass Boulevard").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("West Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("North Moore Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Nagle Avenue").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Broadway").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Rivington Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("West 144th Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("[u'River Terrace', u'Vesey Place']").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Avenue C").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Division Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Eldridge Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("East 79th Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Madison Avenue").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("East 27th Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("Hester Street").multiplicity(MULTI).make();
        mgmt.makeEdgeLabel("East 81st Street").multiplicity(MULTI).make();
        mgmt.commit();

// Define vertex labels
        mgmt = graph.openManagement();
        mgmt.makeVertexLabel("traffic_signals").make();
        mgmt.commit();

// Define vertex property keys
        mgmt = graph.openManagement();
        mgmt.makePropertyKey("ref").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("highway").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("osmid").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("x").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("y").dataType(String.class).cardinality(Cardinality.SINGLE).make();
        mgmt.commit();

// Define edge property keys
        mgmt = graph.openManagement();
        mgmt.makePropertyKey("service").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("access").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("width").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("tunnel").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("bridge").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
//        mgmt.makePropertyKey("ref").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("geometry").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("maxspeed").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("lanes").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
//        mgmt.makePropertyKey("key").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("oneway").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
//        mgmt.makePropertyKey("highway").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
//        mgmt.makePropertyKey("osmid").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("length").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.makePropertyKey("name").dataType(Integer.class).cardinality(Cardinality.SINGLE).make();
        mgmt.commit();

}

GraphMl file loaded from here : https://www.kaggle.com/crailtap/street-network-of-new-york-in-graphml

Error :

Exception in thread "main" java.lang.IllegalArgumentException: Name cannot be in protected namespace: edge
    at org.janusgraph.graphdb.types.system.SystemTypeManager.throwIfSystemName(SystemTypeManager.java:72)
    at org.janusgraph.graphdb.types.StandardRelationTypeMaker.name(StandardRelationTypeMaker.java:181)
    at org.janusgraph.graphdb.types.StandardRelationTypeMaker.<init>(StandardRelationTypeMaker.java:53)

Also Schema is being created but data is not getting entered. Printing the schema created:

------------------------------------------------------------------------------------------------
Vertex Label Name              | Partitioned | Static                                             |
---------------------------------------------------------------------------------------------------
traffic_signals                | false       | false                                              |
---------------------------------------------------------------------------------------------------
Edge Label Name                | Directed    | Unidirected | Multiplicity                         |
---------------------------------------------------------------------------------------------------
East 81st Street               | true        | false       | MULTI                                |
Frederick Douglass Boulevard   | true        | false       | MULTI                                |
West Street                    | true        | false       | MULTI                                |
North Moore Street             | true        | false       | MULTI                                |
Nagle Avenue                   | true        | false       | MULTI                                |
Broadway                       | true        | false       | MULTI                                |
Rivington Street               | true        | false       | MULTI                                |
West 144th Street              | true        | false       | MULTI                                |
[u'River Terrace', u'Vesey Place'] | true        | false       | MULTI                                |
Avenue C                       | true        | false       | MULTI                                |
Division Street                | true        | false       | MULTI                                |
Eldridge Street                | true        | false       | MULTI                                |
East 79th Street               | true        | false       | MULTI                                |
Madison Avenue                 | true        | false       | MULTI                                |
East 27th Street               | true        | false       | MULTI                                |
Hester Street                  | true        | false       | MULTI                                |
---------------------------------------------------------------------------------------------------
Property Key Name              | Cardinality | Data Type                                          |
---------------------------------------------------------------------------------------------------
ref                            | SINGLE      | class java.lang.String                             |
highway                        | SINGLE      | class java.lang.String                             |
osmid                          | SINGLE      | class java.lang.String                             |
x                              | SINGLE      | class java.lang.String                             |
y                              | SINGLE      | class java.lang.String                             |
service                        | SINGLE      | class java.lang.Integer                            |
access                         | SINGLE      | class java.lang.Integer                            |
width                          | SINGLE      | class java.lang.Integer                            |
tunnel                         | SINGLE      | class java.lang.Integer                            |
bridge                         | SINGLE      | class java.lang.Integer                            |
geometry                       | SINGLE      | class java.lang.Integer                            |
maxspeed                       | SINGLE      | class java.lang.Integer                            |
lanes                          | SINGLE      | class java.lang.Integer                            |
oneway                         | SINGLE      | class java.lang.Integer                            |
length                         | SINGLE      | class java.lang.Integer                            |
name                           | SINGLE      | class java.lang.Integer                            |
---------------------------------------------------------------------------------------------------
Vertex Index Name              | Type        | Unique    | Backing        | Key:           Status |
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Edge Index (VCI) Name          | Type        | Unique    | Backing        | Key:           Status |
----------------------------------

--------------------------------------------------- ------------------

相关指数|类型方向|排序键|订购|状态|

1 个答案:

答案 0 :(得分:2)

我不确定这是否是问题所在,但GraphML不包含TinkerPop -csplit所期望的预期边缘和顶点标签(分别为GraphMLReaderlabelE)。您可以调整数据,也可以配置labelV以在通过GraphMLReaderGraphMLReader.Builder.edgeLabelKey()指定的数据中使用属性键。您可以在javadoc中看到这些配置和其他配置。

我认为您想做类似的事情:

vertexLabelKey()

请注意,如果您使用的是TinkerPop的较新版本,则可以通过以下方式使用Gremlin:

GraphMLReader reader = GraphMLReader.build().edgeLabelKey(<whatever your label field is>).create();
InputStream input = FileInputStream(<path to graphml file>);
reader.readGraph(input, graph);