This is my code (I didn't use actually Book and Author tables, I used my
domain specific tables, but here I illustrated problem with these common
names to make it easier to understand).
This works, but my question is could this be done using just ETL without
any coding.
Map<Integer, Vertex> bookMap = new HashMap<>();
String queryString = "SELECT * FROM Books";
Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(queryString);
while (rs.next()) {
Vertex bookVertex = graph.addVertex("class:Book");
Integer bookId = rs.getInt(1);
bookVertex.setProperty(...);
// fill vertex from result set
bookMap.put(bookId, bookVertex);
}
rs.close();
statement.close();
Map<Integer, Vertex> authorMap = new HashMap<>();
queryString = "SELECT * FROM Authors";
statement = connection.createStatement();
rs = statement.executeQuery(queryString);
while (rs.next()) {
Vertex authorVertex = graph.addVertex("class:Author");
Integer authorId = rs.getInt(1);
authorVertex.setProperty(...);
// fill vertex from result set
authorMap.put(authorId, authorVertex);
}
rs.close();
statement.close();
graph.commit();
queryString = "SELECT * FROM BookAuthor";
statement = connection.createStatement();
rs = statement.executeQuery(queryString);
while (rs.next()) {
Integer bookId = rs.getInt(2);
Integer authorId = rs.getInt(2);
Edge edge = graph.addEdge(null, bookMap.get(bookId),
authorMap.get(authorId), "BookAuthor");
edge.setProperty(....);
}
rs.close();
statement.close();
graph.commit();
On Monday, 20 October 2014 20:51:22 UTC+2, Lvc@ wrote:
>
> @Bojan, How did you import edges? Can you share the code? It's hard to
> help without any information.
>
> Lvc@
>
>
> On 20 October 2014 13:31, 'Curtis Mosters' via OrientDB <
> [email protected] <javascript:>> wrote:
>
>> Is you code secret? I still don't understand the real issue you have,
>> sorry.
>>
>> Am Montag, 20. Oktober 2014 15:26:27 UTC+2 schrieb Bojan Vukotić:
>>
>>>
>>> Well, that's exactly what I need (and what I already did). I thought
>>> maybe that ETL has some API that we could use to make this easier (I used
>>> 'pure' OrientDB API to implement this)
>>>
>>>
>>>
>>> On Monday, 20 October 2014 15:15:27 UTC+2, Curtis Mosters wrote:
>>>>
>>>> I think I don't understand your issue:
>>>>
>>>> First of all you import all Books. So you have all the data in there.
>>>> Now setting an index on the Book.ID.
>>>>
>>>> After that the Authors are imported. They are matched with the ID of
>>>> the Book. I think in your case the Author matched with a Book is the same
>>>> like the Book.ID? Or do you have another file containing the relations of
>>>> the ID's?
>>>>
>>>> Can you post here the first 10 lines of each file maybe? That would
>>>> help a low.
>>>>
>>>> Am Montag, 20. Oktober 2014 14:55:10 UTC+2 schrieb Bojan Vukotić:
>>>>>
>>>>> I took example from here http://www.orientechnologies.
>>>>> com/docs/last/orientdb-etl.wiki/Import-from-DBMS.html
>>>>>
>>>>> When can I find ETL/Java example?
>>>>>
>>>>>
>>>>>
>>>>> On Monday, 20 October 2014 14:43:11 UTC+2, Curtis Mosters wrote:
>>>>>>
>>>>>> Well I think it's way better to create a Java example. Then you
>>>>>> understand what is happening in the background. Otherwhise in my tests
>>>>>> the
>>>>>> ETL way had the same speed, but these tests are 3-4 month old. I will
>>>>>> redo
>>>>>> them soon. Did you take the example of ETL from OrientDB? Otherwhise
>>>>>> look
>>>>>> above for some examples. Or even post yours here?
>>>>>>
>>>>>> Am Montag, 20. Oktober 2014 12:36:57 UTC+2 schrieb Bojan Vukotić:
>>>>>>>
>>>>>>>
>>>>>>> I prefer do it with ETL, if it is possible, I would like to avoid
>>>>>>> programming. If not, Java is also a good solution.
>>>>>>>
>>>>>>> So, example how to do it in ETL? And regarding ETL, I was playing
>>>>>>> with it, it imports vertices nicely, but when I want to import edges
>>>>>>> (100
>>>>>>> 000 of them) it is extremely slow :( How to improve this?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Monday, 20 October 2014 12:16:08 UTC+2, Curtis Mosters wrote:
>>>>>>>>
>>>>>>>> Well you have several ways. Do you want to do it with JAVA oder the
>>>>>>>> ETL plugin?
>>>>>>>>
>>>>>>>> In any case I think it should be
>>>>>>>>
>>>>>>>> Vertices: Author, Book
>>>>>>>> Edge: WROTE
>>>>>>>>
>>>>>>>> WDYT?
>>>>>>>>
>>>>>>>> Am Montag, 20. Oktober 2014 10:51:03 UTC+2 schrieb Bojan Vukotić:
>>>>>>>>>
>>>>>>>>> Hi guys!
>>>>>>>>>
>>>>>>>>> The whole discussion here is how to create edges from one table to
>>>>>>>>> another, but what to do if we have more complex cases where we have
>>>>>>>>> connected 2 (or even more) tables? Example, n:n relation: book and
>>>>>>>>> authors,
>>>>>>>>> book can have one or more authors and author can work on one or more
>>>>>>>>> books.
>>>>>>>>>
>>>>>>>>> Tables:
>>>>>>>>>
>>>>>>>>> Book {
>>>>>>>>> book_id
>>>>>>>>> book_name,
>>>>>>>>> ....
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> Author {
>>>>>>>>> author_id,
>>>>>>>>> author_name,
>>>>>>>>> ......
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Author_on_Book {
>>>>>>>>> ab_id,
>>>>>>>>> book_id,
>>>>>>>>> author_id,
>>>>>>>>> description // describes what this author did on this book
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> How to migrate this case? Should "Author_on_Book" be migrated as a
>>>>>>>>> vertex or edge? How to write scripts in this case? (in real life we
>>>>>>>>> could
>>>>>>>>> have even more foreign keys in "Author_on_Book" table )
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "OrientDB" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.