public TRowRange toThrift() { return new TRowRange(TextUtil.getByteBuffer(startRow), TextUtil.getByteBuffer(endRow)); }
public static Text truncate(Text row) { return truncate(row, Constants.MAX_DATA_TO_PRINT); } }
/** * Creates a column visibility for a Mutation. * * @param expression * visibility expression * @see #ColumnVisibility(String) */ public ColumnVisibility(Text expression) { this(TextUtil.getBytes(expression)); }
public TKeyExtent toThrift() { return new TKeyExtent(ByteBuffer.wrap(tableId.getUtf8()), textEndRow == null ? null : TextUtil.getByteBuffer(textEndRow), textPrevEndRow == null ? null : TextUtil.getByteBuffer(textPrevEndRow)); }
@Override public String toString() { String endRowString; String prevEndRowString; String tableIdString = getTableId().canonicalID().replaceAll(";", "\\\\;").replaceAll("\\\\", "\\\\\\\\"); if (getEndRow() == null) endRowString = "<"; else endRowString = ";" + TextUtil.truncate(getEndRow()).toString().replaceAll(";", "\\\\;") .replaceAll("\\\\", "\\\\\\\\"); if (getPrevEndRow() == null) prevEndRowString = "<"; else prevEndRowString = ";" + TextUtil.truncate(getPrevEndRow()).toString() .replaceAll(";", "\\\\;").replaceAll("\\\\", "\\\\\\\\"); return tableIdString + endRowString + prevEndRowString; }
@Override public void deleteRows(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); ByteBuffer EMPTY = ByteBuffer.allocate(0); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(UTF_8)), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY : TextUtil.getByteBuffer(end)); Map<String,String> opts = new HashMap<>(); try { doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_DELETE_RANGE, args, opts); } catch (TableExistsException e) { // should not happen throw new AssertionError(e); } }
@Override public TabletLocation locateTablet(ClientContext context, Text row, boolean skipRow, boolean retry) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { OpTimer timer = null; if (log.isTraceEnabled()) { log.trace("tid={} Locating tablet table={} row={} skipRow={} retry={}", Thread.currentThread().getId(), tableId, TextUtil.truncate(row), skipRow, retry); timer = new OpTimer().start(); } while (true) { LockCheckerSession lcSession = new LockCheckerSession(); TabletLocation tl = _locateTablet(context, row, skipRow, retry, true, lcSession); if (retry && tl == null) { sleepUninterruptibly(100, TimeUnit.MILLISECONDS); if (log.isTraceEnabled()) log.trace("Failed to locate tablet containing row {} in table {}, will retry...", TextUtil.truncate(row), tableId); continue; } if (timer != null) { timer.stop(); log.trace("tid={} Located tablet {} at {} in {}", Thread.currentThread().getId(), (tl == null ? "null" : tl.tablet_extent), (tl == null ? "null" : tl.tablet_location), String.format("%.3f secs", timer.scale(TimeUnit.SECONDS))); } return tl; } }
@Override public byte[] encode(Text data) { return TextUtil.getBytes(data); }
@Override public void merge(String tableName, Text start, Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException { checkArgument(tableName != null, "tableName is null"); ByteBuffer EMPTY = ByteBuffer.allocate(0); List<ByteBuffer> args = Arrays.asList(ByteBuffer.wrap(tableName.getBytes(UTF_8)), start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY : TextUtil.getByteBuffer(end)); Map<String,String> opts = new HashMap<>(); try { doTableFateOperation(tableName, TableNotFoundException.class, FateOperation.TABLE_MERGE, args, opts); } catch (TableExistsException e) { // should not happen throw new AssertionError(e); } }
Thread.currentThread().getId(), src.tablet_extent.getTableId(), TextUtil.truncate(row), src.tablet_extent, src.tablet_location); timer = new OpTimer().start();
@Override public void create(String tableName, NewTableConfiguration ntc) throws AccumuloException, AccumuloSecurityException, TableExistsException { checkArgument(tableName != null, "tableName is null"); checkArgument(ntc != null, "ntc is null"); List<ByteBuffer> args = new ArrayList<>(); args.add(ByteBuffer.wrap(tableName.getBytes(UTF_8))); args.add(ByteBuffer.wrap(ntc.getTimeType().name().getBytes(UTF_8))); // Send info relating to initial table creation i.e, create online or offline args.add(ByteBuffer.wrap(ntc.getInitialTableState().name().getBytes(UTF_8))); // Check for possible initial splits to be added at table creation // Always send number of initial splits to be created, even if zero. If greater than zero, // add the splits to the argument List which will be used by the FATE operations. int numSplits = ntc.getSplits().size(); args.add(ByteBuffer.wrap(String.valueOf(numSplits).getBytes(UTF_8))); if (numSplits > 0) { for (Text t : ntc.getSplits()) { args.add(TextUtil.getByteBuffer(t)); } } Map<String,String> opts = ntc.getProperties(); try { doTableFateOperation(tableName, AccumuloException.class, FateOperation.TABLE_CREATE, args, opts); } catch (TableNotFoundException e) { // should not happen throw new AssertionError(e); } }
public static Text truncate(Text row) { return truncate(row, Constants.MAX_DATA_TO_PRINT); } }
start == null ? EMPTY : TextUtil.getByteBuffer(start), end == null ? EMPTY : TextUtil.getByteBuffer(end), ByteBuffer.wrap(IteratorUtil.encodeIteratorSettings(config.getIterators())), ByteBuffer.wrap(CompactionStrategyConfigUtil.encode(config.getCompactionStrategy())));
@Override public String toString() { String endRowString; String prevEndRowString; String tableIdString = getTableId().replaceAll(";", "\\\\;").replaceAll("\\\\", "\\\\\\\\"); if (getEndRow() == null) endRowString = "<"; else endRowString = ";" + TextUtil.truncate(getEndRow()).toString().replaceAll(";", "\\\\;") .replaceAll("\\\\", "\\\\\\\\"); if (getPrevEndRow() == null) prevEndRowString = "<"; else prevEndRowString = ";" + TextUtil.truncate(getPrevEndRow()).toString() .replaceAll(";", "\\\\;").replaceAll("\\\\", "\\\\\\\\"); return tableIdString + endRowString + prevEndRowString; }
/** * @return encoded columns */ protected static String encodeColumns(Text[] columns) { StringBuilder sb = new StringBuilder(); for (Text column : columns) { sb.append(Base64.getEncoder().encodeToString(TextUtil.getBytes(column))); sb.append('\n'); } return sb.toString(); }
@Override public List<Summary> retrieve() throws AccumuloException, AccumuloSecurityException, TableNotFoundException { Table.ID tableId = Tables.getTableId(context, tableName); if (Tables.getTableState(context, tableId) == TableState.OFFLINE) throw new TableOfflineException(Tables.getTableOfflineMsg(context, tableId)); TRowRange range = new TRowRange(TextUtil.getByteBuffer(startRow), TextUtil.getByteBuffer(endRow)); TSummaryRequest request = new TSummaryRequest(tableId.canonicalID(), range, summariesToFetch, summarizerClassRegex); if (flush) { _flush(tableId, startRow, endRow, true); } TSummaries ret = ServerClient.execute(context, new TabletClientService.Client.Factory(), client -> { TSummaries tsr = client.startGetSummaries(Tracer.traceInfo(), context.rpcCreds(), request); while (!tsr.finished) { tsr = client.contiuneGetSummaries(Tracer.traceInfo(), tsr.sessionId); } return tsr; }); return new SummaryCollection(ret).getSummaries(); }