use of com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue in project orientdb by orientechnologies.
the class IndexTxAwareMultiValueGetEntriesTest method testPut.
@Test
public void testPut() {
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareMultiValueGetEntriesTest");
Assert.assertTrue(index instanceof OIndexTxAwareMultiValue);
final int clusterId = database.getDefaultClusterId();
final List<Long> positions = getValidPositions(clusterId);
index.put(1, new ORecordId(clusterId, positions.get(0)));
index.put(1, new ORecordId(clusterId, positions.get(1)));
index.put(2, new ORecordId(clusterId, positions.get(2)));
database.commit();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
Set<OIdentifiable> resultOne = new HashSet<OIdentifiable>();
OIndexCursor cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultOne);
Assert.assertEquals(resultOne.size(), 3);
database.begin();
index.put(2, new ORecordId(clusterId, positions.get(3)));
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
Set<OIdentifiable> resultTwo = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultTwo);
Assert.assertEquals(resultTwo.size(), 4);
database.rollback();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
Set<OIdentifiable> resultThree = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultThree);
Assert.assertEquals(resultThree.size(), 3);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue in project orientdb by orientechnologies.
the class IndexTxAwareMultiValueGetEntriesTest method testRemoveOne.
@Test
public void testRemoveOne() {
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareMultiValueGetEntriesTest");
Assert.assertTrue(index instanceof OIndexTxAwareMultiValue);
final int clusterId = database.getDefaultClusterId();
final List<Long> positions = getValidPositions(clusterId);
final ORecordId firstRecordId = new ORecordId(clusterId, positions.get(0));
index.put(1, firstRecordId);
index.put(1, new ORecordId(clusterId, positions.get(1)));
index.put(2, new ORecordId(clusterId, positions.get(2)));
database.commit();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
Set<OIdentifiable> resultOne = new HashSet<OIdentifiable>();
OIndexCursor cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultOne);
Assert.assertEquals(resultOne.size(), 3);
database.begin();
index.remove(1, firstRecordId);
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
Set<OIdentifiable> resultTwo = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultTwo);
Assert.assertEquals(resultTwo.size(), 2);
database.rollback();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
Set<OIdentifiable> resultThree = new HashSet<OIdentifiable>();
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultThree);
Assert.assertEquals(resultThree.size(), 3);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue in project orientdb by orientechnologies.
the class IndexTxAwareMultiValueGetEntriesTest method testClear.
@Test
public void testClear() {
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareMultiValueGetEntriesTest");
Assert.assertTrue(index instanceof OIndexTxAwareMultiValue);
final int clusterId = database.getDefaultClusterId();
final List<Long> positions = getValidPositions(clusterId);
index.put(1, new ORecordId(clusterId, positions.get(0)));
index.put(1, new ORecordId(clusterId, positions.get(1)));
index.put(2, new ORecordId(clusterId, positions.get(2)));
database.commit();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
Set<OIdentifiable> resultOne = new HashSet<OIdentifiable>();
OIndexCursor cursor = index.iterateEntries(Arrays.asList(1, 2), true);
cursorToSet(cursor, resultOne);
Assert.assertEquals(resultOne.size(), 3);
database.begin();
index.clear();
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetEntriesTest"));
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("idxTxAwareMultiValueGetEntriesTest"));
cursor = index.iterateEntries(Arrays.asList(1, 2), true);
Set<OIdentifiable> resultThree = new HashSet<OIdentifiable>();
cursorToSet(cursor, resultThree);
Assert.assertEquals(resultThree.size(), 3);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue in project orientdb by orientechnologies.
the class IndexTxAwareMultiValueGetTest method testMultiPut.
@Test
public void testMultiPut() {
database.getMetadata().getIndexManager().reload();
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareMultiValueGetTest");
Assert.assertTrue(index instanceof OIndexTxAwareMultiValue);
final int clusterId = database.getDefaultClusterId();
index.put(1, new ORecordId(clusterId, 1));
index.put(1, new ORecordId(clusterId, 1));
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetTest"));
Assert.assertEquals(((OIndexTxAwareMultiValue) index).get(1).size(), 1);
database.commit();
Assert.assertEquals(((OIndexTxAwareMultiValue) index).get(1).size(), 1);
}
use of com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue in project orientdb by orientechnologies.
the class IndexTxAwareMultiValueGetTest method testClearAndPut.
@Test
public void testClearAndPut() {
database.getMetadata().getIndexManager().reload();
database.begin();
final OIndex<?> index = database.getMetadata().getIndexManager().getIndex("idxTxAwareMultiValueGetTest");
Assert.assertTrue(index instanceof OIndexTxAwareMultiValue);
final int clusterId = database.getDefaultClusterId();
final List<Long> positions = getValidPositions(clusterId);
index.put(1, new ORecordId(clusterId, positions.get(0)));
index.put(1, new ORecordId(clusterId, positions.get(1)));
index.put(2, new ORecordId(clusterId, positions.get(2)));
database.commit();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetTest"));
Assert.assertEquals(((OIndexTxAwareMultiValue) index).get(1).size(), 2);
Assert.assertEquals(((OIndexTxAwareMultiValue) index).get(2).size(), 1);
database.begin();
index.clear();
index.put(2, new ORecordId(clusterId, 3));
Assert.assertNotNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetTest"));
Assert.assertNull(index.get(1));
Assert.assertEquals(((OIndexTxAwareMultiValue) index).get(2).size(), 1);
database.rollback();
Assert.assertNull(database.getTransaction().getIndexChanges("idxTxAwareMultiValueGetTest"));
Assert.assertEquals(((OIndexTxAwareMultiValue) index).get(1).size(), 2);
Assert.assertEquals(((OIndexTxAwareMultiValue) index).get(2).size(), 1);
}
Aggregations