Search in sources :

Example 21 with RowCursor

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

the class LatestByValuesIndexedRecordCursor method buildTreeMap.

protected void buildTreeMap() {
    final int keyCount = symbolKeys.size();
    found.clear();
    rows.setPos(0);
    DataFrame frame;
    while ((frame = this.dataFrameCursor.next()) != null && found.size() < keyCount) {
        final BitmapIndexReader indexReader = frame.getBitmapIndexReader(columnIndex, BitmapIndexReader.DIR_BACKWARD);
        final long rowLo = frame.getRowLo();
        final long rowHi = frame.getRowHi() - 1;
        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 = Rows.toRowID(frame.getPartitionIndex(), cursor.next());
                    rows.add(row);
                    found.addAt(index, symbolKey);
                }
            }
        }
    }
    index = rows.size() - 1;
}
Also used : BitmapIndexReader(io.questdb.cairo.BitmapIndexReader) DataFrame(io.questdb.cairo.sql.DataFrame) RowCursor(io.questdb.cairo.sql.RowCursor)

Example 22 with RowCursor

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

the class HeapRowCursor method next.

@Override
public long next() {
    int idx = heap.popIndex();
    RowCursor cursor = cursors.getQuick(idx);
    return cursor.hasNext() ? heap.popAndReplace(idx, cursor.next()) : heap.popValue();
}
Also used : RowCursor(io.questdb.cairo.sql.RowCursor)

Example 23 with RowCursor

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

the class HeapRowCursor method of.

public void of(ObjList<RowCursor> cursors) {
    int nCursors = cursors.size();
    this.cursors = cursors;
    this.heap.clear();
    for (int i = 0; i < nCursors; i++) {
        final RowCursor cursor = cursors.getQuick(i);
        if (cursor.hasNext()) {
            heap.add(i, cursor.next());
        }
    }
}
Also used : RowCursor(io.questdb.cairo.sql.RowCursor)

Example 24 with RowCursor

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

the class LatestByValueIndexedFilteredRecordCursor method findRecord.

private void findRecord() {
    DataFrame frame;
    found = false;
    while ((frame = this.dataFrameCursor.next()) != null) {
        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);
        RowCursor cursor = indexReader.getCursor(false, symbolKey, rowLo, rowHi);
        while (cursor.hasNext()) {
            recordA.setRecordIndex(cursor.next());
            if (filter.getBool(recordA)) {
                found = true;
                return;
            }
        }
    }
}
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