本文整理汇总了Java中org.apache.hadoop.hbase.filter.CompareFilter类的典型用法代码示例。如果您正苦于以下问题:Java CompareFilter类的具体用法?Java CompareFilter怎么用?Java CompareFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompareFilter类属于org.apache.hadoop.hbase.filter包,在下文中一共展示了CompareFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkAndDelete
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Override
public boolean checkAndDelete(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Delete delete) throws IOException {
if (!Arrays.equals(delete.getRow(), row)) {
throw new UnsupportedOperationException("CheckAndDelete does not support check one row but delete other row");
}
ODelete odelete = ElementConvertor.toOtsDelete(delete, this.tablestoreColumnMapping);
Condition condition = ElementConvertor.toOtsCondition(family, qualifier, compareOp, value, this.tablestoreColumnMapping);
odelete.setCondition(condition);
try {
this.tablestoreAdaptor.delete(tableNameStr, odelete);
} catch (IOException ex) {
if (ex.getCause().getCause() instanceof TableStoreException) {
TableStoreException exception = (TableStoreException)ex.getCause().getCause();
if (exception.getErrorCode().equals("OTSConditionCheckFail")) {
return false;
}
}
throw ex;
}
return true;
}
示例2: checkAndPut
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Override
public boolean checkAndPut(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, Put put) throws IOException {
if (!Arrays.equals(put.getRow(), row)) {
throw new UnsupportedOperationException("CheckAndPut does not support check one row but put other row");
}
OPut oput = ElementConvertor.toOtsPut(put, this.tablestoreColumnMapping);
Condition condition = ElementConvertor.toOtsCondition(family, qualifier, compareOp, value, this.tablestoreColumnMapping);
oput.setCondition(condition);
try {
this.tablestoreAdaptor.put(tableNameStr, oput);
} catch (IOException ex) {
if (ex.getCause().getCause() instanceof TableStoreException) {
TableStoreException exception = (TableStoreException)ex.getCause().getCause();
if (exception.getErrorCode().equals("OTSConditionCheckFail")) {
return false;
}
}
throw ex;
}
return true;
}
示例3: checkAndMutate
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Override
public boolean checkAndMutate(byte[] row, byte[] family, byte[] qualifier, CompareFilter.CompareOp compareOp, byte[] value, RowMutations mutation) throws IOException {
if (!Arrays.equals(mutation.getRow(), row)) {
throw new UnsupportedOperationException("CheckAndMutation does not support check one row but Mutate other row");
}
OUpdate oupdate = ElementConvertor.toOtsUpdate(mutation, this.tablestoreColumnMapping);
Condition condition = ElementConvertor.toOtsCondition(family, qualifier, compareOp, value, this.tablestoreColumnMapping);
oupdate.setCondition(condition);
try {
this.tablestoreAdaptor.update(tableNameStr, oupdate);
} catch (IOException ex) {
if (ex.getCause().getCause() instanceof TableStoreException) {
TableStoreException exception = (TableStoreException)ex.getCause().getCause();
if (exception.getErrorCode().equals("OTSConditionCheckFail")) {
return false;
}
}
throw ex;
}
return true;
}
示例4: testCheckNullSucceeded
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testCheckNullSucceeded() throws IOException {
clean();
Put put = new Put(Bytes.toBytes("pk0"));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("col_1_var"));
RowMutations mutaions = new RowMutations(Bytes.toBytes("pk0"));
mutaions.add(put);
table.checkAndMutate(Bytes.toBytes("pk0"), Bytes.toBytes(familyName), Bytes.toBytes("col_1"), CompareFilter.CompareOp.EQUAL,
null, mutaions);
Get get = new Get(Bytes.toBytes("pk0"));
Result result = table.get(get);
String value = Bytes.toString(result.getValue(Bytes.toBytes(familyName), Bytes.toBytes("col_1")));
assertEquals("col_1_var", value);
}
示例5: testMutationWithOneDelete
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testMutationWithOneDelete() throws IOException {
clean();
Put put = new Put(Bytes.toBytes("pk0"));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("col_1_var"));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_2"), Bytes.toBytes("col_2_var"));
table.put(put);
Delete delete = new Delete(Bytes.toBytes("pk0"));
delete.addColumns(Bytes.toBytes(familyName), Bytes.toBytes("col_2"));
RowMutations mutaions = new RowMutations(Bytes.toBytes("pk0"));
mutaions.add(delete);
table.checkAndMutate(Bytes.toBytes("pk0"), Bytes.toBytes(familyName), Bytes.toBytes("col_1"), CompareFilter.CompareOp.GREATER_OR_EQUAL,
Bytes.toBytes("col_1_var"), mutaions);
Get get = new Get(Bytes.toBytes("pk0"));
Result result = table.get(get);
String value = Bytes.toString(result.getValue(Bytes.toBytes(familyName), Bytes.toBytes("col_1")));
assertEquals("col_1_var", value);
byte[] col2 = result.getValue(Bytes.toBytes(familyName), Bytes.toBytes("col_2"));
assertTrue(col2 == null);
}
示例6: testTwoFilterWithMustAllPassFailed
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testTwoFilterWithMustAllPassFailed() throws IOException {
clean();
{
Put put = new Put(Bytes.toBytes(rowPrefix));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("col_1_var"));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_2"), Bytes.toBytes("col_2_var"));
table.put(put);
}
{
Get get = new Get(Bytes.toBytes(rowPrefix));
Filter filter1 = new SingleColumnValueFilter(Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.EQUAL, Bytes.toBytes("col_1_var"));
Filter filter2 = new SingleColumnValueFilter(Bytes.toBytes(familyName), Bytes.toBytes("col_2"),
CompareFilter.CompareOp.NOT_EQUAL, Bytes.toBytes("col_2_var"));
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
filterList.addFilter(filter1);
filterList.addFilter(filter2);
get.setFilter(filterList);
Result result = table.get(get);
assertTrue(result.getRow() == null);
}
}
示例7: testTwoFilterWithMustOnePassFailed
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testTwoFilterWithMustOnePassFailed() throws IOException {
clean();
{
Put put = new Put(Bytes.toBytes(rowPrefix));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("col_1_var"));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_2"), Bytes.toBytes("col_2_var"));
table.put(put);
}
{
Get get = new Get(Bytes.toBytes(rowPrefix));
Filter filter1 = new SingleColumnValueFilter(Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.NOT_EQUAL, Bytes.toBytes("col_1_var"));
Filter filter2 = new SingleColumnValueFilter(Bytes.toBytes(familyName), Bytes.toBytes("col_2"),
CompareFilter.CompareOp.NOT_EQUAL, Bytes.toBytes("col_2_var"));
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);
filterList.addFilter(filter1);
filterList.addFilter(filter2);
get.setFilter(filterList);
Result result = table.get(get);
assertTrue(result.getRow() == null);
}
}
示例8: testEqualAndSuccess2
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testEqualAndSuccess2() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.EQUAL, Bytes.toBytes("val_1"), delete);
assertTrue(ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result == null);
}
示例9: testEqualAndFailed2
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testEqualAndFailed2() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.EQUAL, Bytes.toBytes("val_3"), delete);
assertTrue(!ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result != null);
}
示例10: testNotEqualAndSuccess
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testNotEqualAndSuccess() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.NOT_EQUAL, Bytes.toBytes("val_3"), delete);
assertTrue(ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result == null);
}
示例11: testNotEqualAndFailed
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testNotEqualAndFailed() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.NOT_EQUAL, Bytes.toBytes("val_1"), delete);
assertTrue(!ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result != null);
}
示例12: testGreaterAndSuccess
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testGreaterAndSuccess() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.GREATER, Bytes.toBytes("val_0"), delete);
assertTrue(ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result == null);
}
示例13: testGreaterAndFailed
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testGreaterAndFailed() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.GREATER, Bytes.toBytes("val_1"), delete);
assertTrue(!ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result != null);
}
示例14: testGreaterOrEqualAndSuccess
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testGreaterOrEqualAndSuccess() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.GREATER_OR_EQUAL, Bytes.toBytes("val_0"), delete);
assertTrue(ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result == null);
}
示例15: testGreaterOrEqualAndFailed
import org.apache.hadoop.hbase.filter.CompareFilter; //导入依赖的package包/类
@Test
public void testGreaterOrEqualAndFailed() throws IOException {
clean();
String row = rowPrefix;
{
Put put = new Put(Bytes.toBytes(row));
put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes("col_1"), Bytes.toBytes("val_1"));
table.put(put);
}
Delete delete = new Delete(Bytes.toBytes(row));
boolean ret = table.checkAndDelete(Bytes.toBytes(row), Bytes.toBytes(familyName), Bytes.toBytes("col_1"),
CompareFilter.CompareOp.GREATER_OR_EQUAL, Bytes.toBytes("val_4"), delete);
assertTrue(!ret);
Get get = new Get(Bytes.toBytes(row));
byte[] result = table.get(get).getRow();
assertTrue(result != null);
}