當前位置: 首頁>>代碼示例>>Java>>正文


Java CompareFilter類代碼示例

本文整理匯總了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;
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:25,代碼來源:TablestoreTable.java

示例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;
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:24,代碼來源:TablestoreTable.java

示例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;
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:24,代碼來源:TablestoreTable.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:19,代碼來源:TestCheckAndMutate.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:27,代碼來源:TestCheckAndMutate.java

示例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);
    }
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:26,代碼來源:TestFilterList.java

示例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);
    }
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:26,代碼來源:TestFilterList.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java

示例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);
}
 
開發者ID:aliyun,項目名稱:aliyun-tablestore-hbase-client,代碼行數:23,代碼來源:TestCheckAndDeleteRow.java


注:本文中的org.apache.hadoop.hbase.filter.CompareFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。