Search in sources :

Example 56 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class OSBTreeBonsaiLocalTest method testValuesBetween.

public void testValuesBetween() {
    NavigableMap<Integer, ORID> keyValues = new TreeMap<Integer, ORID>();
    Random random = new Random();
    while (keyValues.size() < KEYS_COUNT) {
        int key = random.nextInt(Integer.MAX_VALUE);
        sbTree.put(key, new ORecordId(key % 32000, key));
        keyValues.put(key, new ORecordId(key % 32000, key));
    }
    assertBetweenValues(keyValues, random, true, true);
    assertBetweenValues(keyValues, random, true, false);
    assertBetweenValues(keyValues, random, false, true);
    assertBetweenValues(keyValues, random, false, false);
    Assert.assertEquals(sbTree.firstKey(), keyValues.firstKey());
    Assert.assertEquals(sbTree.lastKey(), keyValues.lastKey());
}
Also used : ORID(com.orientechnologies.orient.core.id.ORID) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Example 57 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class OSBTreeBonsaiLocalTest method testKeyPut.

public void testKeyPut() throws Exception {
    for (int i = 0; i < KEYS_COUNT; i++) {
        sbTree.put(i, new ORecordId(i % 32000, i));
    }
    for (int i = 0; i < KEYS_COUNT; i++) Assert.assertEquals(sbTree.get(i), new ORecordId(i % 32000, i), i + " key is absent");
    Assert.assertEquals(0, (int) sbTree.firstKey());
    Assert.assertEquals(KEYS_COUNT - 1, (int) sbTree.lastKey());
    for (int i = KEYS_COUNT; i < 2 * KEYS_COUNT; i++) Assert.assertNull(sbTree.get(i));
}
Also used : ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Example 58 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class OSBTreeBonsaiLocalTest method testKeyPutRandomUniform.

public void testKeyPutRandomUniform() throws Exception {
    final NavigableSet<Integer> keys = new TreeSet<Integer>();
    final Random random = new Random();
    while (keys.size() < KEYS_COUNT) {
        int key = random.nextInt(Integer.MAX_VALUE);
        sbTree.put(key, new ORecordId(key % 32000, key));
        keys.add(key);
        Assert.assertEquals(sbTree.get(key), new ORecordId(key % 32000, key));
    }
    Assert.assertEquals(sbTree.firstKey(), keys.first());
    Assert.assertEquals(sbTree.lastKey(), keys.last());
    for (int key : keys) Assert.assertEquals(sbTree.get(key), new ORecordId(key % 32000, key));
}
Also used : ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Example 59 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class OSBTreeBonsaiLocalTest method testKeyPutRandomGaussian.

public void testKeyPutRandomGaussian() throws Exception {
    final double mx = Integer.MAX_VALUE / 2.;
    final double dx = Integer.MAX_VALUE / 8.;
    NavigableSet<Integer> keys = new TreeSet<Integer>();
    long seed = System.currentTimeMillis();
    System.out.println("testKeyPutRandomGaussian seed : " + seed);
    Random random = new Random(seed);
    while (keys.size() < KEYS_COUNT) {
        int key = generateGaussianKey(mx, dx, random);
        sbTree.put(key, new ORecordId(key % 32000, key));
        keys.add(key);
        Assert.assertEquals(sbTree.get(key), new ORecordId(key % 32000, key));
    }
    Assert.assertEquals(sbTree.firstKey(), keys.first());
    Assert.assertEquals(sbTree.lastKey(), keys.last());
    for (int key : keys) Assert.assertEquals(sbTree.get(key), new ORecordId(key % 32000, key));
}
Also used : ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Example 60 with ORecordId

use of com.orientechnologies.orient.core.id.ORecordId in project orientdb by orientechnologies.

the class OSBTreeBonsaiLocalTest method testValuesMajor.

public void testValuesMajor() {
    NavigableMap<Integer, ORID> keyValues = new TreeMap<Integer, ORID>();
    Random random = new Random();
    while (keyValues.size() < KEYS_COUNT) {
        int key = random.nextInt(Integer.MAX_VALUE);
        sbTree.put(key, new ORecordId(key % 32000, key));
        keyValues.put(key, new ORecordId(key % 32000, key));
    }
    assertMajorValues(keyValues, random, true);
    assertMajorValues(keyValues, random, false);
    Assert.assertEquals(sbTree.firstKey(), keyValues.firstKey());
    Assert.assertEquals(sbTree.lastKey(), keyValues.lastKey());
}
Also used : ORID(com.orientechnologies.orient.core.id.ORID) ORecordId(com.orientechnologies.orient.core.id.ORecordId)

Aggregations

ORecordId (com.orientechnologies.orient.core.id.ORecordId)431 Test (org.testng.annotations.Test)153 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)139 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)120 ORID (com.orientechnologies.orient.core.id.ORID)71 HashSet (java.util.HashSet)63 OIndexCursor (com.orientechnologies.orient.core.index.OIndexCursor)42 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)37 ORecord (com.orientechnologies.orient.core.record.ORecord)37 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)34 OIndexTxAwareMultiValue (com.orientechnologies.orient.core.index.OIndexTxAwareMultiValue)30 OIndexTxAwareOneValue (com.orientechnologies.orient.core.index.OIndexTxAwareOneValue)30 HashMap (java.util.HashMap)29 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)28 IOException (java.io.IOException)25 Child (com.orientechnologies.orient.test.domain.business.Child)24 OException (com.orientechnologies.common.exception.OException)23 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)23 Map (java.util.Map)22 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)21