ibessonov commented on code in PR #6753:
URL: https://github.com/apache/ignite-3/pull/6753#discussion_r2440275852
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexMemTable.java:
##########
@@ -64,6 +64,22 @@ public SegmentInfo segmentInfo(long groupId) {
return stripe(groupId).memTable.get(groupId);
}
+ @Override
+ public void truncateSuffix(long groupId, long lastLogIndexKept) {
+ ConcurrentMap<Long, SegmentInfo> memtable = stripe(groupId).memTable;
+
+ SegmentInfo segmentInfo = memtable.get(groupId);
+
+ if (segmentInfo == null || lastLogIndexKept <
segmentInfo.firstLogIndexInclusive()) {
+ // If the current memtable does not have information for the given
group or if we are truncating everything currently present
+ // in the memtable, we need to write a special "empty" SegmentInfo
into the memtable to override existing persisted data during
+ // search.
+ memtable.put(groupId, new SegmentInfo(lastLogIndexKept + 1));
Review Comment:
Ok, I see.
> I wanted to emphasize in this comment that this SegmentInfo is special
My point is - why does it matter? Why can't existing method process the
special case? You may leave this comment intact, but in my opinion it does not
explain enough
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/IndexMemTable.java:
##########
@@ -64,6 +64,22 @@ public SegmentInfo segmentInfo(long groupId) {
return stripe(groupId).memTable.get(groupId);
}
+ @Override
+ public void truncateSuffix(long groupId, long lastLogIndexKept) {
+ ConcurrentMap<Long, SegmentInfo> memtable = stripe(groupId).memTable;
+
+ SegmentInfo segmentInfo = memtable.get(groupId);
+
+ if (segmentInfo == null || lastLogIndexKept <
segmentInfo.firstLogIndexInclusive()) {
+ // If the current memtable does not have information for the given
group or if we are truncating everything currently present
+ // in the memtable, we need to write a special "empty" SegmentInfo
into the memtable to override existing persisted data during
+ // search.
+ memtable.put(groupId, new SegmentInfo(lastLogIndexKept + 1));
Review Comment:
Ok, I see.
> I wanted to emphasize in this comment that this SegmentInfo is special
My point is - why does it matter? Why can't existing method process the
special case? You may leave this comment intact, but in my opinion it does not
explain enough
--
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]