Search in sources :

Example 1 with TooBigLoggableException

use of jetbrains.exodus.log.TooBigLoggableException in project xodus by JetBrains.

the class BasePageMutable method save.

/**
 * Save page to log
 *
 * @return address of this page after save
 */
protected long save() {
    // save leaf nodes
    ReclaimFlag flag = saveChildren();
    // save self. complementary to {@link load()}
    final byte type = getType();
    final BTreeBase tree = getTree();
    final int structureId = tree.structureId;
    final Log log = tree.log;
    if (flag == ReclaimFlag.PRESERVE) {
        // there is a chance to update the flag to RECLAIM
        if (log.getWrittenHighAddress() % log.getFileSize() == 0) {
            // page will be exactly on file border
            flag = ReclaimFlag.RECLAIM;
        } else {
            final ByteIterable[] iterables = getByteIterables(flag);
            long result = log.tryWrite(type, structureId, new CompoundByteIterable(iterables));
            if (result < 0) {
                iterables[0] = CompressedUnsignedLongByteIterable.getIterable((size << 1) + ReclaimFlag.RECLAIM.value);
                result = log.writeContinuously(type, structureId, new CompoundByteIterable(iterables));
                if (result < 0) {
                    throw new TooBigLoggableException();
                }
            }
            return result;
        }
    }
    return log.write(type, structureId, new CompoundByteIterable(getByteIterables(flag)));
}
Also used : Log(jetbrains.exodus.log.Log) TooBigLoggableException(jetbrains.exodus.log.TooBigLoggableException) CompoundByteIterable(jetbrains.exodus.CompoundByteIterable) CompressedUnsignedLongByteIterable(jetbrains.exodus.log.CompressedUnsignedLongByteIterable) CompressedUnsignedLongArrayByteIterable(jetbrains.exodus.bindings.CompressedUnsignedLongArrayByteIterable) ByteIterable(jetbrains.exodus.ByteIterable) CompoundByteIterable(jetbrains.exodus.CompoundByteIterable)

Aggregations

ByteIterable (jetbrains.exodus.ByteIterable)1 CompoundByteIterable (jetbrains.exodus.CompoundByteIterable)1 CompressedUnsignedLongArrayByteIterable (jetbrains.exodus.bindings.CompressedUnsignedLongArrayByteIterable)1 CompressedUnsignedLongByteIterable (jetbrains.exodus.log.CompressedUnsignedLongByteIterable)1 Log (jetbrains.exodus.log.Log)1 TooBigLoggableException (jetbrains.exodus.log.TooBigLoggableException)1