Github user JamesRTaylor commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/12#discussion_r17405826
--- Diff:
phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
---
@@ -1874,6 +1867,95 @@ private void
incrementSequenceValues(List<SequenceKey> keys, long timestamp, lon
}
}
+ @Override
+ public long updateStatistics(final byte[] tenantId, final byte[]
schemaName, final byte[] tableName, final String url)
+ throws SQLException {
+ HTableInterface ht = null;
+ try {
+ ht = this.getTable(tableName);
+ Batch.Call<StatCollectService, StatCollectResponse> callable =
new Batch.Call<StatCollectService, StatCollectResponse>() {
+ ServerRpcController controller = new ServerRpcController();
+ BlockingRpcCallback<StatCollectResponse> rpcCallback = new
BlockingRpcCallback<StatCollectResponse>();
+
+ @Override
+ public StatCollectResponse call(StatCollectService
service) throws IOException {
+ StatCollectRequest.Builder builder =
StatCollectRequest.newBuilder();
+
builder.setTableNameBytes(HBaseZeroCopyByteString.wrap(tableName));
+
builder.setTenantIdBytes(HBaseZeroCopyByteString.wrap(tenantId));
+
builder.setSchemaNameBytes(HBaseZeroCopyByteString.wrap(schemaName));
+ builder.setUrl(url);
+ service.collectStat(controller, builder.build(),
rpcCallback);
+ if (controller.getFailedOn() != null) { throw
controller.getFailedOn(); }
+ return rpcCallback.get();
+ }
+ };
+ Map<byte[], StatCollectResponse> result =
ht.coprocessorService(StatCollectService.class,
+ HConstants.EMPTY_BYTE_ARRAY,
HConstants.EMPTY_BYTE_ARRAY, callable);
+ StatCollectResponse next = result.values().iterator().next();
+ clearCacheForTable(tenantId, schemaName, tableName);
+ return next.getRowsScanned();
+ } catch (ServiceException e) {
+ throw new SQLException("Unable to update the statistics for
the table " + tableName, e);
+ } catch (TableNotFoundException e) {
--- End diff --
Just rethrow any SQLException here
---
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.
---