本文整理匯總了Java中org.apache.hadoop.hbase.filter.SingleColumnValueFilter.setLatestVersionOnly方法的典型用法代碼示例。如果您正苦於以下問題:Java SingleColumnValueFilter.setLatestVersionOnly方法的具體用法?Java SingleColumnValueFilter.setLatestVersionOnly怎麽用?Java SingleColumnValueFilter.setLatestVersionOnly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.hadoop.hbase.filter.SingleColumnValueFilter
的用法示例。
在下文中一共展示了SingleColumnValueFilter.setLatestVersionOnly方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: latestVersionOnlyComparisonsAreDone
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter; //導入方法依賴的package包/類
@Test
public void latestVersionOnlyComparisonsAreDone() throws IOException {
byte[] filterValue = Bytes.toBytes("foobar");
byte[] qualifier = Bytes.toBytes("someColumn");
byte[] family = Bytes.toBytes("f");
SingleColumnValueFilter filter = new SingleColumnValueFilter(
family,
qualifier,
CompareFilter.CompareOp.EQUAL,
new BinaryComparator(filterValue));
filter.setFilterIfMissing(false);
filter.setLatestVersionOnly(true);
RowFilter adaptedFilter = adapter.adapt(
new FilterAdapterContext(new Scan()),
filter);
assertFilterIfNotMIssingMatches(
family,
qualifier,
filterValue,
1 /* latest version only = true */,
adaptedFilter);
}
示例2: allVersionComparisonAreDone
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter; //導入方法依賴的package包/類
@Test
public void allVersionComparisonAreDone() throws IOException {
byte[] filterValue = Bytes.toBytes("foobar");
byte[] qualifier = Bytes.toBytes("someColumn");
byte[] family = Bytes.toBytes("f");
SingleColumnValueFilter filter = new SingleColumnValueFilter(
family,
qualifier,
CompareFilter.CompareOp.EQUAL,
new BinaryComparator(filterValue));
filter.setFilterIfMissing(false);
filter.setLatestVersionOnly(false);
RowFilter adaptedFilter = adapter.adapt(
new FilterAdapterContext(new Scan()),
filter);
assertFilterIfNotMIssingMatches(
family,
qualifier,
filterValue,
Integer.MAX_VALUE /* latest version only = false */,
adaptedFilter);
}
示例3: main
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException {
Configuration conf = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(conf);
HTable table = null;
// if (admin.tableExists(tableName)) {
// indexadmin.disableTable(tableName);
// indexadmin.deleteTable(tableName);
// }
if (!admin.tableExists(tableName)) {
HTableDescriptor tableDesc = new HTableDescriptor(tableName);
IndexDescriptor index1 = new IndexDescriptor(Bytes.toBytes("c1"), DataType.DOUBLE);
IndexColumnDescriptor family = new IndexColumnDescriptor("f");
family.addIndex(index1);
tableDesc.addFamily(family);
admin.createTable(tableDesc);
table = new HTable(conf, tableName);
Put put = new Put(Bytes.toBytes("001"));
put.add(Bytes.toBytes("f"), Bytes.toBytes("c1"), 10, Bytes.toBytes(120.0));
put.add(Bytes.toBytes("f"), Bytes.toBytes("c2"), 10, Bytes.toBytes("a"));
table.put(put);
put = new Put(Bytes.toBytes("001"));
put.add(Bytes.toBytes("f"), Bytes.toBytes("c1"), 20, Bytes.toBytes(90.0));
put.add(Bytes.toBytes("f"), Bytes.toBytes("c2"), 20, Bytes.toBytes("a"));
table.put(put);
put = new Put(Bytes.toBytes("002"));
put.add(Bytes.toBytes("f"), Bytes.toBytes("c1"), 30, Bytes.toBytes(150.0));
put.add(Bytes.toBytes("f"), Bytes.toBytes("c2"), 30, Bytes.toBytes("a"));
table.put(put);
}
admin.close();
if (table == null) {
table = new HTable(conf, tableName);
}
Scan scan = new Scan();
RangeList list = new RangeList();
list.addRange(new Range(Bytes.toBytes("f:c1"), Bytes.toBytes(100.0), CompareOp.GREATER, null,
CompareOp.NO_OP));
SingleColumnValueFilter filter =
new SingleColumnValueFilter(Bytes.toBytes("f"), Bytes.toBytes("c1"), CompareOp.GREATER,
Bytes.toBytes(100.0));
filter.setLatestVersionOnly(false);
scan.setFilter(filter);
// scan.setAttribute(IndexConstants.SCAN_INDEX_RANGE, Writables.getBytes(list));
scan.setMaxVersions();
Result result = null;
ResultScanner rs = table.getScanner(scan);
while ((result = rs.next()) != null) {
System.out.println(result);
}
rs.close();
table.close();
}
示例4: filterIfMissingIsApplied
import org.apache.hadoop.hbase.filter.SingleColumnValueFilter; //導入方法依賴的package包/類
@Test
public void filterIfMissingIsApplied() throws IOException {
byte[] filterValue = Bytes.toBytes("foobar");
byte[] qualifier = Bytes.toBytes("someColumn");
byte[] family = Bytes.toBytes("f");
SingleColumnValueFilter filter = new SingleColumnValueFilter(
family,
qualifier,
CompareFilter.CompareOp.EQUAL,
new BinaryComparator(filterValue));
filter.setFilterIfMissing(true);
filter.setLatestVersionOnly(false);
RowFilter adaptedFilter = adapter.adapt(
new FilterAdapterContext(new Scan()),
filter);
assertColumnSpecification(
Bytes.toString(family),
qualifier,
Integer.MAX_VALUE,
adaptedFilter
.getCondition()
.getPredicateFilter()
.getChain()
.getFilters(0)
.getChain());
Assert.assertEquals(
RowFilter.newBuilder()
.setValueRegexFilter(ByteString.copyFromUtf8("foobar"))
.build(),
adaptedFilter
.getCondition()
.getPredicateFilter()
.getChain()
.getFilters(1));
Assert.assertEquals(
RowFilter.newBuilder()
.setCellsPerColumnLimitFilter(Integer.MAX_VALUE)
.build(),
adaptedFilter.getCondition().getTrueFilter());
}