Minor refactor of logic in FileChannelJournalSegmentWriter class.
Removed unnecessary buffer clearing after each entry. New logic
remove already proccesed entry from the buffer and if needed reads
new data from FileChannel to it's capacity.
JIRA: CONTROLLER-2097
Change-Id: I571d531437b068cd468bdc92b3ab6a4223450a45
Signed-off-by: Oleksandr Zharov <oleksandr.zharov@pantheon.tech>
// Read more bytes from the segment if necessary.
if (memory.remaining() < maxEntrySize) {
- memory.clear();
- channel.read(memory, currentPosition);
+ memory.compact();
+ channel.read(memory);
memory.flip();
}