use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.
the class DistributedDatabaseCRUDTest method createVertexTypeWithUniqueIndex.
/**
* Create vertex and edge type with non unique index.
*
* @param orientGraph
* @param className
*/
public void createVertexTypeWithUniqueIndex(OrientBaseGraph orientGraph, String className, String property, String keyIndexProperty) {
String edgeClassName = className;
String vertexClassName = className + "Node";
OClass clazz = orientGraph.getEdgeType(edgeClassName);
if (clazz == null) {
log("Creating edge type - " + edgeClassName);
orientGraph.createEdgeType(edgeClassName);
} else {
log("Edge " + edgeClassName + " already exists");
}
clazz = orientGraph.getVertexType(vertexClassName);
if (clazz == null) {
log("Creating vertex type - " + vertexClassName);
clazz = orientGraph.createVertexType(vertexClassName);
clazz.createProperty(property, OType.STRING);
clazz.createProperty(keyIndexProperty, OType.STRING);
orientGraph.createKeyIndex(keyIndexProperty, Vertex.class, new Parameter("class", vertexClassName), new Parameter("type", "UNIQUE"));
clazz.createIndex(vertexClassName + "_Index_" + property, INDEX_TYPE.UNIQUE, property);
} else {
log("Class " + vertexClassName + " already exists");
}
}
use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.
the class GraphEmbeddedTest method testGetVericesFilterClass.
@Test
public void testGetVericesFilterClass() {
graph.createVertexType("One");
graph.createVertexType("Two");
graph.createKeyIndex("name", Vertex.class, new Parameter("type", "NOTUNIQUE"));
graph.getRawGraph().begin();
graph.addVertex("class:One", new Object[] { "name", "Same" });
graph.addVertex("class:Two", new Object[] { "name", "Same" });
graph.commit();
Iterable<Vertex> vertexes = graph.getVertices("One", new String[] { "name" }, new Object[] { "Same" });
int size = 0;
for (Vertex v : vertexes) {
size++;
Assert.assertNotNull(v);
}
Assert.assertEquals(1, size);
}
use of com.tinkerpop.blueprints.Parameter in project blueprints by tinkerpop.
the class Neo4jBatchGraphTest method testIndexParameters.
public void testIndexParameters() throws Exception {
final String directory = this.getWorkingDirectory();
final Neo4jBatchGraph batch = new Neo4jBatchGraph(directory);
Index<Vertex> index = batch.createIndex("testIdx", Vertex.class, new Parameter("analyzer", LowerCaseKeywordAnalyzer.class.getName()));
Vertex a = batch.addVertex(null);
a.setProperty("name", "marko");
index.put("name", "marko", a);
batch.flushIndices();
batch.shutdown();
// native neo4j graph load
IndexableGraph graph = new Neo4jGraph(directory);
Iterator<Vertex> itty = graph.getIndex("testIdx", Vertex.class).query("name", "*rko").iterator();
int counter = 0;
while (itty.hasNext()) {
counter++;
assertEquals(itty.next().getProperty("name"), "marko");
}
assertEquals(counter, 1);
itty = graph.getIndex("testIdx", Vertex.class).query("name", "MaRkO").iterator();
counter = 0;
while (itty.hasNext()) {
counter++;
assertEquals(itty.next().getProperty("name"), "marko");
}
assertEquals(counter, 1);
graph.shutdown();
}
use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.
the class DistributedConfigReloadTest method createVertexType.
public void createVertexType(OrientBaseGraph orientGraph, String className, String property, String keyIndexProperty) {
String edgeClassName = className;
String vertexClassName = className + "Node";
OClass clazz = orientGraph.getEdgeType(edgeClassName);
if (clazz == null) {
log("Creating edge type - " + edgeClassName);
clazz = orientGraph.createEdgeType(edgeClassName);
clazz.createProperty("linkKey", OType.STRING);
orientGraph.createKeyIndex("linkKey", Edge.class, new Parameter("class", edgeClassName), new Parameter("type", "UNIQUE"));
} else {
log("Edge " + edgeClassName + " already exists");
}
clazz = orientGraph.getVertexType(vertexClassName);
if (clazz == null) {
log("Creating vertex type - " + vertexClassName);
clazz = orientGraph.createVertexType(vertexClassName);
clazz.createProperty(property, OType.STRING);
clazz.createProperty(keyIndexProperty, OType.STRING);
orientGraph.createKeyIndex(keyIndexProperty, Vertex.class, new Parameter("class", vertexClassName), new Parameter("type", "UNIQUE"));
clazz.createIndex(vertexClassName + "_Index_" + property, INDEX_TYPE.UNIQUE, property);
} else {
log("Class " + vertexClassName + " already exists");
}
}
use of com.tinkerpop.blueprints.Parameter in project orientdb by orientechnologies.
the class DistributedDatabaseCRUDTest method createVertexType.
// ----------------------------------------------------------------------------------------------------------------
// ---------------------------- End Database Methods -----------------------------------------------------------
// ----------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// ----------------------- Utility Methods ------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
/**
* Create vertex and edge type with non unique index.
*
* @param orientGraph
* @param className
*/
public void createVertexType(OrientBaseGraph orientGraph, String className, String property, String keyIndexProperty) {
String edgeClassName = className;
String vertexClassName = className + "Node";
OClass clazz = orientGraph.getEdgeType(edgeClassName);
if (clazz == null) {
log("Creating edge type - " + edgeClassName);
orientGraph.createEdgeType(edgeClassName);
} else {
log("Edge " + edgeClassName + " already exists");
}
clazz = orientGraph.getVertexType(vertexClassName);
if (clazz == null) {
log("Creating vertex type - " + vertexClassName);
clazz = orientGraph.createVertexType(vertexClassName);
clazz.createProperty(property, OType.STRING);
clazz.createProperty(keyIndexProperty, OType.STRING);
orientGraph.createKeyIndex(keyIndexProperty, Vertex.class, new Parameter("class", vertexClassName));
clazz.createIndex(vertexClassName + "_Index_" + property, INDEX_TYPE.NOTUNIQUE, property);
} else {
log("Class " + vertexClassName + " already exists");
}
}
Aggregations