本文整理了Java中org.apache.hadoop.hbase.filter.RowFilter.getComparator
方法的一些代码示例,展示了RowFilter.getComparator
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RowFilter.getComparator
方法的具体详情如下:
包路径:org.apache.hadoop.hbase.filter.RowFilter
类名称:RowFilter
方法名:getComparator
暂无
代码示例来源:origin: apache/drill
public HBaseScanSpec parseTree() {
HBaseScanSpec parsedSpec = le.accept(this, null);
if (parsedSpec != null) {
parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
/*
* If RowFilter is THE filter attached to the scan specification,
* remove it since its effect is also achieved through startRow and stopRow.
*/
if (parsedSpec.filter instanceof RowFilter &&
((RowFilter)parsedSpec.filter).getOperator() != CompareOp.NOT_EQUAL &&
((RowFilter)parsedSpec.filter).getComparator() instanceof BinaryComparator) {
parsedSpec.filter = null;
}
}
return parsedSpec;
}
代码示例来源:origin: apache/hbase
@Test
public void testRowFilter() throws IOException {
String filterString = "RowFilter ( =, 'binary:regionse')";
RowFilter rowFilter =
doTestFilter(filterString, RowFilter.class);
assertEquals(CompareOperator.EQUAL, rowFilter.getCompareOperator());
assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
assertEquals("regionse", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
}
代码示例来源:origin: apache/hbase
@Test
public void testWhileFilter() throws IOException {
String filterString = " WHILE RowFilter ( !=, 'binary:row1')";
WhileMatchFilter whileMatchFilter =
doTestFilter(filterString, WhileMatchFilter.class);
assertTrue(whileMatchFilter.getFilter() instanceof RowFilter);
RowFilter rowFilter = (RowFilter) whileMatchFilter.getFilter();
assertEquals(CompareOperator.NOT_EQUAL, rowFilter.getCompareOperator());
assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
assertEquals("row1", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
}
代码示例来源:origin: apache/drill
public HBaseScanSpec parseTree() {
HBaseScanSpec parsedSpec = le.accept(this, null);
if (parsedSpec != null) {
parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
/*
* If RowFilter is THE filter attached to the scan specification,
* remove it since its effect is also achieved through startRow and stopRow.
*/
Filter filter = parsedSpec.getFilter();
if (filter instanceof RowFilter &&
((RowFilter)filter).getOperator() != CompareOp.NOT_EQUAL &&
((RowFilter)filter).getComparator() instanceof BinaryComparator) {
parsedSpec = new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), null);
}
}
return parsedSpec;
}
代码示例来源:origin: com.google.cloud.bigtable/bigtable-hbase
/** {@inheritDoc} */
@Override
public Filter adapt(FilterAdapterContext context,
org.apache.hadoop.hbase.filter.RowFilter filter) throws IOException {
CompareOp compareOp = filter.getOperator();
if (compareOp != CompareFilter.CompareOp.EQUAL) {
throw new IllegalStateException(String.format("Cannot adapt operator %s",
compareOp == null ? null : compareOp.getClass().getCanonicalName()));
}
ByteArrayComparable comparator = filter.getComparator();
ByteString regexValue;
if (comparator == null) {
throw new IllegalStateException("Comparator cannot be null");
} else if (comparator instanceof RegexStringComparator) {
regexValue = ByteString.copyFrom(comparator.getValue());
} else if (comparator instanceof BinaryComparator) {
regexValue =
ReaderExpressionHelper.quoteRegularExpression(comparator.getValue());
} else {
throw new IllegalStateException(String.format("Cannot adapt comparator %s", comparator
.getClass().getCanonicalName()));
}
return FILTERS.key().regex(regexValue);
}
代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client
/** {@inheritDoc} */
@Override
public Filter adapt(FilterAdapterContext context,
org.apache.hadoop.hbase.filter.RowFilter filter) throws IOException {
CompareOp compareOp = filter.getOperator();
if (compareOp != CompareFilter.CompareOp.EQUAL) {
throw new IllegalStateException(String.format("Cannot adapt operator %s",
compareOp == null ? null : compareOp.getClass().getCanonicalName()));
}
ByteArrayComparable comparator = filter.getComparator();
ByteString regexValue;
if (comparator == null) {
throw new IllegalStateException("Comparator cannot be null");
} else if (comparator instanceof RegexStringComparator) {
regexValue = ByteString.copyFrom(comparator.getValue());
} else if (comparator instanceof BinaryComparator) {
regexValue =
ReaderExpressionHelper.quoteRegularExpression(comparator.getValue());
} else {
throw new IllegalStateException(String.format("Cannot adapt comparator %s", comparator
.getClass().getCanonicalName()));
}
return FILTERS.key().regex(regexValue);
}
代码示例来源:origin: com.google.cloud.bigtable/bigtable-hbase
/** {@inheritDoc} */
@Override
public FilterSupportStatus isFilterSupported(
FilterAdapterContext context,
org.apache.hadoop.hbase.filter.RowFilter filter) {
ByteArrayComparable comparator = filter.getComparator();
if (!(comparator instanceof RegexStringComparator) && !(comparator instanceof BinaryComparator)) {
return FilterSupportStatus.newNotSupported(comparator.getClass().getName()
+ " comparator is not supported");
}
if (filter.getOperator() != CompareFilter.CompareOp.EQUAL) {
return FilterSupportStatus.newNotSupported(filter.getOperator()
+ " operator is not supported");
}
return FilterSupportStatus.SUPPORTED;
}
}
代码示例来源:origin: GoogleCloudPlatform/cloud-bigtable-client
/** {@inheritDoc} */
@Override
public FilterSupportStatus isFilterSupported(
FilterAdapterContext context,
org.apache.hadoop.hbase.filter.RowFilter filter) {
ByteArrayComparable comparator = filter.getComparator();
if (!(comparator instanceof RegexStringComparator) && !(comparator instanceof BinaryComparator)) {
return FilterSupportStatus.newNotSupported(comparator.getClass().getName()
+ " comparator is not supported");
}
if (filter.getOperator() != CompareFilter.CompareOp.EQUAL) {
return FilterSupportStatus.newNotSupported(filter.getOperator()
+ " operator is not supported");
}
return FilterSupportStatus.SUPPORTED;
}
}
代码示例来源:origin: org.apache.drill.contrib/drill-storage-hbase
public HBaseScanSpec parseTree() {
HBaseScanSpec parsedSpec = le.accept(this, null);
if (parsedSpec != null) {
parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
/*
* If RowFilter is THE filter attached to the scan specification,
* remove it since its effect is also achieved through startRow and stopRow.
*/
if (parsedSpec.filter instanceof RowFilter &&
((RowFilter)parsedSpec.filter).getOperator() != CompareOp.NOT_EQUAL &&
((RowFilter)parsedSpec.filter).getComparator() instanceof BinaryComparator) {
parsedSpec.filter = null;
}
}
return parsedSpec;
}
代码示例来源:origin: org.apache.hbase/hbase-server
@Test
public void testRowFilter() throws IOException {
String filterString = "RowFilter ( =, 'binary:regionse')";
RowFilter rowFilter =
doTestFilter(filterString, RowFilter.class);
assertEquals(CompareOperator.EQUAL, rowFilter.getCompareOperator());
assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
assertEquals("regionse", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
}
代码示例来源:origin: dremio/dremio-oss
public HBaseScanSpec parseTree() {
HBaseScanSpec parsedSpec = le.accept(this, null);
if (parsedSpec != null) {
parsedSpec = mergeScanSpecs("booleanAnd", oldSpec, parsedSpec);
/*
* If RowFilter is THE filter attached to the scan specification,
* remove it since its effect is also achieved through startRow and stopRow.
*/
Filter parsedFilter = HBaseUtils.deserializeFilter(parsedSpec.getSerializedFilter());
if (parsedFilter instanceof RowFilter && ((RowFilter)parsedFilter).getComparator() instanceof BinaryComparator) {
return new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), (byte[]) null);
}
}
return parsedSpec;
}
代码示例来源:origin: org.apache.hbase/hbase-server
@Test
public void testWhileFilter() throws IOException {
String filterString = " WHILE RowFilter ( !=, 'binary:row1')";
WhileMatchFilter whileMatchFilter =
doTestFilter(filterString, WhileMatchFilter.class);
assertTrue(whileMatchFilter.getFilter() instanceof RowFilter);
RowFilter rowFilter = (RowFilter) whileMatchFilter.getFilter();
assertEquals(CompareOperator.NOT_EQUAL, rowFilter.getCompareOperator());
assertTrue(rowFilter.getComparator() instanceof BinaryComparator);
BinaryComparator binaryComparator = (BinaryComparator) rowFilter.getComparator();
assertEquals("row1", new String(binaryComparator.getValue(), StandardCharsets.UTF_8));
}
代码示例来源:origin: org.apache.drill.contrib/drill-format-mapr
public HBaseScanSpec parseTree() {
HBaseScanSpec parsedSpec = le.accept(this, null);
if (parsedSpec != null) {
parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getHBaseScanSpec(), parsedSpec);
/*
* If RowFilter is THE filter attached to the scan specification,
* remove it since its effect is also achieved through startRow and stopRow.
*/
Filter filter = parsedSpec.getFilter();
if (filter instanceof RowFilter &&
((RowFilter)filter).getOperator() != CompareOp.NOT_EQUAL &&
((RowFilter)filter).getComparator() instanceof BinaryComparator) {
parsedSpec = new HBaseScanSpec(parsedSpec.getTableName(), parsedSpec.getStartRow(), parsedSpec.getStopRow(), null);
}
}
return parsedSpec;
}
内容来源于网络,如有侵权,请联系作者删除!