rpuch commented on code in PR #7101:
URL: https://github.com/apache/ignite-3/pull/7101#discussion_r2598664887


##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexFileManager.java:
##########
@@ -293,33 +301,76 @@ private byte[] 
serializeHeaderAndFillMetadata(ReadModeIndexMemTable indexMemTabl
 
             long lastLogIndexExclusive = segmentInfo.lastLogIndexExclusive();
 
+            long firstIndexKept = segmentInfo.firstIndexKept();
+
             // On recovery we are only creating missing index files, in-memory 
meta will be created on Index File Manager start.
             if (!onRecovery) {
-                var indexFileMeta = new IndexFileMeta(firstLogIndexInclusive, 
lastLogIndexExclusive, payloadOffset, fileOrdinal);
+                IndexFileMeta indexFileMeta = createIndexFileMeta(
+                        firstLogIndexInclusive, lastLogIndexExclusive, 
firstIndexKept, payloadOffset, fileOrdinal
+                );
 
-                putIndexFileMeta(groupId, indexFileMeta);
+                putIndexFileMeta(groupId, indexFileMeta, firstIndexKept);
             }
 
             headerBuffer
                     .putLong(groupId)
                     .putInt(0) // Flags.
                     .putInt(payloadOffset)
                     .putLong(firstLogIndexInclusive)
-                    .putLong(lastLogIndexExclusive);
+                    .putLong(lastLogIndexExclusive)
+                    .putLong(firstIndexKept);
 
             payloadOffset += payloadSize(segmentInfo);
         }
 
         return headerBuffer.array();
     }
 
-    private void putIndexFileMeta(Long groupId, IndexFileMeta indexFileMeta) {
+    private static @Nullable IndexFileMeta createIndexFileMeta(
+            long firstLogIndexInclusive,
+            long lastLogIndexExclusive,
+            long firstIndexKept,
+            int payloadOffset,
+            int fileOrdinal
+    ) {
+        if (firstLogIndexInclusive == -1) {
+            assert firstIndexKept != -1 : "Expected a prefix tombstone, but 
firstIndexKept is not set.";

Review Comment:
   I'm suggesting to extract a constant for -1 so that you can write
   
   `if (firstLogIndexInclusive == PREFIX_TOMBSTONE) {`
   
   Why isn't this possible?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to