Migration from 1.3.x to 1.4.x


GraphDB

OrientDB 1.4.x uses a new optimized structure to manage graphs. You can use the new OrientDB 1.4.x API against graph databases created with OrientDB 1.3.x setting few properties at database level. In this way you can continue to work with your database but remember that this doesn’t use the new structure so it’s strongly suggested to export and import the database.

The new Engine uses some novel techniques based on the idea of a dynamic Graph that change shape at run-time based on the settings and content. The new Engine is much faster than before and needs less space in memory and disk. Below the main improvements:

  • avoid creation of edges as document if haven’t properties. With Graphs wit no properties on edges this can save more than 50% of space on disk and therefore memory with more chances to have a big part of database in cache. Furthermore this speed up traversal too because requires one record load less. As soon as the first property is set the edge is converted transparently
  • Vertex “in” and “out” fields aren’t defined in the schema anymore because can be of different types and change at run-time adapting to the content:
    • no connection = null (no space taken)
    • 1 connection = store as LINK (few bytes)
    • 1 connections = use the Set of LINKS (using the MVRBTreeRIDSet class)

  • binding of Blueprints “label” concept to OrientDB sub-classes. If you create an edge with label “friend”, then the edge sub-type “friend” will be used (created by the engine transparently). This means: 1 field less in document (the field “label”) and therefore less space and the ability to use the technique 1 (see above)
  • edges are stored on different files at file system level because are used different clusters
  • better partitioning against multiple disks (and in the future more parallelism)
  • direct queries like “select from friend” rather than “select from E” and then filtering the result-set looking for the edge with the wanted label property
  • multiple properties for edges of different labels. Not anymore a “in” and “out” in Vertex but “out_friend” to store all the outgoing edges of class “friend”. This means faster traversal of edges giving one or multiple labels avoiding to scan the entire Set of edges to find the right one

Blueprints changes

If you was using Blueprints look also to the Blueprints changes 1.x and 2.x.

Working with database created with 1.3.x

Execute these commands against the open database:

  1. ALTER DATABASE custom useLightweightEdges=false
  2. ALTER DATABASE custom useClassForEdgeLabel=false
  3. ALTER DATABASE custom useClassForVertexLabel=false
  4. ALTER DATABASE custom useVertexFieldsForEdgeLabels=false

Base class changed for Graph elements

Before 1.4.x the base classes for Vertices was “OGraphVertex” with alias “V” and for Edges was “OGraphEdge” with alias “E”. Starting from v1.4 the base class for Vertices is “V” and “E” for Edges. So if in your code you referred “V” and “E” for inheritance nothing is changed (because “V” and “E” was the aliases of OGraphVertex and “OGraphEdge”), but if you used directly “OGraphVertex” and “OGraphEdge” you need to replace them into “V” and “E”.

If you don’t export and import the database you can rename the classes by hand typing these commands:

  1. ALTER CLASS OGraphVertex shortname null
  2. ALTER CLASS OGraphVertex name V
  3. ALTER CLASS OGraphEdge shortname=null
  4. ALTER CLASS OGraphEdge name E

Export and re-import the database

Use GREMLIN and GraphML format.

If you’re exporting the database using the version 1.4.x you’ve to set few configurations at database level. See above Working with database created with 1.3.x.

Export the database

  1. $ cd $ORIENTDB_HOME/bin
  2. $ ./gremlin.sh
  3. \,,,/
  4. (o o)
  5. -----oOOo-(_)-oOOo-----
  6. gremlin> g = new OrientGraph("local:/temp/db");
  7. ==>orientgraph[local:/temp/db]
  8. gremlin> g.saveGraphML("/temp/export.xml")
  9. ==>null

Import the exported database

  1. gremlin> g = new OrientGraph("local:/temp/newdb");
  2. ==>orientgraph[local:/temp/newdb]
  3. gremlin> g.loadGraphML("/temp/export.xml");
  4. ==>null
  5. gremlin>

Your new database will be created under “/temp/newdb” directory.

General Migration

If you want to migrate from release 1.3.x to 1.4.x you’ve to export the database using the 1.3.x and re-import it using 1.4.x. Example:

