use of com.orientechnologies.orient.core.index.OIndexTxAwareOneValue in project orientdb by orientechnologies.
the class IndexTxAwareOneValueGetEntriesTest method testPut.
@Test
public void testPut() {
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetEntriesTest");
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("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultOne = new HashSet<OIdentifiable>();
OIndexCursor cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultOne);
Assert.assertEquals(resultOne.size(), 2);
database.begin();
index.put(3, new ORecordId(clusterId, 3));
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultTwo = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2, 3), true);
cursorToSet(cursor, resultTwo);
Assert.assertEquals(resultTwo.size(), 3);
database.rollback();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultThree = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultThree);
Assert.assertEquals(resultThree.size(), 2);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareOneValue in project orientdb by orientechnologies.
the class IndexTxAwareOneValueGetEntriesTest method testPutAfterRemove.
@Test
public void testPutAfterRemove() {
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetEntriesTest");
Assert.assertTrue(index instanceof OIndexTxAwareOneValue);
final int clusterId = database.getDefaultClusterId();
index.put(1, new ORecordId(clusterId, 1));
index.put(2, new ORecordId(clusterId, 2));
index.remove(1, new ORecordId(clusterId, 1));
index.put(1, new ORecordId(clusterId, 1));
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> result = new HashSet<OIdentifiable>();
OIndexCursor cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, result);
Assert.assertEquals(result.size(), 2);
database.commit();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, result);
Assert.assertEquals(result.size(), 2);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareOneValue in project orientdb by orientechnologies.
the class IndexTxAwareOneValueGetEntriesTest method testClear.
@Test
public void testClear() {
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetEntriesTest");
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("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultOne = new HashSet<OIdentifiable>();
OIndexCursor cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultOne);
Assert.assertEquals(resultOne.size(), 2);
database.begin();
index.clear();
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultTwo = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultTwo);
Assert.assertEquals(resultTwo.size(), 0);
database.rollback();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultThree = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultThree);
Assert.assertEquals(resultThree.size(), 2);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareOneValue in project orientdb by orientechnologies.
the class IndexTxAwareOneValueGetEntriesTest method testRemove.
@Test
public void testRemove() {
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareOneValueGetEntriesTest");
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("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultOne = new HashSet<OIdentifiable>();
OIndexCursor cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultOne);
Assert.assertEquals(resultOne.size(), 2);
database.begin();
index.remove(1);
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultTwo = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultTwo);
Assert.assertEquals(resultTwo.size(), 1);
database.rollback();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetEntriesTest"));
Set<OIdentifiable> resultThree = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultThree);
Assert.assertEquals(resultThree.size(), 2);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareOneValue in project orientdb by orientechnologies.
the class IndexTxAwareOneValueGetTest method testRemoveAllWithinTransaction.
@Test
public void testRemoveAllWithinTransaction() {
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.remove(1);
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareOneValueGetTest"));
Assert.assertNull(index.get(1));
database.commit();
Assert.assertNull(index.get(1));
}
Aggregations