Search in sources :

Example 1 with LongList

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

the class IntervalCompilerTest method assertShortInterval.

private static void assertShortInterval(String expected, String interval) throws ParserException {
    LongList out = new LongList();
    IntervalCompiler.parseIntervalEx(interval, 0, interval.length(), 0, out);
    TestUtils.assertEquals(expected, intervalToString(out));
}
Also used : LongList(com.questdb.std.LongList)

Example 2 with LongList

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

the class KvIndexTest method assertValues.

private void assertValues(long[][] values, KVIndex index) {
    for (int i = 0; i < values.length; i++) {
        LongList array = index.getValues(i);
        Assert.assertEquals(values[i].length, array.size());
        for (int k = 0; k < values[i].length; k++) {
            Assert.assertEquals(values[i][k], array.get(k));
        }
        IndexCursor cursor = index.cursor(i);
        int k = (int) cursor.size();
        while (cursor.hasNext()) {
            Assert.assertEquals(values[i][--k], cursor.next());
        }
        IndexCursor c = index.fwdCursor(i);
        int n = 0;
        while (c.hasNext()) {
            long l = c.next();
            Assert.assertEquals(values[i][n++], l);
        }
    }
}
Also used : LongList(com.questdb.std.LongList)

Example 3 with LongList

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

the class RecordChainTest method testPseudoRandomAccess.

@Test
public void testPseudoRandomAccess() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        int N = 10000;
        try (RecordChain chain = new RecordChain(metadata, SIZE_4M)) {
            Record record = new TestRecord();
            LongList rows = new LongList();
            long o = -1L;
            for (int i = 0; i < N; i++) {
                o = chain.putRecord(record, o);
                rows.add(o);
            }
            Assert.assertEquals(N, rows.size());
            Record expected = new TestRecord();
            for (int i = 0, n = rows.size(); i < n; i++) {
                long row = rows.getQuick(i);
                Record actual = chain.recordAt(row);
                Assert.assertEquals(row, actual.getRowId());
                assertSame(expected, actual);
            }
            Record expected2 = new TestRecord();
            Record rec2 = chain.newRecord();
            for (int i = 0, n = rows.size(); i < n; i++) {
                long row = rows.getQuick(i);
                chain.recordAt(rec2, row);
                Assert.assertEquals(row, rec2.getRowId());
                assertSame(expected2, rec2);
            }
            Record expected3 = new TestRecord();
            Record rec3 = chain.getRecord();
            for (int i = 0, n = rows.size(); i < n; i++) {
                long row = rows.getQuick(i);
                chain.recordAt(rec3, row);
                Assert.assertEquals(row, rec3.getRowId());
                assertSame(expected3, rec3);
            }
        }
    });
}
Also used : Record(com.questdb.common.Record) LongList(com.questdb.std.LongList) Test(org.junit.Test)

Example 4 with LongList

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

the class IntervalCompilerTest method testInvert.

@Test
public void testInvert() throws ParserException {
    final String intervalStr = "2018-01-10T10:30:00.000Z;30m;2d;2";
    LongList out = new LongList();
    IntervalCompiler.parseIntervalEx(intervalStr, 0, intervalStr.length(), 0, out);
    IntervalCompiler.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));
}
Also used : GriffinParserTestUtils.intervalToString(com.questdb.griffin.lexer.GriffinParserTestUtils.intervalToString) LongList(com.questdb.std.LongList) Test(org.junit.Test)

Example 5 with LongList

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

the class IntervalCompilerTest method assertShortInterval.

private static void assertShortInterval(String expected, String interval) throws ParserException {
    LongList out = new LongList();
    IntervalCompiler.parseIntervalEx(interval, 0, interval.length(), 0, out);
    Assert.assertEquals(expected, IntervalCompiler.asIntervalStr(out));
}
Also used : LongList(com.questdb.std.LongList)

Aggregations

LongList (com.questdb.std.LongList)12 Test (org.junit.Test)5 AbstractTest (com.questdb.test.tools.AbstractTest)3 Record (com.questdb.common.Record)2 JournalException (com.questdb.std.ex.JournalException)2 RecordCursor (com.questdb.common.RecordCursor)1 FactoryFullException (com.questdb.ex.FactoryFullException)1 JournalLockedException (com.questdb.ex.JournalLockedException)1 RetryLockException (com.questdb.ex.RetryLockException)1 GriffinParserTestUtils.intervalToString (com.questdb.griffin.lexer.GriffinParserTestUtils.intervalToString)1 Quote (com.questdb.model.Quote)1 MultiIntervalPartitionSource (com.questdb.ql.interval.MultiIntervalPartitionSource)1 IntList (com.questdb.std.IntList)1 Rnd (com.questdb.std.Rnd)1 StringSink (com.questdb.std.str.StringSink)1 IndexCursor (com.questdb.store.IndexCursor)1 Journal (com.questdb.store.Journal)1 JournalMetadata (com.questdb.store.factory.configuration.JournalMetadata)1 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)1 File (java.io.File)1