org.apache.hadoop.hbase.filter.RowFilter.getComparator()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.apache.hadoop.hbase.filter.RowFilter.getComparator方法的一些代码示例,展示了RowFilter.getComparator的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RowFilter.getComparator方法的具体详情如下:
包路径:org.apache.hadoop.hbase.filter.RowFilter
类名称:RowFilter
方法名:getComparator

RowFilter.getComparator介绍

暂无

代码示例

代码示例来源:origin: apache/drill

  1. public HBaseScanSpec parseTree() {
  2. HBaseScanSpec parsedSpec = le.accept(this, null);
  3. if (parsedSpec != null) {
  4. parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
  5. /*
  6. * If RowFilter is THE filter attached to the scan specification,
  7. * remove it since its effect is also achieved through startRow and stopRow.
  8. */
  9. if (parsedSpec.filter instanceof RowFilter &&
  10. ((RowFilter)parsedSpec.filter).getOperator() != CompareOp.NOT_EQUAL &&
  11. ((RowFilter)parsedSpec.filter).getComparator() instanceof BinaryComparator) {
  12. parsedSpec.filter = null;
  13. }
  14. }
  15. return parsedSpec;
  16. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testRowFilter() throws IOException {
  3. String filterString = "RowFilter ( =, 'binary:regionse')";
  4. RowFilter rowFilter =
  5. doTestFilter(filterString, RowFilter.class);
  6. assertEquals(CompareOperator.EQUAL, rowFilter.getCompareOperator());
  7. assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
  8. BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
  9. assertEquals("regionse", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
  10. }

代码示例来源:origin: apache/hbase

  1. @Test
  2. public void testWhileFilter() throws IOException {
  3. String filterString = " WHILE RowFilter ( !=, 'binary:row1')";
  4. WhileMatchFilter whileMatchFilter =
  5. doTestFilter(filterString, WhileMatchFilter.class);
  6. assertTrue(whileMatchFilter.getFilter() instanceof RowFilter);
  7. RowFilter rowFilter = (RowFilter) whileMatchFilter.getFilter();
  8. assertEquals(CompareOperator.NOT_EQUAL, rowFilter.getCompareOperator());
  9. assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
  10. BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
  11. assertEquals("row1", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
  12. }

代码示例来源:origin: apache/drill

  1. public HBaseScanSpec parseTree() {
  2. HBaseScanSpec parsedSpec = le.accept(this, null);
  3. if (parsedSpec != null) {
  4. parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
  5. /*
  6. * If RowFilter is THE filter attached to the scan specification,
  7. * remove it since its effect is also achieved through startRow and stopRow.
  8. */
  9. Filter filter = parsedSpec.getFilter();
  10. if (filter instanceof RowFilter &&
  11. ((RowFilter)filter).getOperator() != CompareOp.NOT_EQUAL &&
  12. ((RowFilter)filter).getComparator() instanceof BinaryComparator) {
  13. parsedSpec = new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), null);
  14. }
  15. }
  16. return parsedSpec;
  17. }

代码示例来源:origin: com.google.cloud.bigtable/bigtable-hbase

  1. /** {@inheritDoc} */
  2. @Override
  3. public Filter adapt(FilterAdapterContext context,
  4. org.apache.hadoop.hbase.filter.RowFilter filter) throws IOException {
  5. CompareOp compareOp = filter.getOperator();
  6. if (compareOp != CompareFilter.CompareOp.EQUAL) {
  7. throw new IllegalStateException(String.format("Cannot adapt operator %s",
  8. compareOp == null ? null : compareOp.getClass().getCanonicalName()));
  9. }
  10. ByteArrayComparable comparator = filter.getComparator();
  11. ByteString regexValue;
  12. if (comparator == null) {
  13. throw new IllegalStateException("Comparator cannot be null");
  14. } else if (comparator instanceof RegexStringComparator) {
  15. regexValue = ByteString.copyFrom(comparator.getValue());
  16. } else if (comparator instanceof BinaryComparator) {
  17. regexValue =
  18. ReaderExpressionHelper.quoteRegularExpression(comparator.getValue());
  19. } else {
  20. throw new IllegalStateException(String.format("Cannot adapt comparator %s", comparator
  21. .getClass().getCanonicalName()));
  22. }
  23. return FILTERS.key().regex(regexValue);
  24. }

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

  1. /** {@inheritDoc} */
  2. @Override
  3. public Filter adapt(FilterAdapterContext context,
  4. org.apache.hadoop.hbase.filter.RowFilter filter) throws IOException {
  5. CompareOp compareOp = filter.getOperator();
  6. if (compareOp != CompareFilter.CompareOp.EQUAL) {
  7. throw new IllegalStateException(String.format("Cannot adapt operator %s",
  8. compareOp == null ? null : compareOp.getClass().getCanonicalName()));
  9. }
  10. ByteArrayComparable comparator = filter.getComparator();
  11. ByteString regexValue;
  12. if (comparator == null) {
  13. throw new IllegalStateException("Comparator cannot be null");
  14. } else if (comparator instanceof RegexStringComparator) {
  15. regexValue = ByteString.copyFrom(comparator.getValue());
  16. } else if (comparator instanceof BinaryComparator) {
  17. regexValue =
  18. ReaderExpressionHelper.quoteRegularExpression(comparator.getValue());
  19. } else {
  20. throw new IllegalStateException(String.format("Cannot adapt comparator %s", comparator
  21. .getClass().getCanonicalName()));
  22. }
  23. return FILTERS.key().regex(regexValue);
  24. }

代码示例来源:origin: com.google.cloud.bigtable/bigtable-hbase

  1. /** {@inheritDoc} */
  2. @Override
  3. public FilterSupportStatus isFilterSupported(
  4. FilterAdapterContext context,
  5. org.apache.hadoop.hbase.filter.RowFilter filter) {
  6. ByteArrayComparable comparator = filter.getComparator();
  7. if (!(comparator instanceof RegexStringComparator) && !(comparator instanceof BinaryComparator)) {
  8. return FilterSupportStatus.newNotSupported(comparator.getClass().getName()
  9. + " comparator is not supported");
  10. }
  11. if (filter.getOperator() != CompareFilter.CompareOp.EQUAL) {
  12. return FilterSupportStatus.newNotSupported(filter.getOperator()
  13. + " operator is not supported");
  14. }
  15. return FilterSupportStatus.SUPPORTED;
  16. }
  17. }

