/** * Test the filter by adding 2 columns of family A and 1 column of family B in the scan. (KO: row * '3' without 'a:foo' qualifier is returned) */ @Test public void scanWithSpecificQualifiers1() throws IOException { /* When */ Scan scan = new Scan(); scan.addColumn(FAMILY_A, QUALIFIER_FOO); scan.addColumn(FAMILY_A, QUALIFIER_BAR); scan.addColumn(FAMILY_B, QUALIFIER_BAR); scan.addColumn(FAMILY_B, QUALIFIER_FOO); scan.setFilter(scanFilter); verify(scan); }
@Test public void testNullQualifier() { Scan scan = new Scan(); byte[] family = Bytes.toBytes("family"); scan.addColumn(family, null); Set<byte[]> qualifiers = scan.getFamilyMap().get(family); Assert.assertEquals(1, qualifiers.size()); }
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(); }
@Test public void testRowCount() throws InterruptedException, ExecutionException { assertEquals(COUNT, AsyncAggregationClient .rowCount(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get() .longValue()); }
/** * Test the filter by adding 2 columns of family A in the scan. (OK) */ @Test public void scanWithSpecificQualifiers3() throws IOException { /* When */ Scan scan = new Scan(); scan.addColumn(FAMILY_A, QUALIFIER_FOO); scan.addColumn(FAMILY_A, QUALIFIER_BAR); scan.setFilter(scanFilter); verify(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();
/** * Returns a scanner on the current table as specified by the {@link Scan} object. * @param scan A configured {@link Scan} object. * @return A scanner. */ ResultScanner getScanner(Scan scan);
@Test public void testSum() throws InterruptedException, ExecutionException { assertEquals(COUNT * (COUNT - 1) / 2, AsyncAggregationClient .sum(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().longValue()); }
/** * Test the filter by adding 1 column of family A (the one used in the filter) and 1 column of * family B in the scan. (OK) */ @Test public void scanWithSpecificQualifiers2() throws IOException { /* When */ Scan scan = new Scan(); scan.addColumn(FAMILY_A, QUALIFIER_FOO); scan.addColumn(FAMILY_B, QUALIFIER_BAR); scan.setFilter(scanFilter); verify(scan); }
assertEquals(1, r.size()); assertArrayEquals(value2, r.getValue(fam1, qual1)); Scan scan = new Scan(row); scan.addColumn(fam1, qual1); InternalScanner s = region.getScanner(scan); assertEquals(false, s.next(results)); assertEquals(1, results.size()); Cell kv = results.get(0);
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; }
@Test public void testAvg() throws InterruptedException, ExecutionException { assertEquals((COUNT - 1) / 2.0, AsyncAggregationClient .avg(TABLE, new LongColumnInterpreter(), new Scan().addColumn(CF, CQ)).get().doubleValue(), DELTA); }
/** * For HBASE-2156 */ @Test public void testScanVariableReuse() throws Exception { Scan scan = new Scan(); scan.addFamily(FAMILY); scan.addColumn(FAMILY, ROW); assertTrue(scan.getFamilyMap().get(FAMILY).size() == 1); scan = new Scan(); scan.addFamily(FAMILY); assertTrue(scan.getFamilyMap().get(FAMILY) == null); assertTrue(scan.getFamilyMap().containsKey(FAMILY)); }
scan = new Scan(FIRST_ROW); for (int ii = 0; ii < EXPLICIT_COLS.length; ii++) { scan.addColumn(COLS[0], EXPLICIT_COLS[ii]); assertFalse(val.length == 0); long startCode = Bytes.toLong(val); assertEquals(START_CODE, startCode); assertFalse(val.length == 0); String server = Bytes.toString(val); assertEquals(0, server.compareTo(serverName));
try { Filter prefixFilter = null; Scan tableScan = new Scan(); if (scanSpec.indexOf('*') > 0) { String prefix = scanSpec.substring(0, scanSpec.indexOf('*')); byte[] prefixBytes = Bytes.toBytes(prefix); prefixFilter = new PrefixFilter(Bytes.toBytes(prefix)); if (startRow.isEmpty()) { tableScan.setStartRow(prefixBytes); tableScan.setTimeRange(startTime, endTime); if (!startRow.isEmpty()) { tableScan.setStartRow(Bytes.toBytes(startRow)); tableScan.setStopRow(Bytes.toBytes(endRow)); + " " + Bytes.toStringBinary(parts[1])); tableScan.addColumn(parts[0], parts[1]); } else { throw new IllegalArgumentException("Invalid column specifier.");