HBASE-21734 Some optimization in FilterListWithOR
This commit is contained in:
parent
f2820ea16f
commit
b0131e19f4
|
@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.filter;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
|
@ -49,7 +48,12 @@ public abstract class FilterListBase extends FilterBase {
|
|||
}
|
||||
|
||||
protected static boolean isInReturnCodes(ReturnCode testRC, ReturnCode... returnCodes) {
|
||||
return Arrays.stream(returnCodes).anyMatch(testRC::equals);
|
||||
for (ReturnCode rc : returnCodes) {
|
||||
if (testRC == rc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static boolean checkAndGetReversed(List<Filter> rowFilters, boolean defaultValue) {
|
||||
|
@ -57,10 +61,11 @@ public abstract class FilterListBase extends FilterBase {
|
|||
return defaultValue;
|
||||
}
|
||||
boolean retValue = rowFilters.get(0).isReversed();
|
||||
boolean allEqual = rowFilters.stream().allMatch(f -> f.isReversed() == retValue);
|
||||
if (!allEqual) {
|
||||
for (int i = 1, n = rowFilters.size(); i < n; i++) {
|
||||
if (rowFilters.get(i).isReversed() != retValue) {
|
||||
throw new IllegalArgumentException("Filters in the list must have the same reversed flag");
|
||||
}
|
||||
}
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.hadoop.hbase.filter;
|
|||
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CellUtil;
|
||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||
import org.apache.yetus.audience.InterfaceAudience;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -254,7 +253,7 @@ public class FilterListWithOR extends FilterListBase {
|
|||
// need not save current cell to prevCellList for saving heap memory.
|
||||
prevCellList.set(index, null);
|
||||
} else {
|
||||
prevCellList.set(index, KeyValueUtil.toNewKeyCell(currentCell));
|
||||
prevCellList.set(index, currentCell);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue