public static String scanToString(BigtableExtendedScan scan) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] table = scan.getAttribute(Scan.SCAN_ATTRIBUTES_TABLE_NAME); DataOutputStream dos = new DataOutputStream(baos); dos.writeInt(table.length); dos.write(table); scan.getRowSet().writeTo(dos); dos.flush(); return Base64.getEncoder().encodeToString(baos.toByteArray()); }
@Override public int compareTo(BigtableExtendedScanSplit o) { // If The table name of the two splits is the same then compare start row // otherwise compare based on table names int tableNameComparison = name.compareTo(o.name); return tableNameComparison != 0 ? tableNameComparison : Bytes.compareTo( scan.getRowSet().getRowRanges(0).getStartKeyClosed().toByteArray(), o.scan.getRowSet().getRowRanges(0).getStartKeyClosed().toByteArray()); }
private RowSet getRowSet(Scan scan) { if (scan instanceof BigtableExtendedScan) { return ((BigtableExtendedScan) scan).getRowSet(); } else { RowSet.Builder rowSetBuilder = RowSet.newBuilder();
private RangeSet<RowKeyWrapper> getRangeSet(Scan scan) { if (scan instanceof BigtableExtendedScan) { RowSet rowSet = ((BigtableExtendedScan) scan).getRowSet(); return rowRangeAdapter.rowSetToRangeSet(rowSet); } else { RangeSet<RowKeyWrapper> rangeSet = TreeRangeSet.create(); final ByteString startRow = ByteString.copyFrom(scan.getStartRow()); final ByteString stopRow = ByteString.copyFrom(scan.getStopRow()); if (scan.isGetScan()) { rangeSet.add(Range.singleton(new RowKeyWrapper(startRow))); } else { final BoundType startBound = (!OPEN_CLOSED_AVAILABLE || scan.includeStartRow()) ? BoundType.CLOSED : BoundType.OPEN; final BoundType endBound = (!OPEN_CLOSED_AVAILABLE || !scan.includeStopRow()) ? BoundType.OPEN : BoundType.CLOSED; rangeSet.add(rowRangeAdapter.boundedRange(startBound, startRow, endBound, stopRow)); } return rangeSet; } }