Source:
void addEntry(IndexEntry entry, Offset fileEndOffset) throws StoreException { try { rwLock.readLock().lock(); if (mapped.get()) { throw new StoreException("IndexSegment : " + indexFile.getAbsolutePath() + " cannot add to a mapped index ", StoreErrorCodes.Illegal_Index_Operation); } logger.trace("IndexSegment inserting key - value - offset size ttl " + "originalMessageOffset fileEndOffset {}", indexFile.getAbsolutePath(), entry.getKey(), entry.getValue().getOffset(), entry.getValue().getSize(), entry.getValue().getExpiresAtMs(), entry.getValue().getOriginalMessageOffset(), fileEndOffset); if (index.put(entry.getKey(), entry.getValue()) == null) { numberOfItems.incrementAndGet(); sizeWritten.addAndGet(entry.getKey().sizeInBytes() + entry.getValue().getBytes().capacity()); bloomFilter.add(ByteBuffer.wrap(entry.getKey().toBytes())); if (resetKey == null) { resetKey = new Pair<>(entry.getKey(), entry.getValue().isFlagSet(IndexValue.Flags.Delete_Index) ? PersistentIndex.IndexEntryType.DELETE : PersistentIndex.IndexEntryType.PUT); } } endOffset.set(fileEndOffset); lastModifiedTimeSec.set(time.seconds()); if (keySize == KEY_SIZE_INVALID_VALUE) { StoreKey key = entry.getKey(); keySize = key.sizeInBytes(); logger.info("IndexSegment : setting key size to of key for index with start offset {}", indexFile.getAbsolutePath(), key.sizeInBytes(), key.getLongForm(), startOffset); } if (valueSize == VALUE_SIZE_INVALID_VALUE) { valueSize = entry.getValue().getBytes().capacity(); logger.info("IndexSegment : setting value size to for index with start offset {}", indexFile.getAbsolutePath(), valueSize, startOffset); } } finally { rwLock.readLock().unlock(); } }

Target:
void addEntry(IndexEntry entry, Offset fileEndOffset) throws StoreException { try { rwLock.readLock().lock(); if (mapped.get()) { throw new StoreException("IndexSegment : " + indexFile.getAbsolutePath() + " cannot add to a mapped index ", StoreErrorCodes.Illegal_Index_Operation); } logger.trace("IndexSegment inserting key - value - offset size ttl " + "originalMessageOffset fileEndOffset {}", indexFile.getAbsolutePath(), entry.getKey(), entry.getValue().getOffset(), entry.getValue().getSize(), entry.getValue().getExpiresAtMs(), entry.getValue().getOriginalMessageOffset(), fileEndOffset); if (index.put(entry.getKey(), entry.getValue()) == null) { numberOfItems.incrementAndGet(); sizeWritten.addAndGet(entry.getKey().sizeInBytes() + entry.getValue().getBytes().capacity()); bloomFilter.add(ByteBuffer.wrap(entry.getKey().toBytes())); if (resetKey == null) { resetKey = new Pair<>(entry.getKey(), entry.getValue().isFlagSet(IndexValue.Flags.Delete_Index) ? PersistentIndex.IndexEntryType.DELETE : PersistentIndex.IndexEntryType.PUT); } } endOffset.set(fileEndOffset); long operationTimeInMs = entry.getValue().getOperationTimeInMs(); if (operationTimeInMs == Utils.Infinite_Time) { lastModifiedTimeSec.set(time.seconds()); } else if ((operationTimeInMs / Time.MsPerSec) > lastModifiedTimeSec.get()) { lastModifiedTimeSec.set(operationTimeInMs / Time.MsPerSec); } if (keySize == KEY_SIZE_INVALID_VALUE) { StoreKey key = entry.getKey(); keySize = key.sizeInBytes(); logger.info("IndexSegment : setting key size to of key for index with start offset {}", indexFile.getAbsolutePath(), key.sizeInBytes(), key.getLongForm(), startOffset); } if (valueSize == VALUE_SIZE_INVALID_VALUE) { valueSize = entry.getValue().getBytes().capacity(); logger.info("IndexSegment : setting value size to for index with start offset {}", indexFile.getAbsolutePath(), valueSize, startOffset); } } finally { rwLock.readLock().unlock(); } }