Search in sources :

Example 26 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException 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 27 with JournalRuntimeException

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

the class JournalPrinter method configure.

private void configure() {
    if (configured) {
        return;
    }
    try {
        for (int i1 = 0, k = ff.size(); i1 < k; i1++) {
            Field f = ff.get(i1);
            // value field
            if (f.name == null) {
                f.fromType = getType(f.typeTemplateIndex);
                f.offset = OBJECT_VALUE_OFFSET;
            } else if (f.typeTemplateIndex == -1) {
                // first type in typeTemplate array wins
                for (int i = 0; i < typeTemplate.length; i++) {
                    Class clazz = typeTemplate[i];
                    java.lang.reflect.Field[] declaredFields = clazz.getDeclaredFields();
                    for (int i2 = 0; i2 < declaredFields.length; i2++) {
                        if (f.name.equals(declaredFields[i2].getName())) {
                            f.fromType = declaredFields[i2].getType();
                            f.typeTemplateIndex = i;
                            break;
                        }
                    }
                    // found type
                    if (f.typeTemplateIndex != -1) {
                        break;
                    }
                }
                // finished loop without finding type
                if (f.typeTemplateIndex == -1) {
                    throw new RuntimeException("No such field: " + f.name);
                }
                f.offset = Unsafe.getUnsafe().objectFieldOffset(getType(f.typeTemplateIndex).getDeclaredField(f.name));
            } else {
                // reference field with known type template index
                Class t = getType(f.typeTemplateIndex);
                f.fromType = t.getDeclaredField(f.name).getType();
                f.offset = Unsafe.getUnsafe().objectFieldOffset(t.getDeclaredField(f.name));
            }
            setConverter(f);
        }
        configured = true;
    } catch (NoSuchFieldException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : JournalRuntimeException(com.questdb.common.JournalRuntimeException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 28 with JournalRuntimeException

use of com.questdb.common.JournalRuntimeException 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)

Example 29 with JournalRuntimeException

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

the class JournalConcurrentIterator method getRunnable.

private Runnable getRunnable() {
    return new Runnable() {

        boolean hasNext = true;

        private int currentIndex = 0;

        private long currentRowID;

        private long currentUpperBound;

        private int currentPartitionID;

        @Override
        public void run() {
            updateVariables();
            while (true) {
                try {
                    long cursor = pubSeq.nextBully();
                    Holder<T> holder = buffer.get(cursor);
                    boolean hadNext = hasNext;
                    if (hadNext) {
                        journal.read(Rows.toRowID(currentPartitionID, currentRowID), holder.object);
                        if (currentRowID < currentUpperBound) {
                            currentRowID++;
                        } else {
                            currentIndex++;
                            updateVariables();
                        }
                    }
                    holder.hasNext = hadNext;
                    pubSeq.done(cursor);
                    if (!hadNext) {
                        break;
                    }
                } catch (JournalException e) {
                    throw new JournalRuntimeException("Error in iterator [%s]", e, this);
                }
            }
        }

        private void updateVariables() {
            if (currentIndex < ranges.size()) {
                JournalIteratorRange w = ranges.getQuick(currentIndex);
                currentRowID = w.lo;
                currentUpperBound = w.hi;
                currentPartitionID = w.partitionID;
            } else {
                hasNext = false;
            }
        }
    };
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 30 with JournalRuntimeException

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

the class QueryAllImpl method incrementBufferedIterator.

@Override
public JournalPeekingIterator<T> incrementBufferedIterator() {
    try {
        long lo = journal.getMaxRowID();
        journal.refresh();
        return new JournalBufferedIterator<>(journal, createRanges(journal.incrementRowID(lo)));
    } catch (JournalException e) {
        throw new JournalRuntimeException(e);
    }
}
Also used : JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Aggregations

JournalRuntimeException (com.questdb.common.JournalRuntimeException)41 JournalException (com.questdb.std.ex.JournalException)30 KVIndex (com.questdb.store.KVIndex)9 IOException (java.io.IOException)6 IndexCursor (com.questdb.store.IndexCursor)5 Partition (com.questdb.store.Partition)5 ObjList (com.questdb.std.ObjList)4 FixedColumn (com.questdb.store.FixedColumn)2 File (java.io.File)2 MappedByteBuffer (java.nio.MappedByteBuffer)2 BootstrapEnv (com.questdb.BootstrapEnv)1 ServerConfiguration (com.questdb.ServerConfiguration)1 NumericException (com.questdb.common.NumericException)1 ImportColumnCountException (com.questdb.ex.ImportColumnCountException)1 ImportNameException (com.questdb.ex.ImportNameException)1 IncompatibleJournalException (com.questdb.ex.IncompatibleJournalException)1 JournalIOException (com.questdb.ex.JournalIOException)1 Quote (com.questdb.model.Quote)1 ClientConfig (com.questdb.net.ha.config.ClientConfig)1 ImportedColumnMetadata (com.questdb.parser.ImportedColumnMetadata)1