代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client

  1. /** {@inheritDoc} */
  2. @Override
  3. public FilterSupportStatus isFilterSupported(
  4. FilterAdapterContext context,
  5. org.apache.hadoop.hbase.filter.RowFilter filter) {
  6. ByteArrayComparable comparator = filter.getComparator();
  7. if (!(comparator instanceof RegexStringComparator) && !(comparator instanceof BinaryComparator)) {
  8. return FilterSupportStatus.newNotSupported(comparator.getClass().getName()
  9. + " comparator is not supported");
  10. }
  11. if (filter.getOperator() != CompareFilter.CompareOp.EQUAL) {
  12. return FilterSupportStatus.newNotSupported(filter.getOperator()
  13. + " operator is not supported");
  14. }
  15. return FilterSupportStatus.SUPPORTED;
  16. }
  17. }

代码示例来源:origin: org.apache.drill.contrib/drill-storage-hbase

  1. public HBaseScanSpec parseTree() {
  2. HBaseScanSpec parsedSpec = le.accept(this, null);
  3. if (parsedSpec != null) {
  4. parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
  5. /*
  6. * If RowFilter is THE filter attached to the scan specification,
  7. * remove it since its effect is also achieved through startRow and stopRow.
  8. */
  9. if (parsedSpec.filter instanceof RowFilter &&
  10. ((RowFilter)parsedSpec.filter).getOperator() != CompareOp.NOT_EQUAL &&
  11. ((RowFilter)parsedSpec.filter).getComparator() instanceof BinaryComparator) {
  12. parsedSpec.filter = null;
  13. }
  14. }
  15. return parsedSpec;
  16. }

代码示例来源:origin: org.apache.hbase/hbase-server

  1. @Test
  2. public void testRowFilter() throws IOException {
  3. String filterString = "RowFilter ( =, 'binary:regionse')";
  4. RowFilter rowFilter =
  5. doTestFilter(filterString, RowFilter.class);
  6. assertEquals(CompareOperator.EQUAL, rowFilter.getCompareOperator());
  7. assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
  8. BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
  9. assertEquals("regionse", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
  10. }

代码示例来源:origin: dremio/dremio-oss

  1. public HBaseScanSpec parseTree() {
  2. HBaseScanSpec parsedSpec = le.accept(this, null);
  3. if (parsedSpec != null) {
  4. parsedSpec = mergeScanSpecs("booleanAnd", oldSpec, parsedSpec);
  5. /*
  6. * If RowFilter is THE filter attached to the scan specification,
  7. * remove it since its effect is also achieved through startRow and stopRow.
  8. */
  9. Filter parsedFilter = HBaseUtils.deserializeFilter(parsedSpec.getSerializedFilter());
  10. if (parsedFilter instanceof RowFilter && ((RowFilter)parsedFilter).getComparator() instanceof BinaryComparator) {
  11. return new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), (byte[]) null);
  12. }
  13. }
  14. return parsedSpec;
  15. }

代码示例来源:origin: org.apache.hbase/hbase-server

  1. @Test
  2. public void testWhileFilter() throws IOException {
  3. String filterString = " WHILE RowFilter ( !=, 'binary:row1')";
  4. WhileMatchFilter whileMatchFilter =
  5. doTestFilter(filterString, WhileMatchFilter.class);
  6. assertTrue(whileMatchFilter.getFilter() instanceof RowFilter);
  7. RowFilter rowFilter = (RowFilter) whileMatchFilter.getFilter();
  8. assertEquals(CompareOperator.NOT_EQUAL, rowFilter.getCompareOperator());
  9. assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
  10. BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
  11. assertEquals("row1", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
  12. }

代码示例来源:origin: org.apache.drill.contrib/drill-format-mapr

  1. public HBaseScanSpec parseTree() {
  2. HBaseScanSpec parsedSpec = le.accept(this, null);
  3. if (parsedSpec != null) {
  4. parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
  5. /*
  6. * If RowFilter is THE filter attached to the scan specification,
  7. * remove it since its effect is also achieved through startRow and stopRow.
  8. */
  9. Filter filter = parsedSpec.getFilter();
  10. if (filter instanceof RowFilter &&
  11. ((RowFilter)filter).getOperator() != CompareOp.NOT_EQUAL &&
  12. ((RowFilter)filter).getComparator() instanceof BinaryComparator) {
  13. parsedSpec = new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), null);
  14. }
  15. }
  16. return parsedSpec;
  17. }

相关文章