jt2594838 commented on code in PR #16531:
URL: https://github.com/apache/iotdb/pull/16531#discussion_r2596974834
##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/datastructure/pattern/IoTDBTreePattern.java:
##########
@@ -71,13 +68,29 @@ private String getDefaultPattern() {
public static <T> List<T> applyReversedIndexesOnList(
final List<Integer> filteredIndexes, final List<T> originalList) {
- final Set<Integer> indexes = new HashSet<>(filteredIndexes);
- return Objects.nonNull(originalList)
- ? IntStream.range(0, originalList.size())
- .filter(index -> !indexes.contains(index)) // 保留不在排除列表中的下标
- .mapToObj(originalList::get)
- .collect(Collectors.toList())
- : null;
+ // No need to sort, the caller guarantees that the filtered sequence ==
original sequence
+ final List<T> filteredList = new ArrayList<>(originalList.size() -
filteredIndexes.size());
+ int filteredIndexPos = 0;
+ int processingIndex = 0;
+ for (; processingIndex < originalList.size(); processingIndex++) {
+ if (filteredIndexPos >= filteredIndexes.size()) {
+ // all filteredIndexes processed, add remaining to the filteredList
+ if (processingIndex < filteredIndexes.size()) {
+ filteredList.addAll(originalList.subList(processingIndex,
originalList.size()));
+ }
+ break;
Review Comment:
if (filteredIndexPos >= filteredIndexes.size()) {
// all filteredIndexes processed, add remaining to the filteredList
filteredList.addAll(originalList.subList(processingIndex,
originalList.size()));
break;
}
--
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]