trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaveBirdsall <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #1206: [TRAFODION-2617] Optionally push est...
Date Tue, 15 Aug 2017 19:00:56 GMT
Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/1206#discussion_r133274008
  
    --- 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 --
    
    The code as written adds up the sizes of all the HFiles. I suppose we could assume that
all regions are the same size and just sample the first one. That might not be safe, though;
one region might have split while another hasn't yet.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message