Search in sources :

Example 1 with StorageException

use of org.apache.jena.dboe.base.StorageException in project jena by apache.

the class BufferChannelMem method read.

@Override
public synchronized int read(ByteBuffer buffer, long loc) {
    checkIfClosed();
    if (TRACKING)
        log("read<<@%d", loc);
    if (loc < 0 || loc > bytes.limit())
        throw new StorageException("Out of range(" + name + "[read]): " + loc + " [0," + bytes.limit() + ")");
    if (loc == bytes.limit())
        log.warn("At the limit(" + name + "[read]): " + loc);
    int x = bytes.position();
    bytes.position((int) loc);
    int len = read(buffer);
    bytes.position(x);
    if (TRACKING)
        log("read>>@%d", loc);
    return len;
}
Also used : StorageException(org.apache.jena.dboe.base.StorageException)

Example 2 with StorageException

use of org.apache.jena.dboe.base.StorageException in project jena by apache.

the class RecordRangeIterator method hasNext.

@Override
public boolean hasNext() {
    if (slot != null)
        return true;
    if (currentPage == null)
        return false;
    // Set slot.
    while (currentIdx >= currentPage.getCount()) {
        // Move to next.
        int link = currentPage.getLink();
        if (link < 0) {
            close();
            return false;
        }
        if (currentPage != null)
            pageMgr.release(currentPage);
        RecordBufferPage nextPage = pageMgr.getRead(link);
        // Check currentPage -> nextPage is strictly increasing keys.
        if (false) {
            Record r1 = currentPage.getRecordBuffer().getHigh();
            Record r2 = nextPage.getRecordBuffer().getLow();
            if (Record.keyGE(r1, r2))
                throw new StorageException("RecordRangeIterator: records not strictly increasing: " + r1 + " // " + r2);
        }
        currentPage = nextPage;
        countBlocks++;
        currentIdx = 0;
    }
    slot = currentPage.getRecordBuffer().access(currentIdx, keySlot, mapper);
    currentIdx++;
    if (maxRec != null && Bytes.compare(keySlot, maxRec.getKey()) >= 0) {
        close();
        return false;
    }
    if (slot == null) {
        close();
        return false;
    }
    countRecords++;
    return true;
}
Also used : Record(org.apache.jena.dboe.base.record.Record) StorageException(org.apache.jena.dboe.base.StorageException)

Example 3 with StorageException

use of org.apache.jena.dboe.base.StorageException in project jena by apache.

the class BufferChannelMem method truncate.

@Override
public synchronized void truncate(long size) {
    checkIfClosed();
    if (TRACKING)
        log("truncate(%d)", size);
    int x = (int) size;
    if (x < 0)
        throw new StorageException("Out of range: " + size);
    if (x > bytes.limit())
        return;
    if (bytes.position() > x)
        bytes.position(x);
    bytes.limit(x);
}
Also used : StorageException(org.apache.jena.dboe.base.StorageException)

Example 4 with StorageException

use of org.apache.jena.dboe.base.StorageException in project jena by apache.

the class BufferChannelMem method position.

@Override
public synchronized void position(long pos) {
    checkIfClosed();
    if (pos < 0 || pos > bytes.capacity())
        throw new StorageException("Out of range: " + pos);
    bytes.position((int) pos);
}
Also used : StorageException(org.apache.jena.dboe.base.StorageException)

Example 5 with StorageException

use of org.apache.jena.dboe.base.StorageException in project jena by apache.

the class BufferChannelMem method write.

// Invert : write(ByteBuffer) = write(ByteBuffer,posn)
@Override
public synchronized int write(ByteBuffer buffer, long loc) {
    checkIfClosed();
    if (TRACKING)
        log("write<<@%d", loc);
    if (loc < 0 || loc > bytes.limit())
        // Can write at loc = bytes()
        throw new StorageException("Out of range(" + name + "[write]): " + loc + " [0," + bytes.limit() + ")");
    int x = bytes.position();
    bytes.position((int) loc);
    int len = write(buffer);
    bytes.position(x);
    if (TRACKING)
        log("write>>@%d", loc);
    return len;
}
Also used : StorageException(org.apache.jena.dboe.base.StorageException)

Aggregations

StorageException (org.apache.jena.dboe.base.StorageException)6 Record (org.apache.jena.dboe.base.record.Record)2