janusgraph.graphml文件在cassandra中创建时出现架构问题

hkmswyz6  于 2021-06-14  发布在  Cassandra
关注(0)|答案(2)|浏览(419)

我正在尝试从.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 |
----------------------------------

cclgggtu

cclgggtu1#

我不确定这是否是问题所在,但是graphml没有包含修补匠所期望的边和顶点标签 GraphMLReader 期望(即。 labelE 以及 labelV 分别)。您可以调整数据或配置 GraphMLReader 在数据中使用通过 GraphMLReader.Builder.edgeLabelKey() 以及 vertexLabelKey() . 您可以在javadoc中看到这些配置和其他配置。
我想你应该做一些类似的事情:

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

请注意,如果您使用的是tinkerpop的较新版本,则只需将gremlin与:

GraphMLReader reader = GraphMLReader.build().edgeLabelKey(<whatever your label field is>).create();
g.io(<path to graphml file>).
    with(IO.reader, reader).
    read().iterate()
ncecgwcz

ncecgwcz2#


关系索引|类型|方向|排序键|顺序|状态|

相关问题