Search in sources :

Example 1 with StorageException

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

the class BPTreeRecords method internalInsert.

@Override
public Record internalInsert(Record record) {
    // [TxTDB:PATCH-UP]
    promote();
    int i = rBuff.find(record);
    Record r2 = null;
    if (i < 0) {
        i = decodeIndex(i);
        if (rBuff.size() >= rBuff.maxSize())
            throw new StorageException("RecordBlock.put overflow");
        rBuff.add(i, record);
    } else {
        r2 = rBuff.get(i);
        if (Record.compareByKeyValue(record, r2) != 0)
            // Replace : return old
            rBuff.set(i, record);
    }
    write();
    return r2;
}
Also used : Record(org.apache.jena.tdb.base.record.Record) StorageException(org.apache.jena.tdb.base.StorageException)

Example 2 with StorageException

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

the class HashBucket method put.

// Return true is added a new value 
public final boolean put(Record record) {
    int i = findIndex(record);
    if (i < 0)
        i = decodeIndex(i);
    else {
        Record recordOrig = getRecordBuffer().get(i);
        if (record.equals(recordOrig))
            return false;
        // Same key, different values. Replace.
        getRecordBuffer().set(i, record);
        return true;
    }
    if (getRecordBuffer().isFull())
        throw new StorageException("Bucket overflow");
    getRecordBuffer().add(i, record);
    return true;
}
Also used : Record(org.apache.jena.tdb.base.record.Record) StorageException(org.apache.jena.tdb.base.StorageException)

Example 3 with StorageException

use of org.apache.jena.tdb.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<<@" + 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>>@" + loc);
    return len;
}
Also used : StorageException(org.apache.jena.tdb.base.StorageException)

Example 4 with StorageException

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

the class BufferChannelMem method truncate.

@Override
public synchronized void truncate(long size) {
    checkIfClosed();
    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.tdb.base.StorageException)

Example 5 with StorageException

use of org.apache.jena.tdb.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.tdb.base.StorageException)

Aggregations

StorageException (org.apache.jena.tdb.base.StorageException)7 Record (org.apache.jena.tdb.base.record.Record)3