long (long recordOffset, @NotNull RecordLayout recordLayout, int recordCapacity) { final int headerSize = recordLayout.headerSize(); final long nextOffset = recordOffset + headerSize + recordCapacity; final int offsetOnPage = toOffsetOnPage(nextOffset); if (pageSize - offsetOnPage < headerSize) { //Previously, I _fix_ the mismatch here -- by moving offset to the next page: // nextOffset = (nextOffset / pageSize + 1) * pageSize; //Now instead of fix it here I adjust new record allocation code (allocateRecord), so for records // on the end of page -- record capacity is increased slightly, to consume that small unusable // bytes on the edge of the page -- this way those bytes are utilized. // But that means this branch should be unreachable now: throw new AssertionError("Bug: offsetOnPage(" + offsetOnPage + ") is too close to page border (" + pageSize + ")"); } return nextOffset; }