Source:
void map(boolean persistBloom) throws IOException, StoreException { RandomAccessFile raf = new RandomAccessFile(indexFile, "r"); rwLock.writeLock().lock(); try { mmap = raf.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, indexFile.length()); mmap.position(0); version = mmap.getShort(); switch (version) { case 0: this.keySize = mmap.getInt(); this.valueSize = mmap.getInt(); this.endOffset.set(new Offset(startOffset.getName(), mmap.getLong())); this.lastModifiedTimeSec = new AtomicLong(time.seconds()); break; case 1: this.keySize = mmap.getInt(); this.valueSize = mmap.getInt(); this.endOffset.set(new Offset(startOffset.getName(), mmap.getLong())); this.lastModifiedTimeSec = new AtomicLong(mmap.getLong()); StoreKey storeKey = factory.getStoreKey(new DataInputStream(new ByteBufferInputStream(mmap))); short resetKeyType = mmap.getShort(); this.resetKey = new Pair<>(storeKey, resetKeyType); break; default: throw new StoreException("IndexSegment : " + indexFile.getAbsolutePath() + " unknown version in index file", StoreErrorCodes.Index_Version_Error); } mapped.set(true); index = null; } finally { raf.close(); rwLock.writeLock().unlock(); } if (persistBloom) { CrcOutputStream crcStream = new CrcOutputStream(new FileOutputStream(bloomFile)); DataOutputStream stream = new DataOutputStream(crcStream); FilterFactory.serialize(bloomFilter, stream); long crcValue = crcStream.getValue(); stream.writeLong(crcValue); } }

Target:
void map(boolean persistBloom) throws IOException, StoreException { RandomAccessFile raf = new RandomAccessFile(indexFile, "r"); rwLock.writeLock().lock(); try { mmap = raf.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, indexFile.length()); mmap.position(0); version = mmap.getShort(); indexSizeExcludingEntries = VERSION_FIELD_LENGTH + KEY_SIZE_FIELD_LENGTH + VALUE_SIZE_FIELD_LENGTH + LOG_END_OFFSET_FIELD_LENGTH + CRC_FIELD_LENGTH; switch (version) { case 0: keySize = mmap.getInt(); valueSize = mmap.getInt(); endOffset.set(new Offset(startOffset.getName(), mmap.getLong())); lastModifiedTimeSec.set(indexFile.lastModified() / 1000); firstKeyRelativeOffset = indexSizeExcludingEntries - CRC_FIELD_LENGTH; break; case 1: keySize = mmap.getInt(); valueSize = mmap.getInt(); endOffset.set(new Offset(startOffset.getName(), mmap.getLong())); lastModifiedTimeSec.set(mmap.getLong()); StoreKey storeKey = factory.getStoreKey(new DataInputStream(new ByteBufferInputStream(mmap))); short resetKeyType = mmap.getShort(); resetKey = new Pair<>(storeKey, PersistentIndex.IndexEntryType.values()[resetKeyType]); indexSizeExcludingEntries += (LAST_MODIFIED_TIME_FIELD_LENGTH + resetKey.getFirst().sizeInBytes() + RESET_KEY_TYPE_FIELD_LENGTH); firstKeyRelativeOffset = indexSizeExcludingEntries - CRC_FIELD_LENGTH; break; default: throw new StoreException("IndexSegment : " + indexFile.getAbsolutePath() + " unknown version in index file", StoreErrorCodes.Index_Version_Error); } mapped.set(true); index = null; } finally { raf.close(); rwLock.writeLock().unlock(); } if (persistBloom) { CrcOutputStream crcStream = new CrcOutputStream(new FileOutputStream(bloomFile)); DataOutputStream stream = new DataOutputStream(crcStream); FilterFactory.serialize(bloomFilter, stream); long crcValue = crcStream.getValue(); stream.writeLong(crcValue); } }