Search in sources :

Example 11 with LongList

use of io.questdb.std.LongList in project questdb by bluestreak01.

the class IntervalUtilsTest method testIntersectInplace.

@Test
public void testIntersectInplace() {
    LongList intervals = new LongList();
    // A
    add(intervals, -1, 10);
    // B
    add(intervals, 1, 2);
    add(intervals, 3, 4);
    runTestIntersectInplace(intervals, 2, "[1,4]");
}
Also used : LongList(io.questdb.std.LongList) Test(org.junit.Test)

Example 12 with LongList

use of io.questdb.std.LongList in project questdb by bluestreak01.

the class IntervalUtilsTest method testLastAContainsWhoelBUnionAllAfterB.

@Test
public void testLastAContainsWhoelBUnionAllAfterB() {
    LongList intervals = new LongList();
    // A
    add(intervals, 1, 2);
    add(intervals, 3, 4);
    add(intervals, 50, 250);
    // B
    add(intervals, 100, 101);
    add(intervals, 200, 201);
    add(intervals, 205, 206);
    runTestUnionInplace(intervals, 6, "[1,2], [3,4], [50,250]");
}
Also used : LongList(io.questdb.std.LongList) Test(org.junit.Test)

Example 13 with LongList

use of io.questdb.std.LongList in project questdb by bluestreak01.

the class IntervalUtilsTest method testIsInListWithOneInterval.

@Test
public void testIsInListWithOneInterval() {
    LongList intervals = new LongList();
    add(intervals, 100, 102);
    Assert.assertFalse(IntervalUtils.isInIntervals(intervals, 99));
    Assert.assertTrue(IntervalUtils.isInIntervals(intervals, 100));
    Assert.assertTrue(IntervalUtils.isInIntervals(intervals, 101));
    Assert.assertTrue(IntervalUtils.isInIntervals(intervals, 102));
    Assert.assertFalse(IntervalUtils.isInIntervals(intervals, 103));
}
Also used : LongList(io.questdb.std.LongList) Test(org.junit.Test)

Example 14 with LongList

use of io.questdb.std.LongList in project questdb by bluestreak01.

the class IntervalUtilsTest method runTestInvertInplace.

private void runTestInvertInplace(LongList intervals, int divider, String expected) {
    LongList toInvertExtracted = new LongList(intervals);
    IntervalUtils.invert(intervals, divider);
    TestUtils.assertEquals(expected, toIntervalString(intervals, divider));
    LongList copy1 = new LongList(toInvertExtracted);
    IntervalUtils.invert(copy1, divider);
    TestUtils.assertEquals(expected, toIntervalString(copy1, divider));
    // Double invert must be same as in the beginning
    IntervalUtils.invert(copy1, divider);
    TestUtils.assertEquals(toIntervalString(toInvertExtracted, divider), toIntervalString(copy1, divider));
}
Also used : LongList(io.questdb.std.LongList)

Example 15 with LongList

use of io.questdb.std.LongList in project questdb by bluestreak01.

the class IntervalUtilsTest method testIsInEmptyIntervalList.

@Test
public void testIsInEmptyIntervalList() {
    LongList intervals = new LongList();
    Assert.assertFalse(IntervalUtils.isInIntervals(intervals, 123));
}
Also used : LongList(io.questdb.std.LongList) Test(org.junit.Test)

Aggregations

LongList (io.questdb.std.LongList)30 Test (org.junit.Test)25 LongTreeSet (io.questdb.griffin.engine.table.LongTreeSet)3 Rnd (io.questdb.std.Rnd)2 CyclicBarrier (java.util.concurrent.CyclicBarrier)2 GriffinParserTestUtils.intervalToString (io.questdb.griffin.GriffinParserTestUtils.intervalToString)1 SOCountDownLatch (io.questdb.mp.SOCountDownLatch)1 ObjList (io.questdb.std.ObjList)1 Random (java.util.Random)1 BrokenBarrierException (java.util.concurrent.BrokenBarrierException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1