下面列出了org.apache.hadoop.hbase.HConstants#DEFAULT_HBASE_CLIENT_SCANNER_CACHING 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Constructor
* This is for internal testing purpose (using the default value).
* In real usage, we should read the configuration from the Configuration object.
*/
@VisibleForTesting
protected ConnectionConfiguration() {
this.writeBufferSize = WRITE_BUFFER_SIZE_DEFAULT;
this.writeBufferPeriodicFlushTimeoutMs = WRITE_BUFFER_PERIODIC_FLUSH_TIMEOUT_MS_DEFAULT;
this.writeBufferPeriodicFlushTimerTickMs = WRITE_BUFFER_PERIODIC_FLUSH_TIMERTICK_MS_DEFAULT;
this.metaOperationTimeout = HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT;
this.operationTimeout = HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT;
this.scannerCaching = HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING;
this.scannerMaxResultSize = HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE;
this.primaryCallTimeoutMicroSecond = 10000;
this.replicaCallTimeoutMicroSecondScan = 1000000;
this.metaReplicaCallTimeoutMicroSecondScan =
HConstants.HBASE_CLIENT_META_REPLICA_SCAN_TIMEOUT_DEFAULT;
this.retries = HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER;
this.clientScannerAsyncPrefetch = Scan.DEFAULT_HBASE_CLIENT_SCANNER_ASYNC_PREFETCH;
this.maxKeyValueSize = MAX_KEYVALUE_SIZE_DEFAULT;
this.readRpcTimeout = HConstants.DEFAULT_HBASE_RPC_TIMEOUT;
this.writeRpcTimeout = HConstants.DEFAULT_HBASE_RPC_TIMEOUT;
this.rpcTimeout = HConstants.DEFAULT_HBASE_RPC_TIMEOUT;
}
public int getScanCacheSize() {
if (options != null) {
if (options.getScanCacheSize() != HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING) {
return options.getScanCacheSize();
}
}
// Need to get default from config.
return 10000;
}
private Object getValue(
final Aggregation aggregation,
final Filter filter,
final DataTypeAdapter dataAdapter,
final Short internalAdapterId,
final HBaseDistributableFilter hdFilter,
final boolean blockCaching,
final int scanCacheSize,
final String[] authorizations) throws IOException {
final Scan scan = new Scan();
scan.setMaxVersions(1);
scan.setCacheBlocks(blockCaching);
if (scanCacheSize != HConstants.DEFAULT_HBASE_CLIENT_SCANNER_CACHING) {
scan.setCaching(scanCacheSize);
}
if (filter != null) {
scan.setFilter(filter);
}
if (internalAdapterId != null) {
scan.addFamily(StringUtils.stringToBinary(ByteArrayUtils.shortToString(internalAdapterId)));
}
if (authorizations != null) {
scan.setAuthorizations(new Authorizations(authorizations));
}
env.getRegion().getCoprocessorHost().preScannerOpen(scan);
try (InternalScanner scanner = env.getRegion().getScanner(scan)) {
final List<Cell> results = new ArrayList<>();
boolean hasNext;
do {
hasNext = scanner.next(results);
if (!results.isEmpty()) {
if (hdFilter != null) {
if (dataAdapter != null) {
final Object row = hdFilter.decodeRow(dataAdapter);
if (row != null) {
aggregation.aggregate(row);
} else {
LOGGER.error("DataAdapter failed to decode row");
}
} else {
aggregation.aggregate(hdFilter.getPersistenceEncoding());
}
} else {
aggregation.aggregate(null);
}
results.clear();
}
} while (hasNext);
}
return aggregation.getResult();
}