// "if-else polymorphism" is not very beautiful, but allows to
// reuse the rest code of this method and doesn't hurt performance.
boolean byteableValue = usingValue && value instanceof Byteable;
long valueLen;
Bytes valueBytes = null;
Byteable valueAsByteable = null;
if (!byteableValue) {
valueBytes = getValueAsBytes(value);
valueLen = valueBytes.remaining();
} else {
valueAsByteable = (Byteable) value;
valueLen = valueAsByteable.maxSize();
}
long entrySize = entrySize(keyLen, valueLen);
int pos = alloc(inBlocks(entrySize));
long offset = offsetFromPos(pos);