Search in sources :

Example 6 with DataFrame

use of com.questdb.cairo.sql.DataFrame in project questdb by bluestreak01.

the class FullTableFrameCursorTest method assertData.

private void assertData(FullTableFrameCursor cursor, TableReaderRecord record, Rnd rnd, SymbolGroup sg, long expecteRowCount) {
    // 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.
    long rowCount = 0;
    while (cursor.hasNext()) {
        DataFrame frame = cursor.next();
        record.jumpTo(frame.getPartitionIndex(), frame.getRowLo());
        final long limit = frame.getRowHi();
        long recordIndex;
        while ((recordIndex = record.getRecordIndex()) < limit) {
            TestUtils.assertEquals(sg.symA[rnd.nextPositiveInt() % sg.S], record.getSym(0));
            TestUtils.assertEquals(sg.symB[rnd.nextPositiveInt() % sg.S], record.getSym(1));
            TestUtils.assertEquals(sg.symC[rnd.nextPositiveInt() % sg.S], record.getSym(2));
            Assert.assertEquals(rnd.nextDouble(), record.getDouble(3), 0.0000001d);
            record.setRecordIndex(recordIndex + 1);
            rowCount++;
        }
    }
    Assert.assertEquals(expecteRowCount, rowCount);
}
Also used : DataFrame(com.questdb.cairo.sql.DataFrame)

Example 7 with DataFrame

use of com.questdb.cairo.sql.DataFrame 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 8 with DataFrame

use of com.questdb.cairo.sql.DataFrame in project questdb by bluestreak01.

the class FilteredTableRecordCursor method nextFrame.

private boolean nextFrame() {
    while (dataFrameCursor.hasNext()) {
        DataFrame dataFrame = dataFrameCursor.next();
        rowCursor = rowCursorFactory.getCursor(dataFrame);
        if (rowCursor.hasNext()) {
            record.jumpTo(dataFrame.getPartitionIndex(), rowCursor.next());
            return true;
        }
    }
    return false;
}
Also used : DataFrame(com.questdb.cairo.sql.DataFrame)

Aggregations

DataFrame (com.questdb.cairo.sql.DataFrame)8 DataFrameCursor (com.questdb.cairo.sql.DataFrameCursor)1 RowCursor (com.questdb.common.RowCursor)1 SymbolTable (com.questdb.common.SymbolTable)1 Rnd (com.questdb.std.Rnd)1 Test (org.junit.Test)1