org.apache.hadoop.hbase.client.Scan Java Examples
The following examples show how to use
org.apache.hadoop.hbase.client.Scan.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransactionAwareHTableTest.java From phoenix-tephra with Apache License 2.0 | 6 votes |
@Test public void testCheckpointRollback() throws Exception { // start a transaction, using checkpoints between writes transactionContext.start(); transactionAwareHTable.put(new Put(TestBytes.row).add(TestBytes.family, TestBytes.qualifier, TestBytes.value)); transactionContext.checkpoint(); transactionAwareHTable.put(new Put(TestBytes.row2).add(TestBytes.family, TestBytes.qualifier, TestBytes.value2)); transactionContext.checkpoint(); transactionAwareHTable.put(new Put(TestBytes.row3).add(TestBytes.family, TestBytes.qualifier, TestBytes.value)); transactionContext.abort(); transactionContext.start(); verifyRow(transactionAwareHTable, TestBytes.row, null); verifyRow(transactionAwareHTable, TestBytes.row2, null); verifyRow(transactionAwareHTable, TestBytes.row3, null); Scan scan = new Scan(); ResultScanner scanner = transactionAwareHTable.getScanner(scan); assertNull(scanner.next()); scanner.close(); transactionContext.finish(); }
Example #2
Source File: WhereClauseOptimizerTest.java From phoenix with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void testLikeExtractKeyExpression2() throws SQLException { String tenantId = "000000000000001"; String keyPrefix = "002"; // TODO: verify that _ at end of like doesn't go to equals String query = "select * from atable where organization_id = ? and entity_id LIKE '" + keyPrefix + "_'"; Scan scan = new Scan(); List<Object> binds = Arrays.<Object>asList(tenantId); compileStatement(query, scan, binds); assertNotNull(scan.getFilter()); byte[] startRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(tenantId),ByteUtil.fillKey(PDataType.VARCHAR.toBytes(keyPrefix),15)); assertArrayEquals(startRow, scan.getStartRow()); byte[] stopRow = ByteUtil.concat(PDataType.VARCHAR.toBytes(tenantId),ByteUtil.fillKey(ByteUtil.nextKey(PDataType.VARCHAR.toBytes(keyPrefix)),15)); assertArrayEquals(stopRow, scan.getStopRow()); }
Example #3
Source File: WhereOptimizerTest.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testMultiKeyBindExpression() throws SQLException { String tenantId = "000000000000001"; String keyPrefix = "002"; String query = "select * from atable where organization_id=? and substr(entity_id,1,3)=?"; List<Object> binds = Arrays.<Object>asList(tenantId,keyPrefix); Scan scan = compileStatement(query, binds).getScan(); assertNull(scan.getFilter()); byte[] startRow = ByteUtil.concat( PVarchar.INSTANCE.toBytes(tenantId),StringUtil.padChar(PVarchar.INSTANCE.toBytes(keyPrefix),15)); assertArrayEquals(startRow, scan.getStartRow()); byte[] stopRow = ByteUtil.concat( PVarchar.INSTANCE.toBytes(tenantId),StringUtil.padChar(ByteUtil.nextKey(PVarchar.INSTANCE.toBytes(keyPrefix)),15)); assertArrayEquals(stopRow, scan.getStopRow()); }
Example #4
Source File: WhereOptimizerTest.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testRVCExpressionThroughOr() throws SQLException { String tenantId = "000000000000001"; String entityId = "002333333333331"; String entityId1 = "002333333333330"; String entityId2 = "002333333333332"; String query = "select * from atable where (organization_id,entity_id) >= (?,?) and organization_id = ? and (entity_id = ? or entity_id = ?)"; List<Object> binds = Arrays.<Object>asList(tenantId, entityId, tenantId, entityId1, entityId2); StatementContext context = compileStatement(query, binds); Scan scan = context.getScan(); byte[] expectedStartRow = ByteUtil.concat(PVarchar.INSTANCE.toBytes(tenantId), PVarchar.INSTANCE.toBytes(entityId1)); byte[] expectedStopRow = ByteUtil.concat(PVarchar.INSTANCE.toBytes(tenantId), PVarchar.INSTANCE.toBytes(entityId2), QueryConstants.SEPARATOR_BYTE_ARRAY); assertArrayEquals(expectedStartRow, scan.getStartRow()); assertArrayEquals(expectedStopRow, scan.getStopRow()); Filter filter = scan.getFilter(); assertTrue(filter instanceof SkipScanFilter); SkipScanFilter skipScanFilter = (SkipScanFilter)filter; List<List<KeyRange>> skipScanRanges = Arrays.asList( Arrays.asList(KeyRange.getKeyRange(ByteUtil.concat(PVarchar.INSTANCE.toBytes(tenantId), PVarchar.INSTANCE.toBytes(entityId1))), KeyRange.getKeyRange(ByteUtil.concat(PVarchar.INSTANCE.toBytes(tenantId), PVarchar.INSTANCE.toBytes(entityId2))))); assertEquals(skipScanRanges, skipScanFilter.getSlots()); }
Example #5
Source File: DataJanitorState.java From phoenix-tephra with Apache License 2.0 | 6 votes |
/** * Delete prune upper bounds for the regions that are not in the given exclude set, and the * prune upper bound is less than the given value. * After the invalid list is pruned up to deletionPruneUpperBound, we do not need entries for regions that have * prune upper bound less than deletionPruneUpperBound. We however limit the deletion to only regions that are * no longer in existence (due to deletion, etc.), to avoid update/delete race conditions. * * @param deletionPruneUpperBound prune upper bound below which regions will be deleted * @param excludeRegions set of regions that should not be deleted * @throws IOException when not able to delete data in HBase */ public void deletePruneUpperBounds(long deletionPruneUpperBound, SortedSet<byte[]> excludeRegions) throws IOException { try (Table stateTable = stateTableSupplier.get()) { byte[] startRow = makeRegionKey(EMPTY_BYTE_ARRAY); Scan scan = new Scan(startRow, REGION_KEY_PREFIX_STOP); scan.addColumn(FAMILY, PRUNE_UPPER_BOUND_COL); try (ResultScanner scanner = stateTable.getScanner(scan)) { Result next; while ((next = scanner.next()) != null) { byte[] region = getRegionFromKey(next.getRow()); if (!excludeRegions.contains(region)) { byte[] timeBytes = next.getValue(FAMILY, PRUNE_UPPER_BOUND_COL); if (timeBytes != null) { long pruneUpperBoundRegion = Bytes.toLong(timeBytes); if (pruneUpperBoundRegion < deletionPruneUpperBound) { stateTable.delete(new Delete(next.getRow())); } } } } } } }
Example #6
Source File: WhereCompilerTest.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testPartialRangeFilter() throws SQLException { // I know these id's are ridiculous, but users can write queries that look like this String tenantId1 = "001"; String tenantId2 = "02"; String query = String.format("select * from %s where organization_id > '%s' AND organization_id < '%s'", ATABLE_NAME, tenantId1, tenantId2); PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = newPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); assertNull(scan.getFilter()); byte[] wideLower = ByteUtil.nextKey(StringUtil.padChar(Bytes.toBytes(tenantId1), 15)); byte[] wideUpper = StringUtil.padChar(Bytes.toBytes(tenantId2), 15); assertArrayEquals(wideLower, scan.getStartRow()); assertArrayEquals(wideUpper, scan.getStopRow()); }
Example #7
Source File: TestSpaceQuotaViolationPolicyRefresherChore.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testMissingAllColumns() throws IOException { when(chore.fetchSnapshotsFromQuotaTable()).thenCallRealMethod(); ResultScanner scanner = mock(ResultScanner.class); Table quotaTable = mock(Table.class); when(conn.getTable(QuotaUtil.QUOTA_TABLE_NAME)).thenReturn(quotaTable); when(quotaTable.getScanner(any(Scan.class))).thenReturn(scanner); List<Result> results = new ArrayList<>(); results.add(Result.create(Collections.emptyList())); when(scanner.iterator()).thenReturn(results.iterator()); try { chore.fetchSnapshotsFromQuotaTable(); fail("Expected an IOException, but did not receive one."); } catch (IOException e) { // Expected an error because we had no cells in the row. // This should only happen due to programmer error. } }
Example #8
Source File: TestFiltersWithBinaryComponentComparator.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testRowFilterWithBinaryComponentComparator() throws IOException { //SELECT * from table where a=1 and b > 10 and b < 20 and c > 90 and c < 100 and d=1 tableName = TableName.valueOf(name.getMethodName()); Table ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE); generateRows(ht, family, qf); FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL); setRowFilters(filterList); Scan scan = createScan(filterList); List<Cell> result = getResults(ht,scan); for(Cell cell: result){ byte[] key = CellUtil.cloneRow(cell); int a = Bytes.readAsInt(key,aOffset,4); int b = Bytes.readAsInt(key,bOffset,4); int c = Bytes.readAsInt(key,cOffset,4); int d = Bytes.readAsInt(key,dOffset,4); assertTrue(a == 1 && b > 10 && b < 20 && c > 90 && c < 100 && d == 1); } ht.close(); }
Example #9
Source File: WhereCompilerTest.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testAndFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id=? and a_integer=0 and a_string='foo'"; List<Object> binds = Arrays.<Object>asList(tenantId); PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = newPreparedStatement(pconn, query); bindParams(pstmt, binds); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); Filter filter = scan.getFilter(); assertEquals( multiEncodedKVFilter(and( constantComparison( CompareOp.EQUAL, A_INTEGER, 0), constantComparison( CompareOp.EQUAL, A_STRING, "foo")), TWO_BYTE_QUALIFIERS), filter); }
Example #10
Source File: WhereCompilerTest.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testBetweenFilter() throws SQLException { String tenantId = "000000000000001"; String query = "select * from atable where organization_id='" + tenantId + "' and a_integer between 0 and 10"; PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); PhoenixPreparedStatement pstmt = newPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); Filter filter = scan.getFilter(); assertEquals( singleKVFilter(and( constantComparison( CompareOp.GREATER_OR_EQUAL, A_INTEGER, 0), constantComparison( CompareOp.LESS_OR_EQUAL, A_INTEGER, 10))), filter); }
Example #11
Source File: QuotaTableUtil.java From hbase with Apache License 2.0 | 6 votes |
/** * Returns a list of {@code Delete} to remove all entries returned by the passed scanner. * @param connection connection to re-use * @param scan the scanner to use to generate the list of deletes */ static List<Delete> createDeletesForExistingSnapshotsFromScan(Connection connection, Scan scan) throws IOException { List<Delete> deletes = new ArrayList<>(); try (Table quotaTable = connection.getTable(QUOTA_TABLE_NAME); ResultScanner rs = quotaTable.getScanner(scan)) { for (Result r : rs) { CellScanner cs = r.cellScanner(); while (cs.advance()) { Cell c = cs.current(); byte[] family = Bytes.copy(c.getFamilyArray(), c.getFamilyOffset(), c.getFamilyLength()); byte[] qual = Bytes.copy(c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()); Delete d = new Delete(r.getRow()); d.addColumns(family, qual); deletes.add(d); } } return deletes; } }
Example #12
Source File: TestReplicationSink.java From hbase with Apache License 2.0 | 6 votes |
/** * Insert a mix of puts and deletes * @throws Exception */ @Test public void testMixedPutDelete() throws Exception { List<WALEntry> entries = new ArrayList<>(BATCH_SIZE/2); List<Cell> cells = new ArrayList<>(); for(int i = 0; i < BATCH_SIZE/2; i++) { entries.add(createEntry(TABLE_NAME1, i, KeyValue.Type.Put, cells)); } SINK.replicateEntries(entries, CellUtil.createCellScanner(cells), replicationClusterId, baseNamespaceDir, hfileArchiveDir); entries = new ArrayList<>(BATCH_SIZE); cells = new ArrayList<>(); for(int i = 0; i < BATCH_SIZE; i++) { entries.add(createEntry(TABLE_NAME1, i, i % 2 != 0 ? KeyValue.Type.Put: KeyValue.Type.DeleteColumn, cells)); } SINK.replicateEntries(entries, CellUtil.createCellScanner(cells.iterator()), replicationClusterId, baseNamespaceDir, hfileArchiveDir); Scan scan = new Scan(); ResultScanner scanRes = table1.getScanner(scan); assertEquals(BATCH_SIZE/2, scanRes.next(BATCH_SIZE).length); }
Example #13
Source File: WhereCompilerTest.java From phoenix with Apache License 2.0 | 6 votes |
@Test public void testSingleVariableFullPkSalted() throws SQLException { PhoenixConnection pconn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TEST_PROPERTIES)).unwrap(PhoenixConnection.class); pconn.createStatement().execute("CREATE TABLE t (k varchar primary key, v varchar) SALT_BUCKETS=20"); String query = "select * from t where k='a'"; PhoenixPreparedStatement pstmt = newPreparedStatement(pconn, query); QueryPlan plan = pstmt.optimizeQuery(); Scan scan = plan.getContext().getScan(); Filter filter = scan.getFilter(); assertNull(filter); byte[] key = new byte[2]; PVarchar.INSTANCE.toBytes("a", key, 1); key[0] = SaltingUtil.getSaltingByte(key, 1, 1, 20); byte[] expectedStartKey = key; byte[] expectedEndKey = ByteUtil.nextKey(ByteUtil.concat(key, QueryConstants.SEPARATOR_BYTE_ARRAY)); byte[] startKey = scan.getStartRow(); byte[] stopKey = scan.getStopRow(); assertTrue(Bytes.compareTo(expectedStartKey, startKey) == 0); assertTrue(Bytes.compareTo(expectedEndKey, stopKey) == 0); }
Example #14
Source File: TestServerSideScanMetricsFromClientSide.java From hbase with Apache License 2.0 | 6 votes |
/** * @return The approximate heap size of a cell in the test table. All cells should have * approximately the same heap size, so the value is cached to avoid repeating the * calculation * @throws Exception on unexpected failure */ private long getCellHeapSize() throws Exception { if (CELL_HEAP_SIZE == -1) { // Do a partial scan that will return a single result with a single cell Scan scan = new Scan(); scan.setMaxResultSize(1); scan.setAllowPartialResults(true); ResultScanner scanner = TABLE.getScanner(scan); Result result = scanner.next(); assertTrue(result != null); assertTrue(result.rawCells() != null); assertTrue(result.rawCells().length == 1); CELL_HEAP_SIZE = result.rawCells()[0].heapSize(); scanner.close(); } return CELL_HEAP_SIZE; }
Example #15
Source File: ScanUtil.java From phoenix with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static void andFilterAtEnd(Scan scan, Filter andWithFilter) { if (andWithFilter == null) { return; } Filter filter = scan.getFilter(); if (filter == null) { scan.setFilter(andWithFilter); } else if (filter instanceof FilterList && ((FilterList)filter).getOperator() == FilterList.Operator.MUST_PASS_ALL) { FilterList filterList = (FilterList)filter; List<Filter> allFilters = new ArrayList<Filter>(filterList.getFilters().size() + 1); allFilters.addAll(filterList.getFilters()); allFilters.add(andWithFilter); scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,allFilters)); } else { scan.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,Arrays.asList(filter, andWithFilter))); } }
Example #16
Source File: ProtobufUtil.java From hbase with Apache License 2.0 | 5 votes |
public static Scan.ReadType toReadType(ClientProtos.Scan.ReadType readType) { switch (readType) { case DEFAULT: return Scan.ReadType.DEFAULT; case STREAM: return Scan.ReadType.STREAM; case PREAD: return Scan.ReadType.PREAD; default: throw new IllegalArgumentException("Unknown ReadType: " + readType); } }
Example #17
Source File: TestScannersWithFilters.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testFirstKeyOnlyFilter() throws Exception { Scan s = new Scan(); s.setFilter(new FirstKeyOnlyFilter()); // Expected KVs, the first KV from each of the remaining 6 rows KeyValue [] kvs = { new KeyValue(ROWS_ONE[0], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), new KeyValue(ROWS_ONE[2], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), new KeyValue(ROWS_ONE[3], FAMILIES[0], QUALIFIERS_ONE[0], VALUES[0]), new KeyValue(ROWS_TWO[0], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), new KeyValue(ROWS_TWO[2], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]), new KeyValue(ROWS_TWO[3], FAMILIES[0], QUALIFIERS_TWO[0], VALUES[1]) }; verifyScanFull(s, kvs); }
Example #18
Source File: TransactionAwareHTableTest.java From phoenix-tephra with Apache License 2.0 | 5 votes |
private void verifyScan(HTableInterface table, Scan scan, List<KeyValue> expectedCells) throws Exception { List<Cell> actualCells = new ArrayList<>(); try (ResultScanner scanner = table.getScanner(scan)) { Result[] results = scanner.next(expectedCells.size() + 1); for (Result result : results) { actualCells.addAll(Lists.newArrayList(result.rawCells())); } Assert.assertEquals(expectedCells, actualCells); } }
Example #19
Source File: TestSnapshotFilterLL.java From phoenix-omid with Apache License 2.0 | 5 votes |
@Test(timeOut = 60_000) public void testInvalidateByScan() throws Throwable { byte[] rowName1 = Bytes.toBytes("row1"); byte[] famName1 = Bytes.toBytes(TEST_FAMILY); byte[] colName1 = Bytes.toBytes("col1"); byte[] dataValue1 = Bytes.toBytes("testWrite-1"); String TEST_TABLE = "testGetFirstResult"; createTableIfNotExists(TEST_TABLE, Bytes.toBytes(TEST_FAMILY)); TTable tt = new TTable(connection, TEST_TABLE); Transaction tx1 = tm.begin(); Put row1 = new Put(rowName1); row1.addColumn(famName1, colName1, dataValue1); tt.put(tx1, row1); Transaction tx2 = tm.begin(); ResultScanner iterableRS = tt.getScanner(tx2, new Scan().setStartRow(rowName1).setStopRow(rowName1)); assertTrue(iterableRS.next() == null); tm.commit(tx2); boolean gotInvalidated = false; try { tm.commit(tx1); } catch (RollbackException e) { gotInvalidated = true; } assertTrue(gotInvalidated); assertTrue(tm.isLowLatency()); }
Example #20
Source File: BaseDao.java From zxl with Apache License 2.0 | 5 votes |
public final List<E> scanByRowPrefix(String prefix) { HTableInterface hTableInterface = getHTableInterface(); try { Scan scan = new Scan(); scan.setFilter(new PrefixFilter(Bytes.toBytes(prefix))); ResultScanner resultScanner = hTableInterface.getScanner(scan); return parse(resultScanner); } catch (Exception cause) { throw new RuntimeException(cause); } finally { closeHTableInterface(hTableInterface); } }
Example #21
Source File: TestHBaseOutput.java From envelope with Apache License 2.0 | 5 votes |
private List<Result> scanAndReturnTable(Table table) throws IOException { List<Result> results = Lists.newArrayList(); Scan scan = new Scan(); ResultScanner scanner = table.getScanner(scan); for (Result result : scanner) { results.add(result); } return results; }
Example #22
Source File: TableInputFormat.java From stratosphere with Apache License 2.0 | 5 votes |
@Override public void configure(Configuration parameters) { HTable table = createTable(parameters); setTable(table); Scan scan = createScanner(parameters); setScan(scan); }
Example #23
Source File: TestQuotaAdmin.java From hbase with Apache License 2.0 | 5 votes |
private void verifyRecordPresentInQuotaTable(ThrottleType type, long limit, TimeUnit tu, QuotaScope scope) throws Exception { // Verify the RPC Quotas in the table try (Table quotaTable = TEST_UTIL.getConnection().getTable(QuotaTableUtil.QUOTA_TABLE_NAME); ResultScanner scanner = quotaTable.getScanner(new Scan())) { Result r = Iterables.getOnlyElement(scanner); CellScanner cells = r.cellScanner(); assertTrue("Expected to find a cell", cells.advance()); assertRPCQuota(type, limit, tu, scope, cells.current()); } }
Example #24
Source File: IndexerRegionScanner.java From phoenix with Apache License 2.0 | 5 votes |
IndexerRegionScanner (final RegionScanner innerScanner, final Region region, final Scan scan, final RegionCoprocessorEnvironment env) throws IOException { super(innerScanner, region, scan, env); indexKeyToDataPutMap = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); verificationResult = new IndexToolVerificationResult(scan); verificationResultRepository = new IndexVerificationResultRepository(indexMaintainer.getIndexTableName(), hTableFactory); }
Example #25
Source File: HBaseLookupTable.java From kylin with Apache License 2.0 | 5 votes |
public HBaseScanBasedIterator(Table table) { try { Scan scan = new Scan(); scan.setCaching(1000); ResultScanner scanner = table.getScanner(HBaseLookupRowEncoder.CF); scannerIterator = scanner.iterator(); } catch (IOException e) { logger.error("error when scan HBase", e); } }
Example #26
Source File: Export.java From hbase with Apache License 2.0 | 5 votes |
RegionScanner checkScannerOpen(final Scan scan) throws IOException { RegionScanner scanner; if (region.getCoprocessorHost() == null) { scanner = region.getScanner(scan); } else { region.getCoprocessorHost().preScannerOpen(scan); scanner = region.getScanner(scan); scanner = region.getCoprocessorHost().postScannerOpen(scan, scanner); } if (scanner == null) { throw new IOException("Failed to open region scanner"); } return scanner; }
Example #27
Source File: SaltingUtil.java From phoenix with Apache License 2.0 | 5 votes |
public static void addRegionStartKeyToScanStartAndStopRows(byte[] startKey, byte[] endKey, Scan scan) { if (startKey.length == 0 && endKey.length == 0) return; byte[] prefixBytes = startKey.length != 0 ? startKey : new byte[endKey.length]; byte[] newStartRow = new byte[scan.getStartRow().length + prefixBytes.length]; System.arraycopy(prefixBytes, 0, newStartRow, 0, prefixBytes.length); System.arraycopy(scan.getStartRow(), 0, newStartRow, prefixBytes.length, scan.getStartRow().length); scan.setStartRow(newStartRow); if (scan.getStopRow().length != 0) { byte[] newStopRow = new byte[scan.getStopRow().length + prefixBytes.length]; System.arraycopy(prefixBytes, 0, newStopRow, 0, prefixBytes.length); System.arraycopy(scan.getStopRow(), 0, newStopRow, prefixBytes.length, scan.getStopRow().length); scan.setStopRow(newStopRow); } }
Example #28
Source File: VertexModel.java From hgraphdb with Apache License 2.0 | 5 votes |
public Iterator<Vertex> vertices(String label) { final VertexReader parser = new VertexReader(graph); Scan scan = getPropertyScan(label); ResultScanner scanner = null; try { scanner = table.getScanner(scan); return HBaseGraphUtils.mapWithCloseAtEnd(scanner, parser::parse); } catch (IOException e) { throw new HBaseGraphException(e); } }
Example #29
Source File: StoreScanner.java From hbase with Apache License 2.0 | 5 votes |
@VisibleForTesting StoreScanner(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> columns, List<? extends KeyValueScanner> scanners, ScanType scanType) throws IOException { // 0 is passed as readpoint because the test bypasses Store this(null, scan, scanInfo, columns != null ? columns.size() : 0, 0L, scan.getCacheBlocks(), scanType); if (scanType == ScanType.USER_SCAN) { this.matcher = UserScanQueryMatcher.create(scan, scanInfo, columns, oldestUnexpiredTS, now, null); } else { this.matcher = CompactionScanQueryMatcher.create(scanInfo, scanType, Long.MAX_VALUE, HConstants.OLDEST_TIMESTAMP, oldestUnexpiredTS, now, null, null, null); } seekAllScanner(scanInfo, scanners); }
Example #30
Source File: WhereOptimizerTest.java From phoenix with Apache License 2.0 | 5 votes |
@Test public void testNullAtStartOfRVC() throws SQLException { String tenantId = null; String parentId = "000000000000002"; Date createdDate = new Date(System.currentTimeMillis()); String query = "select * from entity_history where (organization_id, parent_id, created_date) >= (?,?,?)"; List<Object> binds = Arrays.<Object>asList(tenantId, parentId, createdDate); StatementContext context = compileStatement(query, binds); Scan scan = context.getScan(); Filter filter = scan.getFilter(); assertNull(filter); byte[] expectedStartRow = ByteUtil.concat(new byte[15], ByteUtil.previousKey(PChar.INSTANCE.toBytes(parentId)), PDate.INSTANCE.toBytes(createdDate)); assertArrayEquals(expectedStartRow, scan.getStartRow()); assertArrayEquals(HConstants.EMPTY_END_ROW, scan.getStopRow()); }