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());
}
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));
}
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));
}
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));
}
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());
}
Aggregations