use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class LuceneGraphTXTest method graphTxTest.
@Test
public void graphTxTest() throws Exception {
OrientGraph graph = new OrientGraph("memory:graphTx");
try {
graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
@Override
public Object call(OrientBaseGraph graph) {
OrientVertexType city = graph.createVertexType("City");
city.createProperty("name", OType.STRING);
graph.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
return null;
}
});
OrientVertex v = graph.addVertex("class:City", "name", "London");
v.save();
Collection results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'London'")).execute();
Assert.assertEquals(results.size(), 1);
v.setProperty("name", "Berlin");
v.save();
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'Berlin'")).execute();
Assert.assertEquals(results.size(), 1);
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'London'")).execute();
Assert.assertEquals(results.size(), 0);
graph.commit();
// Assert After Commit
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'Berlin'")).execute();
Assert.assertEquals(results.size(), 1);
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'London'")).execute();
Assert.assertEquals(results.size(), 0);
} finally {
graph.drop();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class LuceneIndexCreateDropTest method init.
@Before
public void init() {
OrientGraph graph = new OrientGraph(db, false);
OrientVertexType type = graph.createVertexType("City");
type.createProperty("name", OType.STRING);
db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class LuceneTransactionCompositeQueryTest method init.
@Before
public void init() {
final OrientVertexType c1 = new OrientGraphNoTx(db).createVertexType("Foo");
c1.createProperty("name", OType.STRING);
c1.createProperty("bar", OType.STRING);
c1.createIndex("Foo.bar", "FULLTEXT", null, null, "LUCENE", new String[] { "bar" });
c1.createIndex("Foo.name", "NOTUNIQUE", null, null, "SBTREE", new String[] { "name" });
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class IndexTest method testIndexEdgeComposite.
public void testIndexEdgeComposite() {
OrientGraph graphNoTx = new OrientGraph((ODatabaseDocumentTx) database.getUnderlying());
OrientVertexType vertexType = null;
if (!graphNoTx.getRawGraph().existsCluster("CustomVertex")) {
vertexType = graphNoTx.createVertexType("CustomVertex");
} else {
vertexType = graphNoTx.getVertexType("CustomVertex");
}
if (!graphNoTx.getRawGraph().existsCluster("CustomEdge")) {
OrientEdgeType edgeType = graphNoTx.createEdgeType("CustomEdge");
edgeType.createProperty("out", OType.LINK, vertexType);
edgeType.createProperty("in", OType.LINK, vertexType);
edgeType.createIndex("CustomEdge.in", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "in" });
edgeType.createIndex("CustomEdge.out", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "out" });
edgeType.createIndex("CustomEdge.compositeInOut", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "out", "in" });
}
// graphNoTx.shutdown();
OrientGraph graph = new OrientGraph((ODatabaseDocumentTx) database.getUnderlying());
Vertex inVert = null;
for (int i = 0; i < 5; ++i) {
Vertex currentVert = graph.addVertex("class:CustomVertex");
if (inVert != null) {
graph.addEdge("class:CustomEdge", currentVert, inVert, "CustomEdge");
}
inVert = currentVert;
}
graph.commit();
Iterable<Vertex> verts = graph.getVertices();
StringBuilder vertIds = new StringBuilder();
for (Vertex vert : verts) {
vertIds.append(vert.getId().toString()).append(" ");
}
System.out.println("Vertices: " + vertIds);
System.out.println();
checkIndexKeys(graph, "CustomEdge.in");
checkIndexKeys(graph, "CustomEdge.out");
checkIndexKeys(graph, "CustomEdge.compositeInOut");
}
use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.
the class PLocalCreateVerticesMultiThreadSpeedTest method init.
@Override
public void init() {
final OrientGraphNoTx graph = factory.getNoTx();
try {
if (graph.getVertexType("Client") == null) {
final OrientVertexType clientType = graph.createVertexType("Client");
final OrientVertexType.OrientVertexProperty property = clientType.createProperty("uid", OType.STRING);
property.createIndex(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX);
// CREATE ONE CLUSTER PER THREAD
for (int i = 0; i < getThreads(); ++i) {
System.out.println("Creating cluster: client_" + i + "...");
clientType.addCluster("client_" + i);
}
foundObjects = 0;
} else
foundObjects = graph.countVertices("Client");
} finally {
graph.shutdown();
}
}
Aggregations