Java Code Examples for org.apache.hadoop.hbase.CompareOperator#LESS

The following examples show how to use org.apache.hadoop.hbase.CompareOperator#LESS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HbaseQuery.java    From tephra with MIT License 6 votes vote down vote up
protected CompareOperator getCompare(Where where) {
    if (where == Where.Equals)
        return CompareOperator.EQUAL;

    if (where == Where.NotEquals)
        return CompareOperator.NOT_EQUAL;

    if (where == Where.Less)
        return CompareOperator.LESS;

    if (where == Where.LessEquals)
        return CompareOperator.LESS_OR_EQUAL;

    if (where == Where.Greater)
        return CompareOperator.GREATER;

    if (where == Where.GreaterEquals)
        return CompareOperator.GREATER_OR_EQUAL;

    return CompareOperator.EQUAL;
}
 
Example 2
Source File: TestFilterSerialization.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testSingleColumnValueFilter() throws Exception {
  // null family/column SingleColumnValueFilter
  SingleColumnValueFilter singleColumnValueFilter =
    new SingleColumnValueFilter(null, null,
    CompareOperator.LESS, Bytes.toBytes("value"));
  assertTrue(singleColumnValueFilter.areSerializedFieldsEqual(
    ProtobufUtil.toFilter(ProtobufUtil.toFilter(singleColumnValueFilter))));

  // non-null family/column SingleColumnValueFilter
  singleColumnValueFilter =
    new SingleColumnValueFilter(Bytes.toBytes("family"), Bytes.toBytes("qualifier"),
     CompareOperator.NOT_EQUAL, new NullComparator(), true, true);
  assertTrue(singleColumnValueFilter.areSerializedFieldsEqual(
    ProtobufUtil.toFilter(ProtobufUtil.toFilter(singleColumnValueFilter))));
}
 
Example 3
Source File: ParseFilter.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * Takes a compareOperator symbol as a byte array and returns the corresponding CompareOperator
 * @param compareOpAsByteArray the comparatorOperator symbol as a byte array
 * @return the Compare Operator
 */
public static CompareOperator createCompareOperator (byte [] compareOpAsByteArray) {
  ByteBuffer compareOp = ByteBuffer.wrap(compareOpAsByteArray);
  if (compareOp.equals(ParseConstants.LESS_THAN_BUFFER))
    return CompareOperator.LESS;
  else if (compareOp.equals(ParseConstants.LESS_THAN_OR_EQUAL_TO_BUFFER))
    return CompareOperator.LESS_OR_EQUAL;
  else if (compareOp.equals(ParseConstants.GREATER_THAN_BUFFER))
    return CompareOperator.GREATER;
  else if (compareOp.equals(ParseConstants.GREATER_THAN_OR_EQUAL_TO_BUFFER))
    return CompareOperator.GREATER_OR_EQUAL;
  else if (compareOp.equals(ParseConstants.NOT_EQUAL_TO_BUFFER))
    return CompareOperator.NOT_EQUAL;
  else if (compareOp.equals(ParseConstants.EQUAL_TO_BUFFER))
    return CompareOperator.EQUAL;
  else
    throw new IllegalArgumentException("Invalid compare operator");
}
 
Example 4
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static CompareOperator compareOpFromThrift(TCompareOperator tCompareOp) {
  switch (tCompareOp.getValue()) {
    case 0: return CompareOperator.LESS;
    case 1: return CompareOperator.LESS_OR_EQUAL;
    case 2: return CompareOperator.EQUAL;
    case 3: return CompareOperator.NOT_EQUAL;
    case 4: return CompareOperator.GREATER_OR_EQUAL;
    case 5: return CompareOperator.GREATER;
    case 6: return CompareOperator.NO_OP;
    default: return null;
  }
}
 
Example 5
Source File: TestFiltersWithBinaryComponentComparator.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void setRowFilters(FilterList filterList) {
  //offset for b as it is second component of "a+b+c+d"
  //'a' is at offset 0
  int bOffset = 4;
  byte[] b10 = Bytes.toBytes(10); //tests b > 10
  Filter b10Filter = new RowFilter(CompareOperator.GREATER,
          new BinaryComponentComparator(b10,bOffset));
  filterList.addFilter(b10Filter);

  byte[] b20  = Bytes.toBytes(20); //tests b < 20
  Filter b20Filter = new RowFilter(CompareOperator.LESS,
          new BinaryComponentComparator(b20,bOffset));
  filterList.addFilter(b20Filter);

  //offset for c as it is third component of "a+b+c+d"
  int cOffset = 8;
  byte[] c90  = Bytes.toBytes(90); //tests c > 90
  Filter c90Filter = new RowFilter(CompareOperator.GREATER,
          new BinaryComponentComparator(c90,cOffset));
  filterList.addFilter(c90Filter);

  byte[] c100  = Bytes.toBytes(100); //tests c < 100
  Filter c100Filter = new RowFilter(CompareOperator.LESS,
          new BinaryComponentComparator(c100,cOffset));
  filterList.addFilter(c100Filter);

  //offset for d as it is fourth component of "a+b+c+d"
  int dOffset = 12;
  byte[] d1   = Bytes.toBytes(1); //tests d == 1
  Filter dFilter  = new RowFilter(CompareOperator.EQUAL,
          new BinaryComponentComparator(d1,dOffset));

  filterList.addFilter(dFilter);

}