Search in sources :

Example 11 with RowCursor

use of com.questdb.common.RowCursor in project questdb by bluestreak01.

the class IntervalFrameCursorTest method assertIndexRowsMatchSymbol.

private static void assertIndexRowsMatchSymbol(DataFrameCursor cursor, TableReaderRecord record, int columnIndex, long expectedCount) {
    // SymbolTable is table at table scope, so it will be the same for every
    // data frame here. Get its instance outside of data frame loop.
    SymbolTable symbolTable = cursor.getSymbolTable(columnIndex);
    long rowCount = 0;
    while (cursor.hasNext()) {
        DataFrame frame = cursor.next();
        record.jumpTo(frame.getPartitionIndex(), frame.getRowLo());
        final long limit = frame.getRowHi();
        final long low = frame.getRowLo();
        // BitmapIndex is always at data frame scope, each table can have more than one.
        // we have to get BitmapIndexReader instance once for each frame.
        BitmapIndexReader indexReader = frame.getBitmapIndexReader(columnIndex);
        // because out Symbol column 0 is indexed, frame has to have index.
        Assert.assertNotNull(indexReader);
        int keyCount = indexReader.getKeyCount();
        for (int i = 0; i < keyCount; i++) {
            RowCursor ic = indexReader.getCursor(i, limit - 1);
            CharSequence expected = symbolTable.value(i - 1);
            while (ic.hasNext()) {
                long row = ic.next();
                if (row < low) {
                    break;
                }
                record.setRecordIndex(row);
                TestUtils.assertEquals(expected, record.getSym(columnIndex));
                rowCount++;
            }
        }
    }
    Assert.assertEquals(expectedCount, rowCount);
}
Also used : SymbolTable(com.questdb.common.SymbolTable) DataFrame(com.questdb.cairo.sql.DataFrame) RowCursor(com.questdb.common.RowCursor)

Example 12 with RowCursor

use of com.questdb.common.RowCursor in project questdb by bluestreak01.

the class HeapMergingRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    heap.clear();
    for (int i = 0, n = sources.length; i < n; i++) {
        RowCursor c = Unsafe.arrayGet(sources, i).prepareCursor(slice);
        Unsafe.arrayPut(cursors, i, c);
        if (c.hasNext()) {
            heap.add(i, c.next());
        }
    }
    return this;
}
Also used : RowCursor(com.questdb.common.RowCursor)

Example 13 with RowCursor

use of com.questdb.common.RowCursor in project questdb by bluestreak01.

the class HeapRowCursor method of.

public void of(RowCursor[] cursors) {
    assert nCursors == cursors.length;
    this.cursors = cursors;
    this.heap.clear();
    for (int i = 0; i < nCursors; i++) {
        RowCursor cursor = Unsafe.arrayGet(cursors, i);
        if (cursor.hasNext()) {
            heap.add(i, cursor.next());
        }
    }
}
Also used : RowCursor(com.questdb.common.RowCursor)

Aggregations

RowCursor (com.questdb.common.RowCursor)13 Test (org.junit.Test)6 Path (com.questdb.std.str.Path)2 DataFrame (com.questdb.cairo.sql.DataFrame)1 SymbolTable (com.questdb.common.SymbolTable)1 Rnd (com.questdb.std.Rnd)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1