Search in sources :

Example 6 with FileException

use of org.apache.jena.tdb.base.file.FileException in project jena by apache.

the class ObjectFileTrans method append.

/** Copy from the temporary file to the real file */
private void append() {
    // We could write directly to the real file if:
    //    we record the truncate point needed for an abort
    //    manage partial final writes
    //    deny the existence of nodes after the transaction mark.
    // Later - stay simple for now.
    // Truncate/position the ObjectFile.
    base.reposition(otherAllocOffset);
    Iterator<Pair<Long, ByteBuffer>> iter = transObjects.all();
    for (; iter.hasNext(); ) {
        Pair<Long, ByteBuffer> p = iter.next();
        String s = StrUtils.fromUTF8bytes(p.getRight().array());
        long x = base.write(p.getRight());
        if (p.getLeft() + otherAllocOffset != x)
            throw new FileException("Expected id of " + (p.getLeft() + otherAllocOffset) + ", got an id of " + x);
    }
}
Also used : FileException(org.apache.jena.tdb.base.file.FileException) ByteBuffer(java.nio.ByteBuffer) Pair(org.apache.jena.atlas.lib.Pair)

Aggregations

FileException (org.apache.jena.tdb.base.file.FileException)6 ByteBuffer (java.nio.ByteBuffer)3 Pair (org.apache.jena.atlas.lib.Pair)1