简体   繁体   English

OrientDB Java批量导入

[英]OrientDB Java Batch Import

I have a bigger problem with the batch import in OrientDB when I use Java. 使用Java时,在OrientDB中批量导入存在更大的问题。

My data is a collection of recordID's and tokens. 我的数据是recordID和令牌的集合。 For each ID exists a set of tokens but tokens can be in several ID'S. 对于每个ID,都有一组令牌,但是令牌可以位于多个ID中。

Example: 例:

ID Tokens ID令牌

1 2,3,4 1 2,3,4

2 3,5,7 2 3,5,7

3 1,2,4 3 1,2,4

My graph should have two types of verticies: rIDClass and tokenClass . 我的图应具有两种类型的折点: rIDClasstokenClass I want to give each vertex an ID corresponding to the recordID and the token. 我想给每个顶点一个对应于recordID和令牌的ID。 So the total number of tokenClass vertices should be the total number of unique tokens in the data. 因此tokenClass顶点的总数应为数据中唯一令牌的总数。 (Each token is only created once!) (每个令牌仅创建一次!)

How can I realize this problem? 我怎么能意识到这个问题? I tried the "Custom Batch Insert" from the original documentation and I tried the method "Batch Implementation", described in the blueprints documentation. 我尝试了原始文档中的“自定义批处理插入”,并尝试了蓝图文档中介绍的“批处理实现”方法。

The problem at the first method is that OrientDB creates for each inserted token a separate vertex with a custom ID, which is set by the system itself. 第一种方法的问题是OrientDB为每个插入的令牌创建一个具有自定义ID的单独顶点,该顶点由系统本身设置。

The problem at the second method is when I try to add a vertex to the batchgraph I can't set the corresponding vertex Class and additionally I get an Exception. 第二种方法的问题是,当我尝试向批处理图中添加一个顶点时,我无法设置相应的顶点类,而且还得到了异常。 This is my code from the second method: 这是第二种方法的代码:

BatchGraph<OrientGraph> bgraph = new BatchGraph<OrientGraph>(graph, VertexIDType.STRING, 1);
Vertex vertex1 =  bgraph.addVertex(1);
vertex1.setProperty("uid", 1);

Maybe someone has a solution. 也许有人有解决方案。

Vertex vertex2 = bgraph.addVertex(2);
vertex2.setProperty("uid", 2);

Edge edge1 = graph.addEdge(12, vertex1 , vertex2, "EdgeConnectClass");

And I get the following Exception: 我得到以下异常:

Exception in thread "main" java.lang.ClassCastException:
com.tinkerpop.blueprints.util.wrappers.batch.BatchGraph$BatchVertex cannot be cast to com.tinkerpop.blueprints.impls.orient.OrientVertex
    at com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.addEdge(OrientBaseGraph.java:612)
    at App.indexRecords3(App.java:83)
    at App.main(App.java:47)

I don't know if I understood correctly but, if you want a schema like this: 我不知道我是否理解正确,但是,如果您想要这样的架构:

在此处输入图片说明

try this: 尝试这个:

Vertex vertex1 = g.addVertex("class:rIDClass");
vertex1.setProperty("uid", 1);

Vertex token2 = g.addVertex("class:tokenClass");
token2.setProperty("uid", 2);

Edge edge1 = g.addEdge("class:rIDClass", vertex1, token2, "EdgeConnectClass");

Hope it helps 希望能帮助到你

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM