A bitwise comparator used in comparison filters. Performs the specified bitwise operation on each of the bytes with the specified byte array. Returns whether the result is non-zero. Only EQUAL and NOT_EQUAL comparisons are valid with this comparator. @since 1.6
| 40 | * @since 1.6 |
| 41 | */ |
| 42 | public final class BitComparator extends FilterComparator { |
| 43 | |
| 44 | /** Bit operators. */ |
| 45 | public enum BitwiseOp { |
| 46 | /** Logical 'and'. */ |
| 47 | AND, |
| 48 | /** Logical 'or'. */ |
| 49 | OR, |
| 50 | /** Logical 'xor'. */ |
| 51 | XOR, |
| 52 | } |
| 53 | |
| 54 | private static final byte[] NAME = |
| 55 | Bytes.UTF8("org.apache.hadoop.hbase.filter.BitComparator"); |
| 56 | private static final byte CODE = 48; |
| 57 | |
| 58 | private final byte[] value; |
| 59 | private final BitwiseOp bit_operator; |
| 60 | |
| 61 | public BitComparator(byte[] value, BitwiseOp bitOperator) { |
| 62 | this.value = value; |
| 63 | this.bit_operator = bitOperator; |
| 64 | } |
| 65 | |
| 66 | public byte[] value() { |
| 67 | return value.clone(); |
| 68 | } |
| 69 | |
| 70 | public BitwiseOp bitwiseOperator() { |
| 71 | return bit_operator; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | byte[] name() { |
| 76 | return NAME; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | ComparatorPB.Comparator toProtobuf() { |
| 81 | ByteString byte_string = ComparatorPB |
| 82 | .BitComparator |
| 83 | .newBuilder() |
| 84 | .setComparable( |
| 85 | ComparatorPB |
| 86 | .ByteArrayComparable |
| 87 | .newBuilder() |
| 88 | .setValue(Bytes.wrap(value))) |
| 89 | .setBitwiseOp(ComparatorPB |
| 90 | .BitComparator.BitwiseOp.valueOf(bit_operator.name())) |
| 91 | .build() |
| 92 | .toByteString(); |
| 93 | return super.toProtobuf(byte_string); |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | void serializeOld(ChannelBuffer buf) { |
| 98 | super.serializeOld(buf); // super.predictSerializedSize() |
| 99 | // Write class code |
nothing calls this directly
no test coverage detected
searching dependent graphs…