Export the database using 1.3.x

  1. $ cd $ORIENTDB_HOME/bin
  2. $ ./console.sh
  3. OrientDB console v.1.3.0 - www.orientechnologies.com
  4. Type 'help' to display all the commands supported.
  5. orientdb> CONNECT local:../databases/mydb admin admin
  6. Connecting to database [local:../databases/mydb] with user 'admin'...
  7. OK
  8. orientdb> EXPORT DATABASE /temp/export.json.gz
  9. Exporting current database to: database /temp/export.json.gz...
  10. Started export of database 'mydb' to /temp/export.json.gz...
  11. Exporting database info...OK
  12. Exporting clusters...OK (24 clusters)
  13. Exporting schema...OK (23 classes)
  14. Exporting records...
  15. - Cluster 'internal' (id=0)...OK (records=3/3)
  16. - Cluster 'index' (id=1)...OK (records=0/0)
  17. - Cluster 'manindex' (id=2)...OK (records=1/1)
  18. - Cluster 'default' (id=3)...OK (records=0/0)
  19. - Cluster 'orole' (id=4)...OK (records=3/3)
  20. - Cluster 'ouser' (id=5)...OK (records=3/3)
  21. - Cluster 'ofunction' (id=6)...OK (records=1/1)
  22. - Cluster 'oschedule' (id=7)...OK (records=0/0)
  23. - Cluster 'orids' (id=8).............OK (records=428/428)
  24. - Cluster 'v' (id=9).............OK (records=809/809)
  25. - Cluster 'e' (id=10)...OK (records=0/0)
  26. - Cluster 'followed_by' (id=11).............OK (records=7047/7047)
  27. - Cluster 'sung_by' (id=12)...OK (records=2/2)
  28. - Cluster 'written_by' (id=13)...OK (records=1/1)
  29. - Cluster 'testmodel' (id=14)...OK (records=2/2)
  30. - Cluster 'vertexwithmandatoryfields' (id=15)...OK (records=1/1)
  31. - Cluster 'artist' (id=16)...OK (records=0/0)
  32. - Cluster 'album' (id=17)...OK (records=0/0)
  33. - Cluster 'track' (id=18)...OK (records=0/0)
  34. - Cluster 'sing' (id=19)...OK (records=0/0)
  35. - Cluster 'has' (id=20)...OK (records=0/0)
  36. - Cluster 'person' (id=21)...OK (records=2/2)
  37. - Cluster 'restaurant' (id=22)...OK (records=1/1)
  38. - Cluster 'eat' (id=23)...OK (records=0/0)
  39. Done. Exported 8304 of total 8304 records
  40. Exporting index info...
  41. - Index dictionary...OK
  42. OK (1 indexes)
  43. Exporting manual indexes content...
  44. - Exporting index dictionary ...OK (entries=0)
  45. OK (1 manual indexes)
  46. Database export completed in 1913ms

Re-import the exported database using OrientDB 1.4.x:

  1. $ cd $ORIENTDB_HOME/bin
  2. $ ./console.sh
  3. OrientDB console v.1.3.0 - www.orientechnologies.com
  4. Type 'help' to display all the commands supported.
  5. orientdb> CREATE DATABASE local:../databases/newmydb admin admin local
  6. Creating database [local:../databases/newmydb] using the storage type [local]...
  7. Database created successfully.
  8. Current database is: local:../databases/newmydb
  9. orientdb> IMPORT DATABASE /temp/export.json.gz
  10. Importing database database /temp/export.json.gz...
  11. Started import of database 'local:../databases/newmydb' from /temp/export.json.gz...
  12. Importing database info...OK
  13. Importing clusters...
  14. - Creating cluster 'internal'...OK, assigned id=0
  15. - Creating cluster 'default'...OK, assigned id=3
  16. - Creating cluster 'orole'...OK, assigned id=4
  17. - Creating cluster 'ouser'...OK, assigned id=5
  18. - Creating cluster 'ofunction'...OK, assigned id=6
  19. - Creating cluster 'oschedule'...OK, assigned id=7
  20. - Creating cluster 'orids'...OK, assigned id=8
  21. - Creating cluster 'v'...OK, assigned id=9
  22. - Creating cluster 'e'...OK, assigned id=10
  23. - Creating cluster 'followed_by'...OK, assigned id=11
  24. - Creating cluster 'sung_by'...OK, assigned id=12
  25. - Creating cluster 'written_by'...OK, assigned id=13
  26. - Creating cluster 'testmodel'...OK, assigned id=14
  27. - Creating cluster 'vertexwithmandatoryfields'...OK, assigned id=15
  28. - Creating cluster 'artist'...OK, assigned id=16
  29. - Creating cluster 'album'...OK, assigned id=17
  30. - Creating cluster 'track'...OK, assigned id=18
  31. - Creating cluster 'sing'...OK, assigned id=19
  32. - Creating cluster 'has'...OK, assigned id=20
  33. - Creating cluster 'person'...OK, assigned id=21
  34. - Creating cluster 'restaurant'...OK, assigned id=22
  35. - Creating cluster 'eat'...OK, assigned id=23
  36. Done. Imported 22 clusters
  37. Importing database schema...OK (23 classes)
  38. Importing records...
  39. - Imported records into cluster 'internal' (id=0): 3 records
  40. - Imported records into cluster 'orole' (id=4): 3 records
  41. - Imported records into cluster 'ouser' (id=5): 3 records
  42. - Imported records into cluster 'internal' (id=0): 1 records
  43. - Imported records into cluster 'v' (id=9): 809 records
  44. - Imported records into cluster 'followed_by' (id=11): 7047 records
  45. - Imported records into cluster 'sung_by' (id=12): 2 records
  46. - Imported records into cluster 'written_by' (id=13): 1 records
  47. - Imported records into cluster 'testmodel' (id=14): 2 records
  48. - Imported records into cluster 'vertexwithmandatoryfields' (id=15): 1 records
  49. - Imported records into cluster 'person' (id=21): 2 records
  50. Done. Imported 7874 records
  51. Importing indexes ...
  52. - Index 'dictionary'...OK
  53. Done. Created 1 indexes.
  54. Importing manual index entries...
  55. - Index 'dictionary'...OK (0 entries)
  56. Done. Imported 1 indexes.
  57. Delete temporary records...OK (0 records)
  58. Database import completed in 2383 ms
  59. orientdb>

Your new database will be created under “../databases/newmydb” directory.