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);
}
}
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);
}
}
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;
}
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;
}
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();
}
Aggregations