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


##########
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:
   Because, as I described above, a SegmentInfo can be both a prefix tombstone 
and contain data (i.e. `firstLogIndexInclusive != -1`). In other words, we can 
have a "pure" prefix tombstone, that is a SegmentInfo with no data 
(`firstLogIndexInclusive == -1 && firstIndexKept != -1`) and a regular 
SegmentInfo that is also a tombstone (`firstLogIndexInclusive != -1 && 
firstIndexKept != -1`). This looks cryptic, but I don't know how to make it 
clearer in the code =(
   
   In this case we just check a condition that this is a "pure" tombstone, 
because we can't have a situation when `firstLogIndexInclusive == -1 && 
firstIndexKept == -1`.



-- 
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