use of io.questdb.std.LongList in project questdb by bluestreak01.
the class LongTreeSetTest method doTestSimple.
private void doTestSimple(LongTreeSet set) {
Rnd rnd = new Rnd();
LongList ll = new LongList();
int n = 10000;
for (int i = 0; i < n; i++) {
long l = rnd.nextLong();
set.put(l);
ll.add(l);
}
ll.sort();
int i = 0;
LongTreeSet.TreeCursor cursor = set.getCursor();
while (cursor.hasNext()) {
long l = cursor.next();
Assert.assertEquals(ll.getQuick(i++), l);
}
Assert.assertEquals(n, i);
cursor.toTop();
i = 0;
while (cursor.hasNext()) {
long l = cursor.next();
Assert.assertEquals(ll.getQuick(i++), l);
}
}
use of io.questdb.std.LongList in project questdb by bluestreak01.
the class CairoEngineTest method testNextTableId.
@Test
public void testNextTableId() {
try (CairoEngine engine = new CairoEngine(configuration);
CairoEngine engineB = new CairoEngine(configuration)) {
final LongList listA = new LongList();
final LongList listB = new LongList();
final CyclicBarrier startBarrier = new CyclicBarrier(2);
final SOCountDownLatch haltLatch = new SOCountDownLatch();
haltLatch.setCount(1);
final AtomicInteger errors = new AtomicInteger();
new Thread(() -> {
try {
startBarrier.await();
for (int i = 0; i < 100; i++) {
listA.add(engine.getNextTableId());
}
haltLatch.countDown();
} catch (InterruptedException | BrokenBarrierException e) {
e.printStackTrace();
errors.incrementAndGet();
}
}).start();
try {
startBarrier.await();
for (int i = 0; i < 100; i++) {
listB.add(engineB.getNextTableId());
}
} catch (InterruptedException | BrokenBarrierException e) {
e.printStackTrace();
errors.incrementAndGet();
}
haltLatch.await();
try (LongTreeSet set = new LongTreeSet(4 * 2048, Integer.MAX_VALUE)) {
// add both arrays to the set and asset that there are no duplicates
for (int i = 0, n = listA.size(); i < n; i++) {
Assert.assertTrue(set.put(listA.getQuick(i)));
}
for (int i = 0, n = listB.size(); i < n; i++) {
Assert.assertTrue(set.put(listB.getQuick(i)));
}
}
}
}
use of io.questdb.std.LongList in project questdb by bluestreak01.
the class IntrinsicModelTest method assertShortInterval.
private static void assertShortInterval(String expected, String interval) throws SqlException {
LongList out = new LongList();
IntervalUtils.parseIntervalEx(interval, 0, interval.length(), 0, out, IntervalOperation.INTERSECT);
IntervalUtils.applyLastEncodedIntervalEx(out);
TestUtils.assertEquals(expected, intervalToString(out));
}
use of io.questdb.std.LongList in project questdb by bluestreak01.
the class IntrinsicModelTest method testInvert.
@Test
public void testInvert() throws SqlException {
final String intervalStr = "2018-01-10T10:30:00.000Z;30m;2d;2";
LongList out = new LongList();
IntervalUtils.parseIntervalEx(intervalStr, 0, intervalStr.length(), 0, out, IntervalOperation.INTERSECT);
IntervalUtils.applyLastEncodedIntervalEx(out);
IntervalUtils.invert(out);
TestUtils.assertEquals("[{lo=, hi=2018-01-10T10:29:59.999999Z},{lo=2018-01-10T11:00:00.000001Z, hi=2018-01-12T10:29:59.999999Z},{lo=2018-01-12T11:00:00.000001Z, hi=294247-01-10T04:00:54.775807Z}]", intervalToString(out));
}
use of io.questdb.std.LongList in project questdb by bluestreak01.
the class IntervalUtilsTest method testIsInListWithEvenNumberOfIntervals.
@Test
public void testIsInListWithEvenNumberOfIntervals() {
LongList intervals = new LongList();
add(intervals, 100, 102);
add(intervals, 122, 124);
Assert.assertFalse(IntervalUtils.isInIntervals(intervals, 99));
Assert.assertTrue(IntervalUtils.isInIntervals(intervals, 101));
Assert.assertFalse(IntervalUtils.isInIntervals(intervals, 103));
Assert.assertTrue(IntervalUtils.isInIntervals(intervals, 123));
Assert.assertFalse(IntervalUtils.isInIntervals(intervals, 125));
}
Aggregations