HBASE-12077 FilterLists create many ArrayList objects per row (Lars Hofhansl)

Conflicts:
	hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
This commit is contained in:
Andrew Purtell 2014-09-24 11:12:21 -07:00
parent 1fbab729a3
commit 8ff5f2548a
1 changed files with 39 additions and 22 deletions

View File

@ -169,8 +169,9 @@ final public class FilterList extends Filter {
@Override
public void reset() throws IOException {
for (Filter filter : filters) {
filter.reset();
int listize = filters.size();
for (int i = 0; i < listize; i++) {
filters.get(i).reset();
}
seekHintFilter = null;
}
@ -178,7 +179,9 @@ final public class FilterList extends Filter {
@Override
public boolean filterRowKey(byte[] rowKey, int offset, int length) throws IOException {
boolean flag = (this.operator == Operator.MUST_PASS_ONE) ? true : false;
for (Filter filter : filters) {
int listize = filters.size();
for (int i = 0; i < listize; i++) {
Filter filter = filters.get(i);
if (this.operator == Operator.MUST_PASS_ALL) {
if (filter.filterAllRemaining() ||
filter.filterRowKey(rowKey, offset, length)) {
@ -196,8 +199,9 @@ final public class FilterList extends Filter {
@Override
public boolean filterAllRemaining() throws IOException {
for (Filter filter : filters) {
if (filter.filterAllRemaining()) {
int listize = filters.size();
for (int i = 0; i < listize; i++) {
if (filters.get(i).filterAllRemaining()) {
if (operator == Operator.MUST_PASS_ALL) {
return true;
}
@ -250,7 +254,9 @@ final public class FilterList extends Filter {
ReturnCode rc = operator == Operator.MUST_PASS_ONE?
ReturnCode.SKIP: ReturnCode.INCLUDE;
for (Filter filter : filters) {
int listize = filters.size();
for (int i = 0; i < listize; i++) {
Filter filter = filters.get(i);
if (operator == Operator.MUST_PASS_ALL) {
if (filter.filterAllRemaining()) {
return ReturnCode.NEXT_ROW;
@ -314,16 +320,18 @@ final public class FilterList extends Filter {
*/
@Override
public void filterRowCells(List<Cell> cells) throws IOException {
for (Filter filter : filters) {
filter.filterRowCells(cells);
int listize = filters.size();
for (int i = 0; i < listize; i++) {
filters.get(i).filterRowCells(cells);
}
}
@Override
public boolean hasFilterRow() {
for (Filter filter : filters) {
if(filter.hasFilterRow()) {
return true;
int listize = filters.size();
for (int i = 0; i < listize; i++) {
if (filters.get(i).hasFilterRow()) {
return true;
}
}
return false;
@ -331,7 +339,9 @@ final public class FilterList extends Filter {
@Override
public boolean filterRow() throws IOException {
for (Filter filter : filters) {
int listize = filters.size();
for (int i = 0; i < listize; i++) {
Filter filter = filters.get(i);
if (operator == Operator.MUST_PASS_ALL) {
if (filter.filterRow()) {
return true;
@ -352,8 +362,9 @@ final public class FilterList extends Filter {
FilterProtos.FilterList.Builder builder =
FilterProtos.FilterList.newBuilder();
builder.setOperator(FilterProtos.FilterList.Operator.valueOf(operator.name()));
for (Filter filter : filters) {
builder.addFilters(ProtobufUtil.toFilter(filter));
int listize = filters.size();
for (int i = 0; i < listize; i++) {
builder.addFilters(ProtobufUtil.toFilter(filters.get(i)));
}
return builder.build().toByteArray();
}
@ -375,8 +386,11 @@ final public class FilterList extends Filter {
List<Filter> rowFilters = new ArrayList<Filter>(proto.getFiltersCount());
try {
for (FilterProtos.Filter filter : proto.getFiltersList()) {
rowFilters.add(ProtobufUtil.toFilter(filter));
List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.Filter> filtersList =
proto.getFiltersList();
int listSize = filtersList.size();
for (int i = 0; i < listSize; i++) {
rowFilters.add(ProtobufUtil.toFilter(filtersList.get(i)));
}
} catch (IOException ioe) {
throw new DeserializationException(ioe);
@ -414,8 +428,9 @@ final public class FilterList extends Filter {
}
// If any condition can pass, we need to keep the min hint
for (Filter filter : filters) {
Cell curKeyHint = filter.getNextCellHint(currentKV);
int listize = filters.size();
for (int i = 0; i < listize; i++) {
Cell curKeyHint = filters.get(i).getNextCellHint(currentKV);
if (curKeyHint == null) {
// If we ever don't have a hint and this is must-pass-one, then no hint
return null;
@ -436,8 +451,9 @@ final public class FilterList extends Filter {
@Override
public boolean isFamilyEssential(byte[] name) throws IOException {
for (Filter filter : filters) {
if (filter.isFamilyEssential(name)) {
int listize = filters.size();
for (int i = 0; i < listize; i++) {
if (filters.get(i).isFamilyEssential(name)) {
return true;
}
}
@ -446,8 +462,9 @@ final public class FilterList extends Filter {
@Override
public void setReversed(boolean reversed) {
for (Filter filter : filters) {
filter.setReversed(reversed);
int listize = filters.size();
for (int i = 0; i < listize; i++) {
filters.get(i).setReversed(reversed);
}
this.reversed = reversed;
}