Search in sources :

Example 11 with OCompositeKey

use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.

the class ClassIndexManagerTest method testCollectionCompositeCreation.

public void testCollectionCompositeCreation() {
    final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
    doc.field("prop1", "test1");
    doc.field("prop2", Arrays.asList(1, 2));
    doc.save();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
    Assert.assertEquals(index.getSize(), 2);
    Assert.assertEquals(index.get(new OCompositeKey("test1", 1)), doc.getIdentity());
    Assert.assertEquals(index.get(new OCompositeKey("test1", 2)), doc.getIdentity());
    doc.delete();
    Assert.assertEquals(index.getSize(), 0);
}
Also used : OCompositeKey(com.orientechnologies.orient.core.index.OCompositeKey) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 12 with OCompositeKey

use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.

the class ClassIndexManagerTest method testCollectionCompositeUpdateCollectionWasAssigned.

public void testCollectionCompositeUpdateCollectionWasAssigned() {
    final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
    doc.field("prop1", "test1");
    doc.field("prop2", Arrays.asList(1, 2));
    doc.save();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
    Assert.assertEquals(index.getSize(), 2);
    doc.field("prop2", Arrays.asList(1, 3));
    doc.save();
    Assert.assertEquals(index.get(new OCompositeKey("test1", 1)), doc.getIdentity());
    Assert.assertEquals(index.get(new OCompositeKey("test1", 3)), doc.getIdentity());
    Assert.assertEquals(index.getSize(), 2);
    doc.delete();
    Assert.assertEquals(index.getSize(), 0);
}
Also used : OCompositeKey(com.orientechnologies.orient.core.index.OCompositeKey) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 13 with OCompositeKey

use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.

the class ClassIndexManagerTest method testCollectionCompositeUpdateSimpleField.

public void testCollectionCompositeUpdateSimpleField() {
    final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
    doc.field("prop1", "test1");
    doc.field("prop2", Arrays.asList(1, 2));
    doc.save();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
    Assert.assertEquals(index.getSize(), 2);
    doc.field("prop1", "test2");
    doc.save();
    Assert.assertEquals(index.get(new OCompositeKey("test2", 1)), doc.getIdentity());
    Assert.assertEquals(index.get(new OCompositeKey("test2", 2)), doc.getIdentity());
    Assert.assertEquals(index.getSize(), 2);
    doc.delete();
    Assert.assertEquals(index.getSize(), 0);
}
Also used : OCompositeKey(com.orientechnologies.orient.core.index.OCompositeKey) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 14 with OCompositeKey

use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.

the class ClassIndexManagerTest method testCollectionCompositeUpdateCollectionWasChanged.

public void testCollectionCompositeUpdateCollectionWasChanged() {
    final ODocument doc = new ODocument("classIndexManagerTestCompositeCollectionClass");
    doc.field("prop1", "test1");
    doc.field("prop2", Arrays.asList(1, 2));
    doc.save();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("classIndexManagerTestIndexValueAndCollection");
    Assert.assertEquals(index.getSize(), 2);
    List<Integer> docList = doc.field("prop2");
    docList.add(3);
    docList.add(4);
    docList.add(5);
    docList.remove(0);
    doc.save();
    Assert.assertEquals(index.get(new OCompositeKey("test1", 2)), doc.getIdentity());
    Assert.assertEquals(index.get(new OCompositeKey("test1", 3)), doc.getIdentity());
    Assert.assertEquals(index.get(new OCompositeKey("test1", 4)), doc.getIdentity());
    Assert.assertEquals(index.get(new OCompositeKey("test1", 5)), doc.getIdentity());
    Assert.assertEquals(index.getSize(), 4);
    doc.delete();
    Assert.assertEquals(index.getSize(), 0);
}
Also used : OCompositeKey(com.orientechnologies.orient.core.index.OCompositeKey) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 15 with OCompositeKey

use of com.orientechnologies.orient.core.index.OCompositeKey in project orientdb by orientechnologies.

the class SBTreeCompositeKeyTest method testIterateValuesMinorNonInclusivePartial.

public void testIterateValuesMinorNonInclusivePartial() {
    OSBTree.OSBTreeCursor<OCompositeKey, OIdentifiable> cursor = localSBTree.iterateEntriesMinor(compositeKey(3.0), false, true);
    Set<ORID> orids = extractRids(cursor);
    assertEquals(orids.size(), 18);
    for (int i = 1; i < 3; i++) for (int j = 1; j <= 9; j++) {
        assertTrue(orids.contains(new ORecordId(i, j)));
    }
    cursor = localSBTree.iterateEntriesMinor(compositeKey(3.0), false, false);
    orids = extractRids(cursor);
    assertEquals(orids.size(), 18);
    for (int i = 1; i < 3; i++) for (int j = 1; j <= 9; j++) {
        assertTrue(orids.contains(new ORecordId(i, j)));
    }
}
Also used : ORID(com.orientechnologies.orient.core.id.ORID) OCompositeKey(com.orientechnologies.orient.core.index.OCompositeKey) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Aggregations

OCompositeKey (com.orientechnologies.orient.core.index.OCompositeKey)40 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)22 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)11 ORecordId (com.orientechnologies.orient.core.id.ORecordId)10 ORID (com.orientechnologies.orient.core.id.ORID)8 OBinarySerializerFactory (com.orientechnologies.orient.core.serialization.serializer.binary.OBinarySerializerFactory)5 OBinarySerializer (com.orientechnologies.common.serialization.types.OBinarySerializer)4 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)4 OIndex (com.orientechnologies.orient.core.index.OIndex)3 Collection (java.util.Collection)3 Date (java.util.Date)3 List (java.util.List)3 OMultiCollectionIterator (com.orientechnologies.common.collection.OMultiCollectionIterator)2 OTransactionException (com.orientechnologies.orient.core.exception.OTransactionException)2 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)2 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)2 OType (com.orientechnologies.orient.core.metadata.schema.OType)2 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)2 OrientEdge (com.tinkerpop.blueprints.impls.orient.OrientEdge)2 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)2