Search in sources :

Example 36 with JournalException

use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.

the class KvIndexIntListHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        FixedColumn col = partition.fixCol(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(values.get(i) & buckets);
            long r = -1;
            boolean found = false;
            while (c.hasNext()) {
                r = rec.rowid = c.next();
                if (r > lo && r < hi && col.getInt(r) == values.get(i) && (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) FixedColumn(com.questdb.store.FixedColumn)

Example 37 with JournalException

use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.

the class KvIndexLongListHeadRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        Partition partition = rec.partition = slice.partition.open();
        KVIndex index = partition.getIndexForColumn(columnIndex);
        FixedColumn col = partition.fixCol(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((int) (values.get(i) & buckets));
            long r = -1;
            boolean found = false;
            while (c.hasNext()) {
                r = rec.rowid = c.next();
                if (r > lo && r < hi && col.getLong(r) == values.get(i) && (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) FixedColumn(com.questdb.store.FixedColumn)

Example 38 with JournalException

use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.

the class KvIndexLongLookupRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        column = slice.partition.fixCol(columnIndex);
        KVIndex index = slice.partition.getIndexForColumn(columnIndex);
        this.indexCursor = newCursor ? index.newFwdCursor(key) : index.fwdCursor(key);
        this.lo = slice.lo - 1;
        this.hi = slice.calcHi ? slice.partition.open().size() : slice.hi + 1;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
    return this;
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException) KVIndex(com.questdb.store.KVIndex)

Example 39 with JournalException

use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.

the class KvIndexStrLookupRowSource method prepareCursor.

@Override
public RowCursor prepareCursor(PartitionSlice slice) {
    try {
        this.column = slice.partition.varCol(columnIndex);
        KVIndex index = slice.partition.getIndexForColumn(columnIndex);
        this.indexCursor = newCursor ? index.newFwdCursor(hash) : index.fwdCursor(hash);
        this.lo = slice.lo - 1;
        this.hi = slice.calcHi ? slice.partition.open().size() : slice.hi + 1;
        this.hasNext = false;
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
    return this;
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException) KVIndex(com.questdb.store.KVIndex)

Example 40 with JournalException

use of com.questdb.std.ex.JournalException in project questdb by bluestreak01.

the class JournalBufferedIterator method updateVariables.

private void updateVariables() {
    if (currentIndex < ranges.size()) {
        JournalIteratorRange w = ranges.getQuick(currentIndex);
        currentRowID = w.lo;
        currentUpperBound = w.hi;
        try {
            partition = journal.getPartition(w.partitionID, true);
        } catch (JournalException e) {
            throw new JournalRuntimeException(e);
        }
    } else {
        hasNext = false;
    }
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Aggregations

JournalException (com.questdb.std.ex.JournalException)63 JournalRuntimeException (com.questdb.common.JournalRuntimeException)29 AbstractTest (com.questdb.test.tools.AbstractTest)14 Test (org.junit.Test)13 KVIndex (com.questdb.store.KVIndex)12 Partition (com.questdb.store.Partition)9 Quote (com.questdb.model.Quote)8 IndexCursor (com.questdb.store.IndexCursor)8 File (java.io.File)8 CountDownLatch (java.util.concurrent.CountDownLatch)7 IncompatibleJournalException (com.questdb.ex.IncompatibleJournalException)5 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)5 ObjList (com.questdb.std.ObjList)4 JournalWriter (com.questdb.store.JournalWriter)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 ClientConfig (com.questdb.net.ha.config.ClientConfig)3 FixedColumn (com.questdb.store.FixedColumn)3 Factory (com.questdb.store.factory.Factory)3 ColumnMetadata (com.questdb.store.factory.configuration.ColumnMetadata)3 JournalLockedException (com.questdb.ex.JournalLockedException)2