Search in sources :

Example 16 with RowCursor

use of io.questdb.cairo.sql.RowCursor in project questdb by bluestreak01.

the class BitmapIndexBwdNullReaderTest method testCursor.

@Test
public void testCursor() {
    final Rnd rnd = new Rnd();
    for (int i = 0; i < 10; i++) {
        int n = rnd.nextPositiveInt() % 1024;
        int m = n;
        RowCursor cursor = reader.getCursor(true, 0, 0, n);
        while (cursor.hasNext()) {
            Assert.assertEquals(m--, cursor.next());
        }
        Assert.assertEquals(-1, m);
    }
}
Also used : Rnd(io.questdb.std.Rnd) RowCursor(io.questdb.cairo.sql.RowCursor) Test(org.junit.Test)

Example 17 with RowCursor

use of io.questdb.cairo.sql.RowCursor in project questdb by bluestreak01.

the class BitmapIndexFwdNullReaderTest method testCursor.

@Test
public void testCursor() {
    final Rnd rnd = new Rnd();
    for (int i = 0; i < 10; i++) {
        int n = rnd.nextPositiveInt() % 1024;
        int m = 0;
        RowCursor cursor = reader.getCursor(true, 0, 0, n);
        while (cursor.hasNext()) {
            Assert.assertEquals(m++, cursor.next());
        }
        Assert.assertEquals(n + 1, m);
    }
}
Also used : Rnd(io.questdb.std.Rnd) RowCursor(io.questdb.cairo.sql.RowCursor) Test(org.junit.Test)

Example 18 with RowCursor

use of io.questdb.cairo.sql.RowCursor in project questdb by bluestreak01.

the class BitmapIndexBwdReader method getCursor.

@Override
public RowCursor getCursor(boolean cachedInstance, int key, long minValue, long maxValue) {
    assert minValue <= maxValue;
    if (key >= keyCount) {
        updateKeyCount();
    }
    if (key == 0 && unIndexedNullCount > 0) {
        final NullCursor nullCursor = getNullCursor(cachedInstance);
        nullCursor.nullCount = unIndexedNullCount;
        nullCursor.of(key, minValue, maxValue, keyCount);
        return nullCursor;
    }
    if (key < keyCount) {
        final Cursor cursor = getCursor(cachedInstance);
        cursor.of(key, minValue, maxValue, keyCount);
        return cursor;
    }
    return EmptyRowCursor.INSTANCE;
}
Also used : RowCursor(io.questdb.cairo.sql.RowCursor)

Example 19 with RowCursor

use of io.questdb.cairo.sql.RowCursor in project questdb by bluestreak01.

the class BitmapIndexFwdReader method getCursor.

@Override
public RowCursor getCursor(boolean cachedInstance, int key, long minValue, long maxValue) {
    if (key >= keyCount) {
        updateKeyCount();
    }
    if (key == 0 && unIndexedNullCount > 0 && minValue < unIndexedNullCount) {
        // we need to return some nulls and the whole set of actual index values
        final NullCursor nullCursor = getNullCursor(cachedInstance);
        nullCursor.nullPos = minValue;
        nullCursor.nullCount = unIndexedNullCount;
        nullCursor.of(key, 0, maxValue, keyCount);
        return nullCursor;
    }
    if (key < keyCount) {
        final Cursor cursor = getCursor(cachedInstance);
        cursor.of(key, minValue, maxValue, keyCount);
        return cursor;
    }
    return EmptyRowCursor.INSTANCE;
}
Also used : NullIndexFrameCursor(io.questdb.NullIndexFrameCursor) RowCursor(io.questdb.cairo.sql.RowCursor)

Example 20 with RowCursor

use of io.questdb.cairo.sql.RowCursor in project questdb by bluestreak01.

the class LatestByValuesIndexedFilteredRecordCursor method buildTreeMap.

@Override
protected void buildTreeMap(SqlExecutionContext executionContext) {
    final int keyCount = symbolKeys.size();
    found.clear();
    DataFrame frame;
    while ((frame = this.dataFrameCursor.next()) != null && found.size() < keyCount) {
        final int partitionIndex = frame.getPartitionIndex();
        final BitmapIndexReader indexReader = frame.getBitmapIndexReader(columnIndex, BitmapIndexReader.DIR_BACKWARD);
        final long rowLo = frame.getRowLo();
        final long rowHi = frame.getRowHi() - 1;
        this.recordA.jumpTo(partitionIndex, 0);
        for (int i = 0, n = symbolKeys.size(); i < n; i++) {
            int symbolKey = symbolKeys.get(i);
            int index = found.keyIndex(symbolKey);
            if (index > -1) {
                RowCursor cursor = indexReader.getCursor(false, symbolKey, rowLo, rowHi);
                if (cursor.hasNext()) {
                    final long row = cursor.next();
                    recordA.setRecordIndex(row);
                    if (filter.getBool(recordA)) {
                        rows.add(Rows.toRowID(partitionIndex, row));
                        found.addAt(index, symbolKey);
                    }
                }
            }
        }
    }
    rows.sortAsUnsigned();
}
Also used : BitmapIndexReader(io.questdb.cairo.BitmapIndexReader) DataFrame(io.questdb.cairo.sql.DataFrame) RowCursor(io.questdb.cairo.sql.RowCursor)

Aggregations

RowCursor (io.questdb.cairo.sql.RowCursor)24 Test (org.junit.Test)11 Path (io.questdb.std.str.Path)4 BitmapIndexReader (io.questdb.cairo.BitmapIndexReader)3 DataFrame (io.questdb.cairo.sql.DataFrame)3 Rnd (io.questdb.std.Rnd)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 CyclicBarrier (java.util.concurrent.CyclicBarrier)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 NullIndexFrameCursor (io.questdb.NullIndexFrameCursor)1