wangweiming800 commented on a change in pull request #741: PHOENIX-5791 Eliminate false invalid row detection due to concurrent … URL: https://github.com/apache/phoenix/pull/741#discussion_r398344146
########## File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java ########## @@ -613,39 +605,132 @@ private boolean isDeleteFamilyVersion(Mutation mutation) { } return getMutationsWithSameTS(put, del); } + /** + * In this method, the actual list is repaired in memory using the expected list which is actually the output of + * rebuilding the index table row. The result of this repair is used only for verification. + */ + private void repairActualMutationList(List<Mutation> actualMutationList, List<Mutation> expectedMutationList) + throws IOException { + // Find the first (latest) actual unverified put mutation + for (Mutation actual : actualMutationList) { + if (actual instanceof Put && !isVerified((Put) actual)) { + long ts = getTimestamp(actual); + int expectedIndex; + int expectedListSize = expectedMutationList.size(); + for (expectedIndex = 0; expectedIndex < expectedListSize; expectedIndex++) { + if (getTimestamp(expectedMutationList.get(expectedIndex)) <= ts) { + if (expectedIndex > 0) { + expectedIndex--; + } + break; + } + } + if (expectedIndex == expectedListSize) { + continue; + } + for (; expectedIndex < expectedListSize; expectedIndex++) { + Mutation mutation = expectedMutationList.get(expectedIndex); + if (mutation instanceof Put) { + mutation = new Put((Put) mutation); + } else { + mutation = new Delete((Delete) mutation); + } + actualMutationList.add(mutation); Review comment: will it be a problem to modify the list when iterating it? https://stackoverflow.com/questions/6866238/concurrent-modification-exception-adding-to-an-arraylist https://www.baeldung.com/java-concurrentmodificationexception ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services