use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.
the class FileSink method map.
private void map() {
if (buffer != null) {
ByteBuffers.release(buffer);
}
try {
this.buffer = channel.map(FileChannel.MapMode.READ_WRITE, this.pos, ByteBuffers.getMaxMappedBufferSize(Long.MAX_VALUE));
pos += buffer.limit();
addr = ByteBuffers.getAddress(buffer);
limit = addr + buffer.remaining();
} catch (IOException e) {
throw new JournalRuntimeException(e);
}
}
use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.
the class Journal method createTempPartition.
public TempPartition<T> createTempPartition(String name) {
int lag = getMetadata().getLag();
if (lag < 1) {
throw new JournalRuntimeException("Journal doesn't support temp partitions: %s", this);
}
Interval interval = null;
if (getMetadata().getPartitionBy() != PartitionBy.NONE) {
Partition<T> p = partitions.getLast();
if (p != null) {
Interval lastPartitionInterval = p.getInterval();
interval = new Interval(lastPartitionInterval.getLo(), Dates.addHours(lastPartitionInterval.getHi(), lag));
} else {
interval = new Interval(System.currentTimeMillis(), getMetadata().getPartitionBy());
}
}
return new TempPartition<>(this, interval, nonLagPartitionCount(), name);
}
use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.
the class JournalIterators method createRanges.
private static <T> ObjList<JournalIteratorRange> createRanges(Journal<T> journal, long lo) {
ObjList<JournalIteratorRange> ranges = new ObjList<>();
int loPartitionID = Rows.toPartitionIndex(lo);
long loLocalRowID = Rows.toLocalRowID(lo);
try {
int count = journal.getPartitionCount();
for (int i = loPartitionID; i < count; i++) {
long localRowID = 0;
if (i == loPartitionID) {
localRowID = loLocalRowID;
}
Partition<T> p = journal.getPartition(i, true);
long size = p.size();
if (size > 0) {
ranges.add(new JournalIteratorRange(p.getPartitionIndex(), localRowID, size - 1));
}
}
return ranges;
} catch (JournalException e) {
throw new JournalRuntimeException(e);
}
}
use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.
the class PlainFile method mapBufferInternal.
private MappedByteBuffer mapBufferInternal(long offset, int size) {
try {
MappedByteBuffer buf;
switch(journalMode) {
case JournalMode.READ:
// make sure size does not extend beyond actual file size, otherwise
// java would assume we want to write and throw an exception
long sz;
if (offset + ((long) size) > channel.size()) {
sz = channel.size() - offset;
} else {
sz = size;
}
assert sz > 0;
buf = channel.map(FileChannel.MapMode.READ_ONLY, offset, sz);
break;
default:
buf = channel.map(FileChannel.MapMode.READ_WRITE, offset, size);
break;
}
buf.order(ByteOrder.LITTLE_ENDIAN);
return buf;
} catch (IOException e) {
throw new JournalRuntimeException("Failed to memory map: %s", e, file.getAbsolutePath());
}
}
use of com.questdb.common.JournalRuntimeException in project questdb by bluestreak01.
the class AllRowSource method prepareCursor.
@Override
public RowCursor prepareCursor(PartitionSlice slice) {
try {
this.lo = slice.lo;
this.hi = slice.calcHi ? slice.partition.open().size() - 1 : slice.hi;
return this;
} catch (JournalException e) {
throw new JournalRuntimeException(e);
}
}
Aggregations