Search in sources :

Example 6 with IndexCursor

use of com.questdb.store.IndexCursor in project questdb by bluestreak01.

the class KvIndexStrLambdaHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        VariableColumn col = partition.varCol(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = hashes.size(); i < n; i++) {
            IndexCursor c = index.cursor(hashes.getQuick(i));
            while (c.hasNext()) {
                long r = rec.rowid = c.next();
                if (r > lo && r < hi && Chars.equals(col.getFlyweightStr(r), keys.get(i)) && (filter == null || filter.getBool(rec))) {
                    rows.add(r);
                    break;
                }
            }
        }
        rows.sort();
        cursor = 0;
        return this;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : Partition(com.questdb.store.Partition) JournalException(com.questdb.std.ex.JournalException) IndexCursor(com.questdb.store.IndexCursor) KVIndex(com.questdb.store.KVIndex) VariableColumn(com.questdb.store.VariableColumn)

Example 7 with IndexCursor

use of com.questdb.store.IndexCursor in project questdb by bluestreak01.

the class KvIndexSymLambdaHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = keys.size(); i < n; i++) {
            IndexCursor c = index.cursor(keys.get(i));
            while (c.hasNext()) {
                long r = rec.rowid = c.next();
                if (r > lo && r < hi && (filter == null || filter.getBool(rec))) {
                    rows.add(r);
                    break;
                }
            }
        }
        rows.sort();
        cursor = 0;
        return this;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : Partition(com.questdb.store.Partition) JournalException(com.questdb.std.ex.JournalException) IndexCursor(com.questdb.store.IndexCursor) KVIndex(com.questdb.store.KVIndex)

Example 8 with IndexCursor

use of com.questdb.store.IndexCursor in project questdb by bluestreak01.

the class KvIndexStrListHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        VariableColumn col = partition.varCol(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = values.size(); i < n; i++) {
            IndexCursor c = index.cursor(Hash.boundedHash(values.get(i), buckets));
            while (c.hasNext()) {
                long r = rec.rowid = c.next();
                if (r > lo && r < hi && col.cmpStr(r, values.get(i)) && (filter == null || filter.getBool(rec))) {
                    rows.add(r);
                    break;
                }
            }
        }
        rows.sort();
        keyIndex = 0;
        return this;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : Partition(com.questdb.store.Partition) JournalException(com.questdb.std.ex.JournalException) IndexCursor(com.questdb.store.IndexCursor) JournalRuntimeException(com.questdb.common.JournalRuntimeException) KVIndex(com.questdb.store.KVIndex) VariableColumn(com.questdb.store.VariableColumn)

Example 9 with IndexCursor

use of com.questdb.store.IndexCursor in project questdb by bluestreak01.

the class KvIndexSymAllHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = valueCount; i < n; i++) {
            IndexCursor c = index.cursor(i);
            while (c.hasNext()) {
                long r = rec.rowid = c.next();
                if (r > lo && r < hi && (filter == null || filter.getBool(rec))) {
                    rows.add(r);
                    break;
                }
            }
        }
        rows.sort();
        cursor = 0;
        return this;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : Partition(com.questdb.store.Partition) JournalException(com.questdb.std.ex.JournalException) IndexCursor(com.questdb.store.IndexCursor) JournalRuntimeException(com.questdb.common.JournalRuntimeException) KVIndex(com.questdb.store.KVIndex)

Example 10 with IndexCursor

use of com.questdb.store.IndexCursor in project questdb by bluestreak01.

the class KvIndexSymListHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        long lo = slice.lo - 1;
        long hi = slice.calcHi ? partition.size() : slice.hi + 1;
        rows.clear();
        for (int i = 0, n = keys.size(); i < n; i++) {
            IndexCursor c = index.cursor(keys.getQuick(i));
            long r = -1;
            boolean found = false;
            while (c.hasNext()) {
                r = rec.rowid = c.next();
                if (r > lo && r < hi && (filter == null || filter.getBool(rec))) {
                    found = true;
                    break;
                }
            }
            if (found) {
                rows.add(r);
            }
        }
        rows.sort();
        keyIndex = 0;
        return this;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : Partition(com.questdb.store.Partition) JournalException(com.questdb.std.ex.JournalException) IndexCursor(com.questdb.store.IndexCursor) JournalRuntimeException(com.questdb.common.JournalRuntimeException) KVIndex(com.questdb.store.KVIndex)

Aggregations

IndexCursor (com.questdb.store.IndexCursor)10 KVIndex (com.questdb.store.KVIndex)9 JournalException (com.questdb.std.ex.JournalException)8 Partition (com.questdb.store.Partition)8 JournalRuntimeException (com.questdb.common.JournalRuntimeException)5 FixedColumn (com.questdb.store.FixedColumn)3 VariableColumn (com.questdb.store.VariableColumn)2 IntLongPriorityQueue (com.questdb.std.IntLongPriorityQueue)1 LongList (com.questdb.std.LongList)1 Rnd (com.questdb.std.Rnd)1 AbstractTest (com.questdb.test.tools.AbstractTest)1 Test (org.junit.Test)1