/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
String DB_NAME = "WonderLand";
OrientGraph graph = Service.getOrCreateGraphInstance(DB_NAME);
OrientVertexType ovt = graph.createVertexType("Person");
OrientVertexType ovt1 = graph.createVertexType("Relation");
graph.createKeyIndex("uid", Vertex.class, new Parameter("type", "UNIQUE"));
OrientVertex v = graph.addVertex("class:Person");
v.setProperties("uid", "ram");
v.setProperties("event", "Login");
Iterable<Vertex> it = graph.getVertices("Person", new String[]{"uid"}, new String[]{"ram"});
System.out.println("vertex Person->> " + it.iterator().next());
Iterable<Vertex> it2 = graph.getVertices("Relation", new String[]{"uid"}, new String[]{"ram"});
System.out.println("vertex Relation->> " + it2.iterator().next());
}
}
Result :
with Indexing :
Oct 12, 2016 7:40:41 PM com.orientechnologies.common.log.OLogManager log
WARNING: Requested command 'create vertex type 'Person' as subclass of 'V'' must be executed outside active transaction: the transaction will be committed and reopen right after it. To avoid this behavior execute it outside a transaction
Oct 12, 2016 7:40:42 PM com.orientechnologies.common.log.OLogManager log
WARNING: Requested command 'create vertex type 'Relation' as subclass of 'V'' must be executed outside active transaction: the transaction will be committed and reopen right after it. To avoid this behavior execute it outside a transaction
Oct 12, 2016 7:40:42 PM com.orientechnologies.common.log.OLogManager log
WARNING: Requested command 'create key index on 'Vertex.uid'' must be executed outside active transaction: the transaction will be committed and reopen right after it. To avoid this behavior execute it outside a transaction
vertex Person->> v(Person)[#-1:-2]
vertex Relation->> v(Person)[#-1:-2]
without Indexing :
Graph executed successfully Person
vertex Person->> v(Person)[#-1:-2]
Exception in thread "main" java.util.NoSuchElementException
at com.tinkerpop.blueprints.util.DefaultGraphQuery$DefaultGraphQueryIterable$1.next(DefaultGraphQuery.java:108)
at com.tinkerpop.blueprints.util.DefaultGraphQuery$DefaultGraphQueryIterable$1.next(DefaultGraphQuery.java:86)
at pcp.spark.playground.App.main(App.java:41)
with Indexing :
Oct 12, 2016 7:40:41 PM com.orientechnologies.common.log.OLogManager log
WARNING: Requested command 'create vertex type 'Person' as subclass of 'V'' must be executed outside active transaction: the transaction will be committed and reopen right after it. To avoid this behavior execute it outside a transaction
Oct 12, 2016 7:40:42 PM com.orientechnologies.common.log.OLogManager log
WARNING: Requested command 'create vertex type 'Relation' as subclass of 'V'' must be executed outside active transaction: the transaction will be committed and reopen right after it. To avoid this behavior execute it outside a transaction
Oct 12, 2016 7:40:42 PM com.orientechnologies.common.log.OLogManager log
WARNING: Requested command 'create key index on 'Vertex.uid'' must be executed outside active transaction: the transaction will be committed and reopen right after it. To avoid this behavior execute it outside a transaction
vertex Person->> v(Person)[#-1:-2]
vertex Relation->> v(Person)[#-1:-2]
without Indexing :
Graph executed successfully Person
vertex Person->> v(Person)[#-1:-2]
Exception in thread "main" java.util.NoSuchElementException
at com.tinkerpop.blueprints.util.DefaultGraphQuery$DefaultGraphQueryIterable$1.next(DefaultGraphQuery.java:108)
at com.tinkerpop.blueprints.util.DefaultGraphQuery$DefaultGraphQueryIterable$1.next(DefaultGraphQuery.java:86)
at pcp.spark.playground.App.main(App.java:41)
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.