Search in sources :

Example 11 with OIndexTxAwareOneValue

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

the class IndexTxAwareOneValueGetTest method testPutAfterTransaction.

@Test
public void testPutAfterTransaction() {
    database.getMetadata().getIndexManager().reload();
    database.begin();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetTest");
    Assert.assertTrue(index instanceof OIndexTxAwareOneValue);
    final int clusterId = database.getDefaultClusterId();
    index.put(1, new ORecordId(clusterId, 1));
    Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(index.get(1));
    database.commit();
    index.put(2, new ORecordId(clusterId, 2));
    Assert.assertNotNull(index.get(2));
}
Also used : OIndexTxAwareOneValue(com.orientechnologies.orient.core.index.OIndexTxAwareOneValue) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test)

Example 12 with OIndexTxAwareOneValue

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

the class IndexTxAwareOneValueGetTest method testMultiPut.

@Test
public void testMultiPut() {
    database.getMetadata().getIndexManager().reload();
    database.begin();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetTest");
    Assert.assertTrue(index instanceof OIndexTxAwareOneValue);
    final int clusterId = database.getDefaultClusterId();
    index.put(1, new ORecordId(clusterId, 1));
    index.put(1, new ORecordId(clusterId, 1));
    Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(((OIndexTxAwareOneValue) index).get(1));
    database.commit();
    Assert.assertNotNull(((OIndexTxAwareOneValue) index).get(1));
}
Also used : OIndexTxAwareOneValue(com.orientechnologies.orient.core.index.OIndexTxAwareOneValue) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test)

Example 13 with OIndexTxAwareOneValue

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

the class IndexTxAwareOneValueGetTest method testRemove.

@Test
public void testRemove() {
    database.getMetadata().getIndexManager().reload();
    database.begin();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetTest");
    Assert.assertTrue(index instanceof OIndexTxAwareOneValue);
    final int clusterId = database.getDefaultClusterId();
    index.put(1, new ORecordId(clusterId, 1));
    index.put(2, new ORecordId(clusterId, 2));
    database.commit();
    Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(index.get(1));
    Assert.assertNotNull(index.get(2));
    database.begin();
    index.remove(1);
    Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNull(index.get(1));
    Assert.assertNotNull(index.get(2));
    database.rollback();
    Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(index.get(1));
    Assert.assertNotNull(index.get(2));
}
Also used : OIndexTxAwareOneValue(com.orientechnologies.orient.core.index.OIndexTxAwareOneValue) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test)

Example 14 with OIndexTxAwareOneValue

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

the class IndexTxAwareOneValueGetTest method testClearAndPut.

@Test
public void testClearAndPut() {
    database.getMetadata().getIndexManager().reload();
    database.begin();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetTest");
    Assert.assertTrue(index instanceof OIndexTxAwareOneValue);
    final int clusterId = database.getDefaultClusterId();
    index.put(1, new ORecordId(clusterId, 1));
    index.put(2, new ORecordId(clusterId, 2));
    database.commit();
    Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(index.get(1));
    Assert.assertNotNull(index.get(2));
    database.begin();
    index.clear();
    index.put(2, new ORecordId(clusterId, 2));
    Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNull(index.get(1));
    Assert.assertNotNull(index.get(2));
    database.rollback();
    Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(index.get(1));
    Assert.assertNotNull(index.get(2));
}
Also used : OIndexTxAwareOneValue(com.orientechnologies.orient.core.index.OIndexTxAwareOneValue) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test)

Example 15 with OIndexTxAwareOneValue

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

the class IndexTxAwareOneValueGetTest method testClear.

@Test
public void testClear() {
    database.getMetadata().getIndexManager().reload();
    database.begin();
    final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetTest");
    Assert.assertTrue(index instanceof OIndexTxAwareOneValue);
    final int clusterId = database.getDefaultClusterId();
    index.put(1, new ORecordId(clusterId, 1));
    index.put(2, new ORecordId(clusterId, 2));
    database.commit();
    Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(index.get(1));
    Assert.assertNotNull(index.get(2));
    database.begin();
    index.clear();
    Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNull(index.get(1));
    Assert.assertNull(index.get(2));
    database.rollback();
    Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
    Assert.assertNotNull(index.get(1));
    Assert.assertNotNull(index.get(2));
}
Also used : OIndexTxAwareOneValue(com.orientechnologies.orient.core.index.OIndexTxAwareOneValue) ORecordId(com.orientechnologies.orient.core.id.ORecordId) Test(org.testng.annotations.Test)

Aggregations

OIndexTxAwareOneValue (com.orientechnologies.orient.core.index.OIndexTxAwareOneValue)32 ORecordId (com.orientechnologies.orient.core.id.ORecordId)30 Test (org.testng.annotations.Test)30 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)22 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)20 HashSet (java.util.HashSet)20 OIndexFactory (com.orientechnologies.orient.core.index.OIndexFactory)2 OSimpleKeyIndexDefinition (com.orientechnologies.orient.core.index.OSimpleKeyIndexDefinition)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 OCompositeKey (com.orientechnologies.orient.core.index.OCompositeKey)1 OIndex (com.orientechnologies.orient.core.index.OIndex)1 OIndexTxAwareMultiValue (com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue)1 Edge (com.tinkerpop.blueprints.Edge)1