Java Code Examples for org.apache.hadoop.hbase.filter.Filter#filterKeyValue()
The following examples show how to use
org.apache.hadoop.hbase.filter.Filter#filterKeyValue() .
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: TestSnapshotFilter.java From phoenix-omid with Apache License 2.0 | 4 votes |
@Test (timeOut = 60_000) public void testFilterCommitCacheInSnapshot() throws Throwable { String TEST_TABLE = "testFilterCommitCacheInSnapshot"; byte[] rowName = Bytes.toBytes("row1"); byte[] famName = Bytes.toBytes(TEST_FAMILY); createTableIfNotExists(TEST_TABLE, famName); TTable tt = new TTable(connection, TEST_TABLE); Transaction tx1 = tm.begin(); Put put = new Put(rowName); for (int i = 0; i < 200; ++i) { byte[] dataValue1 = Bytes.toBytes("some data"); byte[] colName = Bytes.toBytes("col" + i); put.addColumn(famName, colName, dataValue1); } tt.put(tx1, put); tm.commit(tx1); Transaction tx3 = tm.begin(); Table htable = connection.getTable(TableName.valueOf(TEST_TABLE)); SnapshotFilterImpl snapshotFilter = spy(new SnapshotFilterImpl(new HTableAccessWrapper(htable, htable), tm.getCommitTableClient())); Filter newFilter = TransactionFilters.getVisibilityFilter(null, snapshotFilter, (HBaseTransaction) tx3); Table rawTable = connection.getTable(TableName.valueOf(TEST_TABLE)); Scan scan = new Scan(); ResultScanner scanner = rawTable.getScanner(scan); for(Result row: scanner) { for(Cell cell: row.rawCells()) { newFilter.filterKeyValue(cell); } } verify(snapshotFilter, Mockito.times(0)) .getTSIfInSnapshot(any(Cell.class),any(HBaseTransaction.class), any(Map.class)); tm.commit(tx3); tt.close(); }
Example 2
Source File: TestSnapshotFilter.java From phoenix-omid with Apache License 2.0 | 4 votes |
@Test (timeOut = 60_000) public void testFilterCommitCacheNotInSnapshot() throws Throwable { String TEST_TABLE = "testFilterCommitCacheNotInSnapshot"; byte[] rowName = Bytes.toBytes("row1"); byte[] famName = Bytes.toBytes(TEST_FAMILY); createTableIfNotExists(TEST_TABLE, famName); TTable tt = new TTable(connection, TEST_TABLE); //add some uncommitted values Transaction tx1 = tm.begin(); Put put = new Put(rowName); for (int i = 0; i < 200; ++i) { byte[] dataValue1 = Bytes.toBytes("some data"); byte[] colName = Bytes.toBytes("col" + i); put.addColumn(famName, colName, dataValue1); } tt.put(tx1, put); //try to scan from tx Transaction tx = tm.begin(); Table htable = connection.getTable(TableName.valueOf(TEST_TABLE)); SnapshotFilterImpl snapshotFilter = spy(new SnapshotFilterImpl(new HTableAccessWrapper(htable, htable), tm.getCommitTableClient())); Filter newFilter = TransactionFilters.getVisibilityFilter(null, snapshotFilter, (HBaseTransaction) tx); Table rawTable = connection.getTable(TableName.valueOf(TEST_TABLE)); Scan scan = new Scan(); ResultScanner scanner = rawTable.getScanner(scan); for(Result row: scanner) { for(Cell cell: row.rawCells()) { newFilter.filterKeyValue(cell); } } verify(snapshotFilter, Mockito.times(1)) .getTSIfInSnapshot(any(Cell.class),any(HBaseTransaction.class), any(Map.class)); tt.close(); }