org.apache.hadoop.hbase.filter.BinaryPrefixComparator Java Examples
The following examples show how to use
org.apache.hadoop.hbase.filter.BinaryPrefixComparator.
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: ScannerModel.java From hbase with Apache License 2.0 | 6 votes |
public ByteArrayComparableModel( ByteArrayComparable comparator) { String typeName = comparator.getClass().getSimpleName(); ComparatorType type = ComparatorType.valueOf(typeName); this.type = typeName; switch (type) { case BinaryComparator: case BinaryPrefixComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); break; case BitComparator: this.value = Bytes.toString(Base64.getEncoder().encode(comparator.getValue())); this.op = ((BitComparator)comparator).getOperator().toString(); break; case NullComparator: break; case RegexStringComparator: case SubstringComparator: this.value = Bytes.toString(comparator.getValue()); break; default: throw new RuntimeException("unhandled filter type: " + type); } }
Example #2
Source File: TestUpdateScan.java From phoenix-omid with Apache License 2.0 | 4 votes |
@Test(timeOut = 10_000) public void testGet(ITestContext context) throws Exception { try { TransactionManager tm = newTransactionManager(context); TTable table = new TTable(connection, TEST_TABLE); Transaction t = tm.begin(); int[] lInts = new int[]{100, 243, 2342, 22, 1, 5, 43, 56}; for (int i = 0; i < lInts.length; i++) { byte[] data = Bytes.toBytes(lInts[i]); Put put = new Put(data); put.addColumn(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data); table.put(t, put); } int startKeyValue = lInts[3]; int stopKeyValue = lInts[3]; byte[] startKey = Bytes.toBytes(startKeyValue); byte[] stopKey = Bytes.toBytes(stopKeyValue); Get g = new Get(startKey); Result r = table.get(t, g); if (!r.isEmpty()) { int tmp = Bytes.toInt(r.getValue(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL))); LOG.info("Result:" + tmp); assertTrue(tmp == startKeyValue, "Bad value, should be " + startKeyValue + " but is " + tmp); } else { Assert.fail("Bad result"); } tm.commit(t); Scan s = new Scan(startKey); CompareFilter.CompareOp op = CompareFilter.CompareOp.LESS_OR_EQUAL; RowFilter toFilter = new RowFilter(op, new BinaryPrefixComparator(stopKey)); boolean startInclusive = true; if (!startInclusive) { FilterList filters = new FilterList(FilterList.Operator.MUST_PASS_ALL); filters.addFilter(new RowFilter(CompareFilter.CompareOp.GREATER, new BinaryPrefixComparator(startKey))); filters.addFilter(new WhileMatchFilter(toFilter)); s.setFilter(filters); } else { s.setFilter(new WhileMatchFilter(toFilter)); } t = tm.begin(); ResultScanner res = table.getScanner(t, s); Result rr; int count = 0; while ((rr = res.next()) != null) { int iTmp = Bytes.toInt(rr.getValue(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL))); LOG.info("Result: " + iTmp); count++; } assertEquals(count, 1, "Count is wrong"); LOG.info("Rows found " + count); tm.commit(t); table.close(); } catch (Exception e) { LOG.error("Exception in test", e); } }
Example #3
Source File: HbaseTraceDaoV2.java From pinpoint with Apache License 2.0 | 4 votes |
public QualifierFilter createSpanQualifierFilter() { byte indexPrefix = SpanEncoder.TYPE_SPAN; BinaryPrefixComparator prefixComparator = new BinaryPrefixComparator(new byte[]{indexPrefix}); QualifierFilter qualifierPrefixFilter = new QualifierFilter(CompareFilter.CompareOp.EQUAL, prefixComparator); return qualifierPrefixFilter; }