Hi, I am new to orientdb. So far I could not figure out how to make unique
indices work. This is the test code:
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.*;
public class OrientDBTest {
public static void main(String[] args) {
OrientGraph graph = new
OrientGraph("memory:test");//"plocal:c:/tmp/orientdb"
OrientVertexType person = graph.createVertexType("Person");
person.createProperty("name", OType.STRING);
person.createProperty("age", OType.INTEGER);
person.createIndex("nameIdx", OClass.INDEX_TYPE.UNIQUE, "name");
graph.commit();
long t = System.currentTimeMillis();
for (int i=0;i<10000;i++) {
OrientVertex v1 = graph.addVertex("class:Person");
Map<String,Object> props = new HashMap<String,Object>();
props.put("name", "Jill");
props.put("age", 33);
v1.setProperties(props);
if (i%1000==0)
graph.commit();
}
graph.commit();
System.out.println("Time: "+(System.currentTimeMillis()-t));
Iterator<Vertex> it = graph.getVerticesOfClass("Person").iterator();
System.out.println(it.next().getProperty("name") + " "
+it.next().getProperty("name"));
}
}
Which generates 10000 records with name 'Jill' even though there is a
unique index on name. Why does this not fail? Is there anything else I need
to set?
Thanks
Timm
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.