michaeljmarshall commented on code in PR #4196:
URL: https://github.com/apache/cassandra/pull/4196#discussion_r2141130378
##########
src/java/org/apache/cassandra/index/sai/memory/MemtableIndexManager.java:
##########
@@ -134,47 +127,15 @@ public MemtableIndex
getPendingMemtableIndex(LifecycleNewTracker tracker)
.orElse(null);
}
- public KeyRangeIterator searchMemtableIndexes(QueryContext queryContext,
Expression e, AbstractBounds<PartitionPosition> keyRange)
- {
- Collection<MemtableIndex> memtableIndexes =
liveMemtableIndexMap.values();
-
- if (memtableIndexes.isEmpty())
- {
- return KeyRangeIterator.empty();
- }
-
- KeyRangeIterator.Builder builder =
KeyRangeUnionIterator.builder(memtableIndexes.size());
-
- for (MemtableIndex memtableIndex : memtableIndexes)
- {
- builder.add(memtableIndex.search(queryContext, e, keyRange));
- }
-
- return builder.build();
- }
-
- public KeyRangeIterator limitToTopResults(QueryContext context,
List<PrimaryKey> source, Expression e)
+ public long liveMemtableWriteCount()
{
- Collection<MemtableIndex> memtables = liveMemtableIndexMap.values();
-
- if (memtables.isEmpty())
- {
- return KeyRangeIterator.empty();
- }
-
- KeyRangeUnionIterator.Builder builder =
KeyRangeUnionIterator.builder(memtables.size());
-
- for (MemtableIndex index : memtables)
- {
- builder.add(index.limitToTopResults(source, e,
context.vectorContext().limit()));
- }
-
- return builder.build();
+ return
liveMemtableIndexMap.values().stream().mapToLong(MemtableIndex::writeCount).sum();
}
- public long liveMemtableWriteCount()
+ public Collection<MemtableIndex> getLiveMemtableIndexes()
{
- return
liveMemtableIndexMap.values().stream().mapToLong(MemtableIndex::writeCount).sum();
+ // Copy the values. Otherwise, we'll only have a view of the map's
values which is subject to change.
+ return new ArrayList<>(liveMemtableIndexMap.values());
Review Comment:
Good suggestions. I will do both.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]