How to create lightweight edges from console?

109 views
Skip to first unread message

ky...@ovguideinc.com

unread,
Apr 16, 2015, 3:40:41 PM4/16/15
to orient-...@googlegroups.com
I am using orientdb 2.0.7
I cannot create lightweight edges in the console 

I executed 
alter database custom useLightweightEdges=true

If I try to create a lightweight edge labeled "knows" I get the following error:
Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Class 'KNOWS' was not found



I am able to create lightweight edges using gremlin.


orientdb> create database plocal:/home/kyle/Downloads/orientdb-community-2.0.7/databases/ledge_test2 admin admin
Creating database [plocal:/home/kyle/Downloads/orientdb-community-2.0.7/databases/ledge_test2] using the storage type [plocal]...
Database created successfully.
Current database is: plocal:/home/kyle/Downloads/orientdb-community-2.0.7/databases/ledge_test2
orientdb {db=ledge_test2}> alter database custom useLightweightEdges=true
Database updated successfully
orientdb {db=ledge_test2}> insert into V set myid = 1
Inserted record 'V#9:0{myid:1} v1' in 0.007000 sec(s).
orientdb {db=ledge_test2}> insert into V set myid = 2
Inserted record 'V#9:1{myid:2} v1' in 0.001000 sec(s).
orientdb {db=ledge_test2}> create edge knows from #9:0 to #9:1
Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Class 'KNOWS' was not found
orientdb {db=ledge_test2}> disconnect
Disconnecting from the database [ledge_test2]...OK
orientdb> exit

now go to gremlin console!

gremlin> g = new OrientGraph("remote:localhost/ledge_test2")
Apr 16, 2015 12:32:55 PM com.orientechnologies.common.log.OLogManager log
INFO: OrientDB auto-config DISKCACHE=13,498MB (heap=455MB os=16,002MB disk=30,513MB)
==>orientgraph[remote:localhost/ledge_test2]
gremlin> g.isUseLightweightEdges()
==>true
gremlin> v1=g.V[0].next();v2=g.V[1].next();
==>v[#9:1]
gremlin> e=v1.addEdge("knows",v2)
==>e[#9:0->#9:1][#9:0-knows->#9:1]
gremlin> e
==>e[#9:0->#9:1][#9:0-knows->#9:1]
gremlin> e.isLightweight()
==>true


there are closed issues on github so I figured I'd ask here first in case I'm doing something wrong.

Colin

unread,
Apr 16, 2015, 5:56:43 PM4/16/15
to orient-...@googlegroups.com
Try creating the Knows edge class prior to creating the actual edge.

See if that works.

-Colin

Orient Technologies

The Company behind OrientDB

ky...@ovguideinc.com

unread,
Apr 16, 2015, 6:29:03 PM4/16/15
to orient-...@googlegroups.com
Yes, if I create the class a lightweight edge is indeed created. 
But when I create the lightweight edge using gremlin it does not require creating a class.

I see you can do 
alter database custom useClassForEdgeLabel=false;
but that seems to still require creating normal edges.

I have very heterogeneous data, creating a class for each edge label would require creating hundreds of thousands of classes. A large portion of the data is going to remain static, so my plan has been to create lightweight edges for the static portions and classes for the more involved data to reduce storage, increase performance and make schema management less cluttered.

So, is there a way to create lightweight edges using sql that does not require creating classes or does that functionality require gremlin?

Colin

unread,
Apr 16, 2015, 10:54:37 PM4/16/15
to orient-...@googlegroups.com
If you use Gremlin and then check the database, is an edge class with that label's name created?

-Colin

Kyle

unread,
Apr 16, 2015, 11:20:00 PM4/16/15
to orient-...@googlegroups.com
is an edge class with that label's name created?
no. an edge class with that labels name is not created. 
------
I thought/consider the gremlin classless lightweight edge creation behavior a feature, is it actually a bug or something?

-------
If I do as I did in the first post:
1) set uselightweight edges
2) create an edge using v.addEdge using gremlin

then a lightweight edge is created that has the label set to the edge name


==>e[#9:0->#9:1][#9:0-knows->#9:1]
gremlin> e.isLightweight()
==>true
gremlin> e.map
==>{}
gremlin> e.label
==>knows
gremlin> e.getProperty("@class")
==>null

orientdb {db=testdb}> list classes


CLASSES
----------------------------------------------+------------------------------------+------------+----------------+
 NAME                                         | SUPERCLASS                         | CLUSTERS   | RECORDS        |
----------------------------------------------+------------------------------------+------------+----------------+
 E                                            |                                    | 10         |              0 |
 OFunction                                    |                                    | 6          |              0 |
 OIdentity                                    |                                    | -          |              0 |
 ORestricted                                  |                                    | -          |              0 |
 ORIDs                                        |                                    | 8          |              0 |
 ORole                                        | OIdentity                          | 4          |              3 |
 OSchedule                                    |                                    | 7          |              0 |
 OTriggered                                   |                                    | -          |              0 |
 OUser                                        | OIdentity                          | 5          |              3 |
 V                                            |                                    | 9          |              2 |
----------------------------------------------+------------------------------------+------------+----------------+
 TOTAL = 10                                                                                                    8 |
----------------------------------------------+------------------------------------+------------+----------------+
orientdb {db=testdb}> select from V

----+----+------+----+---------+--------
#   |@RID|@CLASS|myid|out_knows|in_knows
----+----+------+----+---------+--------
0   |#9:0|V     |1   |[size=1] |null
1   |#9:1|V     |2   |null     |[size=1]
----+----+------+----+---------+--------
Reply all
Reply to author
Forward
0 new messages