Search in sources :

Example 71 with SingleColumnValueFilter

use of org.apache.hadoop.hbase.filter.SingleColumnValueFilter in project hbase by apache.

the class TestHRegion method testCheckAndMutate_wrongRow.

@Test
@Deprecated
public void testCheckAndMutate_wrongRow() throws Throwable {
    final byte[] wrongRow = Bytes.toBytes("wrongRow");
    // Setting up region
    this.region = initHRegion(tableName, method, CONF, fam1);
    try {
        region.checkAndMutate(row, fam1, qual1, CompareOperator.EQUAL, new BinaryComparator(value1), new Put(wrongRow).addColumn(fam1, qual1, value1));
        fail("should throw DoNotRetryIOException");
    } catch (DoNotRetryIOException e) {
        assertEquals("The row of the action <wrongRow> doesn't match the original one <rowA>", e.getMessage());
    }
    try {
        region.checkAndMutate(row, new SingleColumnValueFilter(fam1, qual1, CompareOperator.EQUAL, value1), new Put(wrongRow).addColumn(fam1, qual1, value1));
        fail("should throw DoNotRetryIOException");
    } catch (DoNotRetryIOException e) {
        assertEquals("The row of the action <wrongRow> doesn't match the original one <rowA>", e.getMessage());
    }
    try {
        region.checkAndRowMutate(row, fam1, qual1, CompareOperator.EQUAL, new BinaryComparator(value1), new RowMutations(wrongRow).add((Mutation) new Put(wrongRow).addColumn(fam1, qual1, value1)).add((Mutation) new Delete(wrongRow).addColumns(fam1, qual2)));
        fail("should throw DoNotRetryIOException");
    } catch (DoNotRetryIOException e) {
        assertEquals("The row of the action <wrongRow> doesn't match the original one <rowA>", e.getMessage());
    }
    try {
        region.checkAndRowMutate(row, new SingleColumnValueFilter(fam1, qual1, CompareOperator.EQUAL, value1), new RowMutations(wrongRow).add((Mutation) new Put(wrongRow).addColumn(fam1, qual1, value1)).add((Mutation) new Delete(wrongRow).addColumns(fam1, qual2)));
        fail("should throw DoNotRetryIOException");
    } catch (DoNotRetryIOException e) {
        assertEquals("The row of the action <wrongRow> doesn't match the original one <rowA>", e.getMessage());
    }
}
Also used : Delete(org.apache.hadoop.hbase.client.Delete) SingleColumnValueFilter(org.apache.hadoop.hbase.filter.SingleColumnValueFilter) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) Mutation(org.apache.hadoop.hbase.client.Mutation) BinaryComparator(org.apache.hadoop.hbase.filter.BinaryComparator) Put(org.apache.hadoop.hbase.client.Put) RowMutations(org.apache.hadoop.hbase.client.RowMutations) Test(org.junit.Test)

Aggregations

SingleColumnValueFilter (org.apache.hadoop.hbase.filter.SingleColumnValueFilter)71 Test (org.junit.Test)39 FilterList (org.apache.hadoop.hbase.filter.FilterList)28 BinaryComparator (org.apache.hadoop.hbase.filter.BinaryComparator)16 Scan (org.apache.hadoop.hbase.client.Scan)15 Put (org.apache.hadoop.hbase.client.Put)13 Result (org.apache.hadoop.hbase.client.Result)13 Filter (org.apache.hadoop.hbase.filter.Filter)12 Delete (org.apache.hadoop.hbase.client.Delete)8 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)8 RowFilter (org.apache.hadoop.hbase.filter.RowFilter)8 TableName (org.apache.hadoop.hbase.TableName)7 Table (org.apache.hadoop.hbase.client.Table)7 BitComparator (org.apache.hadoop.hbase.filter.BitComparator)7 ArrayList (java.util.ArrayList)6 CheckAndMutateResult (org.apache.hadoop.hbase.client.CheckAndMutateResult)6 Get (org.apache.hadoop.hbase.client.Get)6 Mutation (org.apache.hadoop.hbase.client.Mutation)6 ByteArrayComparable (org.apache.hadoop.hbase.filter.ByteArrayComparable)6 CompareOp (org.apache.hadoop.hbase.filter.CompareFilter.CompareOp)6