Refine search
public static Pair<byte[], byte[]> getMinMaxRowIds(Connector connector, AccumuloTable table, Authorizations auths) throws TableNotFoundException { Scanner scanner = connector.createScanner(table.getMetricsTableName(), auths); scanner.setRange(new Range(new Text(Indexer.METRICS_TABLE_ROW_ID.array()))); Text family = new Text(Indexer.METRICS_TABLE_ROWS_CF.array()); Text firstRowQualifier = new Text(Indexer.METRICS_TABLE_FIRST_ROW_CQ.array()); Text lastRowQualifier = new Text(Indexer.METRICS_TABLE_LAST_ROW_CQ.array()); scanner.fetchColumn(family, firstRowQualifier); scanner.fetchColumn(family, lastRowQualifier); byte[] firstRow = null; byte[] lastRow = null; for (Entry<Key, Value> entry : scanner) { if (entry.getKey().compareColumnQualifier(firstRowQualifier) == 0) { firstRow = entry.getValue().get(); } if (entry.getKey().compareColumnQualifier(lastRowQualifier) == 0) { lastRow = entry.getValue().get(); } } scanner.close(); return Pair.of(firstRow, lastRow); }
scan.fetchColumnFamily(new Text(Indexer.getIndexColumnFamily(constraintEntry.getKey().getFamily().getBytes(), constraintEntry.getKey().getQualifier().getBytes()).array())); Text tmpQualifier = new Text(); Set<Range> columnRanges = new HashSet<>(); for (Entry<Key, Value> entry : scan) { columnRanges.add(new Range(tmpQualifier));
/** * Gets a scanner from Accumulo over one row. * * @param row the row to scan * @param fields the set of columns to scan * @return an Accumulo {@link Scanner} bound to the given row and columns */ private Scanner getRow(String table, Text row, Set<String> fields) throws TableNotFoundException { Scanner scanner = connector.createScanner(table, Authorizations.EMPTY); scanner.setRange(new Range(row)); if (fields != null) { for (String field : fields) { scanner.fetchColumn(colFam, new Text(field)); } } return scanner; }
/** * Gets a scanner from Accumulo over one row. * * @param row the row to scan * @param fields the set of columns to scan * @return an Accumulo {@link Scanner} bound to the given row and columns */ private Scanner getRow(String table, Text row, Set<String> fields) throws TableNotFoundException { Scanner scanner = connector.createScanner(table, Authorizations.EMPTY); scanner.setRange(new Range(row)); if (fields != null) { for (String field : fields) { scanner.fetchColumn(colFam, new Text(field)); } } return scanner; }
/** * Gets a scanner from Accumulo over one row. * * @param row the row to scan * @param fields the set of columns to scan * @return an Accumulo {@link Scanner} bound to the given row and columns */ private Scanner getRow(String table, Text row, Set<String> fields) throws TableNotFoundException { Scanner scanner = connector.createScanner(table, Authorizations.EMPTY); scanner.setRange(new Range(row)); if (fields != null) { for (String field : fields) { scanner.fetchColumn(colFam, new Text(field)); } } return scanner; }
private Optional<String> getDefaultTabletLocation(String fulltable) { try { String tableId = connector.tableOperations().tableIdMap().get(fulltable); // Create a scanner over the metadata table, fetching the 'loc' column of the default tablet row Scanner scan = connector.createScanner("accumulo.metadata", connector.securityOperations().getUserAuthorizations(username)); scan.fetchColumnFamily(new Text("loc")); scan.setRange(new Range(tableId + '<')); // scan the entry Optional<String> location = Optional.empty(); for (Entry<Key, Value> entry : scan) { if (location.isPresent()) { throw new PrestoException(FUNCTION_IMPLEMENTATION_ERROR, "Scan for default tablet returned more than one entry"); } location = Optional.of(entry.getValue().toString()); } scan.close(); return location; } catch (Exception e) { // Swallow this exception so the query does not fail due to being unable to locate the tablet server for the default tablet. // This is purely an optimization, but we will want to log the error. LOG.error("Failed to get tablet location, returning dummy location", e); return Optional.empty(); } }
accumuloRange = new Range(); Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getSingleValue())); accumuloRange = new Range(split); Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue())); accumuloRange = new Range(null, false, split, inclusive); Text split = new Text(serializer.encode(prestoRange.getType(), prestoRange.getLow().getValue())); accumuloRange = new Range(split, inclusive, null, false); Text endSplit = new Text(serializer.encode(prestoRange.getType(), prestoRange.getHigh().getValue())); accumuloRange = new Range(startSplit, startKeyInclusive, endSplit, endKeyInclusive);
public OfflineScanner(ClientContext context, Table.ID tableId, Authorizations authorizations) { checkArgument(context != null, "context is null"); checkArgument(tableId != null, "tableId is null"); checkArgument(authorizations != null, "authorizations is null"); this.context = context; this.tableId = new Text(tableId.getUtf8()); this.range = new Range((Key) null, (Key) null); this.authorizations = authorizations; this.batchSize = Constants.SCAN_BATCH_SIZE; }
protected Range getRangeForTrace(long minutesSince) { long endTime = System.currentTimeMillis(); long millisSince = minutesSince * 60 * 1000; // Catch the overflow if (millisSince < minutesSince) { millisSince = endTime; } long startTime = endTime - millisSince; String startHexTime = Long.toHexString(startTime), endHexTime = Long.toHexString(endTime); if (startHexTime.length() < endHexTime.length()) { StringUtils.leftPad(startHexTime, endHexTime.length(), '0'); } return new Range(new Text("start:" + startHexTime), new Text("start:" + endHexTime)); }
private static Text findInitialEnd(Scanner scanner) { Text end = new Text(new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff}); scanner.setRange(new Range(end, null)); while (scanner.iterator().hasNext()) { Text t = new Text(); t.append(end.getBytes(), 0, end.getLength()); t.append(end.getBytes(), 0, end.getLength()); end = t; scanner.setRange(new Range(end, null)); } return end; }
protected Range getRange(final CommandLine cl, final ScanInterpreter formatter) throws UnsupportedEncodingException { if ((cl.hasOption(OptUtil.START_ROW_OPT) || cl.hasOption(OptUtil.END_ROW_OPT)) && cl.hasOption(scanOptRow.getOpt())) { // did not see a way to make commons cli do this check... it has mutually exclusive options // but does not support the or throw new IllegalArgumentException("Options -" + scanOptRow.getOpt() + " AND (-" + OptUtil.START_ROW_OPT + " OR -" + OptUtil.END_ROW_OPT + ") are mutally exclusive "); } if (cl.hasOption(scanOptRow.getOpt())) { return new Range(formatter .interpretRow(new Text(cl.getOptionValue(scanOptRow.getOpt()).getBytes(Shell.CHARSET)))); } else { Text startRow = OptUtil.getStartRow(cl); if (startRow != null) startRow = formatter.interpretBeginRow(startRow); Text endRow = OptUtil.getEndRow(cl); if (endRow != null) endRow = formatter.interpretEndRow(endRow); final boolean startInclusive = !cl.hasOption(optStartRowExclusive.getOpt()); final boolean endInclusive = !cl.hasOption(optEndRowExclusive.getOpt()); return new Range(startRow, startInclusive, endRow, endInclusive); } }
private Iterator<Entry<Key,Value>> getIter2() { if (iter2 == null) { try { if ((table == null || !isMeta(table)) && iter1Count == 0) { Scanner scanner = context.createScanner(MetadataTable.NAME, Authorizations.EMPTY); scanner.setTimeout(3, TimeUnit.SECONDS); if (table == null) { scanner.setRange(new Range(new Text("~err_"), false, new Text("~err`"), false)); } else { scanner.setRange(new Range(new Text("~err_" + table))); } iter2 = scanner.iterator(); } else { Map<Key,Value> m = Collections.emptyMap(); iter2 = m.entrySet().iterator(); } } catch (Exception e) { throw new RuntimeException(e); } } return iter2; }
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; }
private static int listSpans(Opts opts, ScannerOpts scanOpts) throws Exception { PrintStream out = System.out; long endTime = System.currentTimeMillis(); long startTime = endTime - opts.length; try (AccumuloClient client = opts.createClient()) { Scanner scanner = client.createScanner(opts.getTableName(), opts.auths); scanner.setBatchSize(scanOpts.scanBatchSize); Range range = new Range(new Text("start:" + Long.toHexString(startTime)), new Text("start:" + Long.toHexString(endTime))); scanner.setRange(range); out.println("Trace Day/Time (ms) Start"); for (Entry<Key,Value> entry : scanner) { RemoteSpan span = TraceFormatter.getRemoteSpan(entry); out.println(String.format("%016x %s %5d %s", span.traceId, TraceFormatter.formatDate(new Date(span.getStart())), span.stop - span.start, span.description)); } } return 0; }
ranges = new ArrayList<>(); for (int i = 0; i < rangeSize; i++) { Range range = new Range(); range.readFields(dataInput); ranges.add(range); for (int i = 0; i < columnSize; i++) { long numPairs = dataInput.readInt(); Text colFam = new Text(); colFam.readFields(dataInput); if (numPairs == 1) { columns.add(new Pair<>(colFam, null)); } else if (numPairs == 2) { Text colQual = new Text(); colQual.readFields(dataInput); columns.add(new Pair<>(colFam, colQual));