keith-turner commented on code in PR #5497: URL: https://github.com/apache/accumulo/pull/5497#discussion_r2056276622
########## server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java: ########## @@ -274,12 +274,7 @@ void writeBuffer(String destPath, List<Pair<LogFileKey,LogFileValue>> buffer, in var logFileKey = pair.getFirst(); var logFileValue = pair.getSecond(); Key k = logFileKey.toKey(); - var list = keyListMap.putIfAbsent(k, logFileValue.mutations); - if (list != null) { - var muts = new ArrayList<>(list); - muts.addAll(logFileValue.mutations); - keyListMap.put(logFileKey.toKey(), muts); - } + keyListMap.computeIfAbsent(k, (key) -> new ArrayList<>()).addAll(logFileValue.mutations); Review Comment: Seems like this code was attempting to avoid any copy when the key was only seen once. However when a key was seen more than once it would keep copying. Wondering if we can efficiently accomplish the following in some way. 1. The first time a key is seen put a reference to the list in the map w/o copy 2. The second time a key is seen, copy the list and then append 3. The third or later time a keys is seen append to list and do not copy. I was able to create a test that reproduces this problem. Will post that in another cmment and try this change w/ the test. -- 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: notifications-unsubscr...@accumulo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org