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