@Override public void close() { scanner.close(); nanoEnd = System.nanoTime(); }
scan.close(); return columnRanges; }));
scanner.close();
/** * Loads the cardinality for the given Range. Uses a BatchScanner and sums the cardinality for all values that encapsulate the Range. * * @param key Range to get the cardinality for * @return The cardinality of the column, which would be zero if the value does not exist */ @Override public Long load(CacheKey key) throws Exception { LOG.debug("Loading a non-exact range from Accumulo: %s", key); // Get metrics table name and the column family for the scanner String metricsTable = getMetricsTableName(key.getSchema(), key.getTable()); Text columnFamily = new Text(getIndexColumnFamily(key.getFamily().getBytes(UTF_8), key.getQualifier().getBytes(UTF_8)).array()); // Create scanner for querying the range BatchScanner scanner = connector.createBatchScanner(metricsTable, key.auths, 10); scanner.setRanges(connector.tableOperations().splitRangeByTablets(metricsTable, key.range, Integer.MAX_VALUE)); scanner.fetchColumn(columnFamily, CARDINALITY_CQ_AS_TEXT); try { return stream(scanner) .map(Entry::getValue) .map(Value::toString) .mapToLong(Long::parseLong) .sum(); } finally { scanner.close(); } }
@Override public void close() { if (iter != null) { mdScanner.close(); iter = null; } }
public Set<Path> getPendingReplicationPaths() { final Set<Path> paths = new HashSet<>(); // Read over the queued work BatchScanner bs; try { bs = context.createBatchScanner(ReplicationTable.NAME, Authorizations.EMPTY, 4); } catch (TableNotFoundException e) { log.debug("No replication table exists", e); return paths; } bs.setRanges(Collections.singleton(new Range())); StatusSection.limit(bs); try { Text buffer = new Text(); for (Entry<Key,Value> entry : bs) { Key k = entry.getKey(); k.getRow(buffer); paths.add(new Path(buffer.toString())); } } finally { bs.close(); } return paths; }
MetaDataTableScanner(ClientContext context, Range range, CurrentState state, String tableName) { // scan over metadata table, looking for tablets in the wrong state based on the live servers // and online tables try { mdScanner = context.createBatchScanner(tableName, Authorizations.EMPTY, 8); configureScanner(mdScanner, state); mdScanner.setRanges(Collections.singletonList(range)); iter = mdScanner.iterator(); } catch (Exception ex) { if (mdScanner != null) mdScanner.close(); iter = null; mdScanner = null; throw new RuntimeException(ex); } }
} finally { if (bs != null) { bs.close();
printRecords(cl, shellState, config, scanner, formatter, printFile); } finally { scanner.close();
} finally { if (bs != null) { bs.close();
log.debug("Finished updating files with completed replication work"); bs.close();
public void close() { if (bs != null) { bs.close(); } }
@Override public void close() { if (iter != null) { mdScanner.close(); iter = null; } }
@Override protected void doClose() throws IOException { if (scanner instanceof BatchScanner) ((BatchScanner)scanner).close(); }
@Override public void onRemoval(RemovalNotification<UUID,ScannerPlusIterator> notification) { final ScannerBase base = notification.getValue().scanner; if (base instanceof BatchScanner) { final BatchScanner scanner = (BatchScanner) base; scanner.close(); } }
private void verify(Connector c, String tableName, ByteArraySet nss, String... expected) throws Exception { Scanner scanner = c.createScanner(tableName, new Authorizations(nss)); verify(scanner.iterator(), expected); BatchScanner bs = getConnector().createBatchScanner(tableName, new Authorizations(nss), 3); bs.setRanges(Collections.singleton(new Range())); verify(bs.iterator(), expected); bs.close(); }