use of com.orientechnologies.orient.core.db.record.ridbag.ORidBag in project orientdb by orientechnologies.
the class OPropertyRidBagAbstractIndexDefinitionTest method testCreateValueTwoParametersArrayParams.
public void testCreateValueTwoParametersArrayParams() {
ORidBag ridBag = new ORidBag();
ridBag.setAutoConvertToRecord(false);
ridBag.add(new ORecordId("#1:12"));
ridBag.add(new ORecordId("#1:23"));
final Object result = propertyIndex.createValue(ridBag, "25");
Assert.assertTrue(result instanceof Collection);
final Collection<?> collectionResult = (Collection<?>) result;
Assert.assertEquals(collectionResult.size(), 2);
Assert.assertTrue(collectionResult.contains(new ORecordId("#1:12")));
Assert.assertTrue(collectionResult.contains(new ORecordId("#1:23")));
}
use of com.orientechnologies.orient.core.db.record.ridbag.ORidBag in project orientdb by orientechnologies.
the class OPropertyRidBagAbstractIndexDefinitionTest method testCreateValueTwoParameters.
public void testCreateValueTwoParameters() {
ORidBag ridBag = new ORidBag();
ridBag.setAutoConvertToRecord(false);
ridBag.add(new ORecordId("#1:12"));
ridBag.add(new ORecordId("#1:23"));
final Object result = propertyIndex.createValue(Arrays.asList(ridBag, "25"));
Assert.assertTrue(result instanceof Collection);
final Collection<?> collectionResult = (Collection<?>) result;
Assert.assertEquals(collectionResult.size(), 2);
Assert.assertTrue(collectionResult.contains(new ORecordId("#1:12")));
Assert.assertTrue(collectionResult.contains(new ORecordId("#1:23")));
}
use of com.orientechnologies.orient.core.db.record.ridbag.ORidBag in project orientdb by orientechnologies.
the class OSBTreeRidBagConcurrencySingleRidBag method testConcurrency.
public void testConcurrency() throws Exception {
ODatabaseDocumentTx db = new ODatabaseDocumentTx(URL);
if (db.exists()) {
db.open("admin", "admin");
db.drop();
}
db.create();
db.declareIntent(new OIntentMassiveInsert());
ODocument document = new ODocument();
ORidBag ridBag = new ORidBag();
ridBag.setAutoConvertToRecord(false);
document.field("ridBag", ridBag);
for (int i = 0; i < 100; i++) {
final ORID ridToAdd = new ORecordId(0, positionCounter.incrementAndGet());
ridBag.add(ridToAdd);
ridTree.add(ridToAdd);
}
document.save();
docContainerRid = document.getIdentity();
List<Future<Void>> futures = new ArrayList<Future<Void>>();
for (int i = 0; i < 5; i++) futures.add(threadExecutor.submit(new RidAdder(i)));
for (int i = 0; i < 5; i++) futures.add(threadExecutor.submit(new RidDeleter(i)));
latch.countDown();
Thread.sleep(30 * 60000);
cont = false;
for (Future<Void> future : futures) future.get();
document = db.load(document.getIdentity());
document.setLazyLoad(false);
ridBag = document.field("ridBag");
for (OIdentifiable identifiable : ridBag) Assert.assertTrue(ridTree.remove(identifiable.getIdentity()));
Assert.assertTrue(ridTree.isEmpty());
System.out.println("Result size is " + ridBag.size());
db.close();
}
use of com.orientechnologies.orient.core.db.record.ridbag.ORidBag in project orientdb by orientechnologies.
the class OCompositeIndexDefinitionTest method testDocumentToIndexRidBagValueSuccessfulOne.
@Test
public void testDocumentToIndexRidBagValueSuccessfulOne() {
final ODocument document = new ODocument();
final ORidBag ridBag = new ORidBag();
ridBag.setAutoConvertToRecord(false);
ridBag.add(new ORecordId("#1:10"));
ridBag.add(new ORecordId("#1:11"));
ridBag.add(new ORecordId("#1:11"));
document.field("fOne", 12);
document.field("fTwo", ridBag);
final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass");
compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER));
compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo"));
final Object result = compositeIndexDefinition.getDocumentValueToIndex(document);
final ArrayList<OCompositeKey> expectedResult = new ArrayList<OCompositeKey>();
expectedResult.add(new OCompositeKey(12, new ORecordId("#1:10")));
expectedResult.add(new OCompositeKey(12, new ORecordId("#1:11")));
expectedResult.add(new OCompositeKey(12, new ORecordId("#1:11")));
Assert.assertEquals(result, expectedResult);
}
use of com.orientechnologies.orient.core.db.record.ridbag.ORidBag in project orientdb by orientechnologies.
the class OCompositeIndexDefinitionTest method testCreateRidBagValueSuccessfulTwo.
@Test
public void testCreateRidBagValueSuccessfulTwo() {
final OCompositeIndexDefinition compositeIndexDefinition = new OCompositeIndexDefinition("testCollectionClass");
compositeIndexDefinition.addIndex(new OPropertyRidBagIndexDefinition("testCollectionClass", "fTwo"));
compositeIndexDefinition.addIndex(new OPropertyIndexDefinition("testCollectionClass", "fOne", OType.INTEGER));
ORidBag ridBag = new ORidBag();
ridBag.setAutoConvertToRecord(false);
ridBag.add(new ORecordId("#1:10"));
ridBag.add(new ORecordId("#1:11"));
ridBag.add(new ORecordId("#1:11"));
final Object result = compositeIndexDefinition.createValue(Arrays.asList(ridBag, 12));
final ArrayList<OCompositeKey> expectedResult = new ArrayList<OCompositeKey>();
expectedResult.add(new OCompositeKey(new ORecordId("#1:10"), 12));
expectedResult.add(new OCompositeKey(new ORecordId("#1:11"), 12));
expectedResult.add(new OCompositeKey(new ORecordId("#1:11"), 12));
Assert.assertEquals(result, expectedResult);
}
Aggregations