Github user sbroeder commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/1206#discussion_r133306960
--- Diff: core/sql/src/main/java/org/trafodion/sql/HBaseClient.java ---
@@ -1395,6 +1422,169 @@ private boolean estimateRowCountBody(String
tblName, int partialRowSize,
return true;
}
+ // Similar to estimateRowCount, except that the implementation
+ // uses a coprocessor. This is necessary when HBase encryption is
+ // in use, because the Trafodion ID does not have the proper
+ // authorization to the KeyStore file used by HBase.
+ public boolean estimateRowCountViaCoprocessor(String tblName, int
partialRowSize,
+ int numCols, int
retryLimitMilliSeconds, long[] rc)
+ throws ServiceException, IOException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("HBaseClient.estimateRowCountViaCoprocessor(" +
tblName + ") called.");
+ logger.debug("numCols = " + numCols + ", partialRowSize = " +
partialRowSize);
+ }
+
+ boolean retcode = true;
+ rc[0] = 0;
+
+ HConnection connection = null;
+ HTableInterface table = null;
+ connection = HConnectionManager.createConnection(config);
+ table = connection.getTable(tblName);
+
+ int putKVsSampled = 0;
+ int nonPutKVsSampled = 0;
+ int missingKVsCount = 0;
+ long totalEntries = 0; // KeyValues in all HFiles for table
+ long totalSizeBytes = 0; // Size of all HFiles for table
+
+ final int finalNumCols = numCols;
+
+ Batch.Call<TrxRegionService, TrafEstimateRowCountResponse> callable
=
+ new Batch.Call<TrxRegionService, TrafEstimateRowCountResponse>() {
+ ServerRpcController controller = new ServerRpcController();
+ BlockingRpcCallback<TrafEstimateRowCountResponse> rpcCallback =
+ new BlockingRpcCallback<TrafEstimateRowCountResponse>();
+
+ @Override
+ public TrafEstimateRowCountResponse call(TrxRegionService
instance) throws IOException {
+ if (logger.isDebugEnabled()) logger.debug("call method for
TrxRegionService was called");
+
+ // one of these God-awful long type identifiers common in
Java/Maven environments...
+
org.apache.hadoop.hbase.coprocessor.transactional.generated.TrxRegionProtos.TrafEstimateRowCountRequest.Builder
+ builder = TrafEstimateRowCountRequest.newBuilder();
+ builder.setNumCols(finalNumCols);
+
+ instance.trafEstimateRowCount(controller, builder.build(),
rpcCallback);
+ TrafEstimateRowCountResponse response = rpcCallback.get();
+ if (logger.isDebugEnabled()) {
+ if (response == null)
+ logger.debug("response was null");
+ else
+ logger.debug("response was non-null");
+ if (controller.failed())
+ logger.debug("controller.failed() is true");
+ else
+ logger.debug("controller.failed() is false");
+ if (controller.errorText() != null)
+ logger.debug("controller.errorText() is " +
controller.errorText());
+ else
+ logger.debug("controller.errorText() is null");
+ IOException ioe = controller.getFailedOn();
+ if (ioe != null)
+ logger.debug("controller.getFailedOn() returned " +
ioe.getMessage());
+ else
+ logger.debug("controller.getFailedOn() returned null");
+ }
+ return response;
+ }
+ };
+
+ Map<byte[], TrafEstimateRowCountResponse> result = null;
+ try {
+ result = table.coprocessorService(TrxRegionService.class, null,
null, callable);
+ } catch (Throwable e) {
+ throw new IOException("Exception from coprocessorService caught in
estimateRowCountViaCoprocessor",e);
+ }
+
+ for (TrafEstimateRowCountResponse response : result.values()) {
+ boolean hasException = response.getHasException();
--- End diff --
Yes, good point.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---