Skip to content

Commit

Permalink
HBASE-25277 postScannerFilterRow impacts Scan performance a lot in HB…
Browse files Browse the repository at this point in the history
…ase 2.x (apache#2765)

Signed-off-by: Guanghao Zhang <zghao@apache.org>
(cherry picked from commit 4cd6047)

Change-Id: I4f94ed20ca6d698e1a5bef221a8efd39192a1cb9
  • Loading branch information
pankaj72981 committed Jan 4, 2021
1 parent a46dd73 commit 8cc9315
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 32 deletions.
Expand Up @@ -22,20 +22,19 @@
import java.util.List;
import java.util.Optional;

import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessor;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.RegionObserver;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.wal.WALEdit;
import org.apache.yetus.audience.InterfaceAudience;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/***
* Processes multiple {@link Constraint Constraints} on a given table.
Expand Down Expand Up @@ -98,11 +97,4 @@ public void prePut(ObserverContext<RegionCoprocessorEnvironment> e, Put put,
}
// if we made it here, then the Put is valid
}

@Override
public boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> e,
final InternalScanner s, final Cell curRowCell, final boolean hasMore) throws IOException {
// 'default' in RegionObserver might do unnecessary copy for Off heap backed Cells.
return hasMore;
}
}
Expand Up @@ -105,6 +105,13 @@ public class RegionCoprocessorHost
// optimization: no need to call postScannerFilterRow, if no coprocessor implements it
private final boolean hasCustomPostScannerFilterRow;

/*
* Whether any configured CPs override postScannerFilterRow hook
*/
public boolean hasCustomPostScannerFilterRow() {
return hasCustomPostScannerFilterRow;
}

/**
*
* Encapsulation of the environment of each coprocessor
Expand Down Expand Up @@ -278,11 +285,10 @@ public RegionCoprocessorHost(final HRegion region,
out: for (RegionCoprocessorEnvironment env: coprocEnvironments) {
if (env.getInstance() instanceof RegionObserver) {
Class<?> clazz = env.getInstance().getClass();
for(;;) {
if (clazz == null) {
// we must have directly implemented RegionObserver
hasCustomPostScannerFilterRow = true;
break out;
for (;;) {
if (clazz == Object.class) {
// we dont need to look postScannerFilterRow into Object class
break; // break the inner loop
}
try {
clazz.getDeclaredMethod("postScannerFilterRow", ObserverContext.class,
Expand Down
Expand Up @@ -1877,13 +1877,6 @@ public void postScannerClose(final ObserverContext<RegionCoprocessorEnvironment>
scannerOwners.remove(s);
}

@Override
public boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> e,
final InternalScanner s, final Cell curRowCell, final boolean hasMore) throws IOException {
// 'default' in RegionObserver might do unnecessary copy for Off heap backed Cells.
return hasMore;
}

/**
* Verify, when servicing an RPC, that the caller is the scanner owner.
* If so, we assume that access control is correctly enforced based on
Expand Down
Expand Up @@ -741,13 +741,6 @@ private Cell createNewCellWithTags(Mutation mutation, Cell newCell) throws IOExc
return PrivateCellUtil.createCell(newCell, tags);
}

@Override
public boolean postScannerFilterRow(final ObserverContext<RegionCoprocessorEnvironment> e,
final InternalScanner s, final Cell curRowCell, final boolean hasMore) throws IOException {
// 'default' in RegionObserver might do unnecessary copy for Off heap backed Cells.
return hasMore;
}

/****************************** VisibilityEndpoint service related methods ******************************/
@Override
public synchronized void addLabels(RpcController controller, VisibilityLabelsRequest request,
Expand Down
Expand Up @@ -37,6 +37,7 @@
import org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost;
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
import org.apache.hadoop.hbase.testclassification.SmallTests;

import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand Down

0 comments on commit 8cc9315

Please sign in to comment.