private Scan createScan() { Scan scan = new Scan(); scan.setMaxVersions(3); return scan; }
/** * Creates Scan operation to load backup history * @return scan operation */ private Scan createScanForBackupHistory() { Scan scan = new Scan(); byte[] startRow = Bytes.toBytes(BACKUP_INFO_PREFIX); byte[] stopRow = Arrays.copyOf(startRow, startRow.length); stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1); scan.setStartRow(startRow); scan.setStopRow(stopRow); scan.addFamily(BackupSystemTable.SESSIONS_FAMILY); scan.setMaxVersions(1); return scan; }
Scan scan = new Scan(); scan.addFamily(Bytes.toBytes(columnFamily)); scan.setMaxVersions(Integer.parseInt(conf.get(SCAN_MAXVERSIONS)));
@Test public void testMultiRowRangeFilterWithEmptyStartRow() throws IOException { tableName = TableName.valueOf(name.getMethodName()); Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE); generateRows(numRows, ht, family, qf, value); Scan scan = new Scan(); scan.setMaxVersions(); List<RowRange> ranges = new ArrayList<>(); ranges.add(new RowRange(Bytes.toBytes(""), true, Bytes.toBytes(10), false)); ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false)); MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges); scan.setFilter(filter); int resultsSize = getResultsSize(ht, scan); List<Cell> results1 = getScanResult(Bytes.toBytes(""), Bytes.toBytes(10), ht); List<Cell> results2 = getScanResult(Bytes.toBytes(30), Bytes.toBytes(40), ht); assertEquals(results1.size() + results2.size(), resultsSize); ht.close(); }
@Test public void testScans() throws Exception { Filter filter = new DependentColumnFilter(FAMILIES[0], QUALIFIER); Scan scan = new Scan(); scan.setFilter(filter); scan.setMaxVersions(Integer.MAX_VALUE); scan = new Scan(); scan.setFilter(filter); scan.setMaxVersions(Integer.MAX_VALUE); scan = new Scan(); scan.setFilter(filter); scan.setMaxVersions(Integer.MAX_VALUE); scan = new Scan(); scan.setFilter(filter); scan.setMaxVersions(Integer.MAX_VALUE);
private void verify(final Table table) throws IOException { Scan scan = new Scan(); scan.addColumn(FAMILY_NAME, COLUMN_NAME); scan.setMaxVersions(1); ResultScanner scanner = table.getScanner(scan); for (Result r: scanner) { for (Cell kv : r.listCells()) { log.debug(Bytes.toString(r.getRow()) + "\t" + Bytes.toString(CellUtil.cloneFamily(kv)) + "\t" + Bytes.toString(CellUtil.cloneQualifier(kv)) + "\t" + kv.getTimestamp() + "\t" + Bytes.toBoolean(CellUtil.cloneValue(kv))); org.junit.Assert.assertEquals(TIMESTAMP.get(kv.getTimestamp()), Bytes.toBoolean(CellUtil.cloneValue(kv))); } } scanner.close(); }
/** * Set the scan attribute * * @param reversed if true, scan will be backward order * @param mobScanRaw if true, scan will get the mob reference * @return this */ public void setScan(Scan scan, boolean reversed, boolean mobScanRaw) { scan.setReversed(reversed); scan.setMaxVersions(4); if(mobScanRaw) { scan.setAttribute(MobConstants.MOB_SCAN_RAW, Bytes.toBytes(Boolean.TRUE)); } }
@Test public void testMultiRowRangeFilterWithEmptyStopRow() throws IOException { tableName = TableName.valueOf(name.getMethodName()); Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE); generateRows(numRows, ht, family, qf, value); Scan scan = new Scan(); scan.setMaxVersions(); List<RowRange> ranges = new ArrayList<>(); ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(""), false)); ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false)); MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges); scan.setFilter(filter); int resultsSize = getResultsSize(ht, scan); List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(""), ht); assertEquals(results1.size(), resultsSize); ht.close(); }
/** * The ExplicitColumnTracker does not support "raw" scanning. */ @Test public void testRawScanWithColumns() throws Exception { HTableDescriptor htd = hbu.createTableDescriptor(name.getMethodName(), 0, 3, HConstants.FOREVER, KeepDeletedCells.TRUE); Region region = hbu.createLocalHRegion(htd, null, null); Scan s = new Scan(); s.setRaw(true); s.setMaxVersions(); s.addColumn(c0, c0); try { region.getScanner(s); fail("raw scanner with columns should have failed"); } catch (org.apache.hadoop.hbase.DoNotRetryIOException dnre) { // ok! } HBaseTestingUtility.closeRegionAndWAL(region); }
job.setSortComparatorClass(CompositeKeyComparator.class); Scan scan = new Scan(); scan.addFamily(CHAIN_FAM); scan.addFamily(SORT_FAM); scan.setMaxVersions(1); scan.setCacheBlocks(false); scan.setBatch(1000); assertEquals(true, job.waitForCompletion(true));
job.setJarByClass(VerifyReplication.class); Scan scan = new Scan(); scan.setTimeRange(startTime, endTime); scan.setRaw(includeDeletedCells); scan.setMaxVersions(versions); LOG.info("Number of versions set to " + versions); String[] fams = families.split(","); for(String fam : fams) { scan.addFamily(Bytes.toBytes(fam));
static Scan createScanForBulkLoadedFiles(String backupId) { Scan scan = new Scan(); byte[] startRow = backupId == null ? BULK_LOAD_PREFIX_BYTES : rowkey(BULK_LOAD_PREFIX, backupId + BLK_LD_DELIM); byte[] stopRow = Arrays.copyOf(startRow, startRow.length); stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1); scan.setStartRow(startRow); scan.setStopRow(stopRow); scan.addFamily(BackupSystemTable.META_FAMILY); scan.setMaxVersions(1); return scan; }
@VisibleForTesting static Scan getScanFromCommandLine(Configuration conf, String[] args) throws IOException { Scan s = new Scan(); s.setMaxVersions(versions); s.addFamily(Bytes.toBytes(columnFamily));
scan.setMaxVersions(); scan.setAttribute(BaseScannerRegionObserver.IMMUTABLE_STORAGE_ENCODING_SCHEME, new byte[]{table.getImmutableStorageScheme().getSerializedMetadataValue()}); scan.setAttribute(BaseScannerRegionObserver.USE_NEW_VALUE_COLUMN_QUALIFIER, Bytes.toBytes(true));
@Test public void testMultiRowRangeFilterWithoutRangeOverlap() throws IOException { tableName = TableName.valueOf(name.getMethodName()); Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE); generateRows(numRows, ht, family, qf, value); Scan scan = new Scan(); scan.setMaxVersions(); List<RowRange> ranges = new ArrayList<>(); ranges.add(new RowRange(Bytes.toBytes(30), true, Bytes.toBytes(40), false)); ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false)); ranges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(70), false)); MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges); scan.setFilter(filter); int resultsSize = getResultsSize(ht, scan); LOG.info("found " + resultsSize + " results"); List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(20), ht); List<Cell> results2 = getScanResult(Bytes.toBytes(30), Bytes.toBytes(40), ht); List<Cell> results3 = getScanResult(Bytes.toBytes(60), Bytes.toBytes(70), ht); assertEquals(results1.size() + results2.size() + results3.size(), resultsSize); ht.close(); }
@Test public void testWideScanBatching() throws IOException { final int batch = 256; int inserted = addWideContent(this.r); List<Cell> results = new ArrayList<>(); Scan scan = new Scan(); scan.addFamily(A); scan.addFamily(B); scan.addFamily(C); scan.setMaxVersions(100); scan.setBatch(batch); InternalScanner s = r.getScanner(scan);
Scan scan = new Scan(); scan.addColumn(family, qf1); scan.setMaxVersions(4); ResultScanner scanner = table.getScanner(scan); List<Cell> cells = result.getColumnCells(family, qf1); Assert.assertEquals(1, cells.size()); Assert.assertEquals(1, size); } finally { table.close();
private ResultScanner scan(Table ht, byte[] cf, Integer[] rowIndexes, Integer[] columnIndexes, Long[] versions, int maxVersions) throws IOException { Arrays.asList(rowIndexes); byte startRow[] = Bytes.toBytes("row:" + Collections.min( Arrays.asList(rowIndexes))); byte endRow[] = Bytes.toBytes("row:" + Collections.max( Arrays.asList(rowIndexes))+1); Scan scan = new Scan(startRow, endRow); for (Integer colIdx: columnIndexes) { byte column[] = Bytes.toBytes("column:" + colIdx); scan.addColumn(cf, column); } scan.setMaxVersions(maxVersions); scan.setTimeRange(Collections.min(Arrays.asList(versions)), Collections.max(Arrays.asList(versions))+1); ResultScanner scanner = ht.getScanner(scan); return scanner; }
/** * Creates Scan operation to load last RS log roll results * @return scan operation */ private Scan createScanForReadRegionServerLastLogRollResult(String backupRoot) { Scan scan = new Scan(); byte[] startRow = rowkey(RS_LOG_TS_PREFIX, backupRoot); byte[] stopRow = Arrays.copyOf(startRow, startRow.length); stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1); scan.setStartRow(startRow); scan.setStopRow(stopRow); scan.addFamily(BackupSystemTable.META_FAMILY); scan.setMaxVersions(1); return scan; }
@Test public void testMultiRowRangeFilterWithInclusive() throws IOException { tableName = TableName.valueOf(name.getMethodName()); Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE); generateRows(numRows, ht, family, qf, value); Scan scan = new Scan(); scan.setMaxVersions(); List<RowRange> ranges = new ArrayList<>(); ranges.add(new RowRange(Bytes.toBytes(10), true, Bytes.toBytes(20), false)); ranges.add(new RowRange(Bytes.toBytes(20), true, Bytes.toBytes(40), false)); ranges.add(new RowRange(Bytes.toBytes(65), true, Bytes.toBytes(75), false)); ranges.add(new RowRange(Bytes.toBytes(60), true, null, false)); ranges.add(new RowRange(Bytes.toBytes(60), true, Bytes.toBytes(80), false)); MultiRowRangeFilter filter = new MultiRowRangeFilter(ranges); scan.setFilter(filter); int resultsSize = getResultsSize(ht, scan); LOG.info("found " + resultsSize + " results"); List<Cell> results1 = getScanResult(Bytes.toBytes(10), Bytes.toBytes(40), ht); List<Cell> results2 = getScanResult(Bytes.toBytes(60), Bytes.toBytes(""), ht); assertEquals(results1.size() + results2.size(), resultsSize); ht.close(); }