Search in sources :

Example 31 with JournalRuntimeException

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);
    }
}
Also used : JournalRuntimeException(com.questdb.common.JournalRuntimeException) IOException(java.io.IOException)

Example 32 with JournalRuntimeException

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);
}
Also used : JournalRuntimeException(com.questdb.common.JournalRuntimeException) Interval(com.questdb.std.time.Interval)

Example 33 with JournalRuntimeException

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);
    }
}
Also used : ObjList(com.questdb.std.ObjList) JournalException(com.questdb.std.ex.JournalException) JournalRuntimeException(com.questdb.common.JournalRuntimeException)

Example 34 with JournalRuntimeException

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());
    }
}
Also used : MappedByteBuffer(java.nio.MappedByteBuffer) JournalRuntimeException(com.questdb.common.JournalRuntimeException) IOException(java.io.IOException)

Example 35 with JournalRuntimeException

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