MCPcopy Create free account
hub / github.com/OpenTSDB/asynchbase / BinaryPrefixComparator

Class BinaryPrefixComparator

src/BinaryPrefixComparator.java:39–95  ·  view source on GitHub ↗

A binary comparator used in comparison filters. Compares byte arrays lexicographically up to the length of the provided byte array. @since 1.6

Source from the content-addressed store, hash-verified

37 * @since 1.6
38 */
39public final class BinaryPrefixComparator extends FilterComparator {
40
41 private static final byte[] NAME =
42 Bytes.UTF8("org.apache.hadoop.hbase.filter.BinaryPrefixComparator");
43 private static final byte CODE = 47;
44
45 private final byte[] value;
46
47 public BinaryPrefixComparator(byte[] value) {
48 this.value = value;
49 }
50
51 public byte[] value() {
52 return value.clone();
53 }
54
55 @Override
56 byte[] name() {
57 return NAME;
58 }
59
60 @Override
61 ComparatorPB.Comparator toProtobuf() {
62 ByteString byte_string = ComparatorPB
63 .BinaryPrefixComparator
64 .newBuilder()
65 .setComparable(
66 ComparatorPB
67 .ByteArrayComparable
68 .newBuilder()
69 .setValue(Bytes.wrap(value)))
70 .build()
71 .toByteString();
72 return super.toProtobuf(byte_string);
73 }
74
75 @Override
76 void serializeOld(ChannelBuffer buf) {
77 super.serializeOld(buf); // super.predictSerializedSize()
78 // Write class code
79 buf.writeByte(CODE); // 1
80 // Write value
81 HBaseRpc.writeByteArray(buf, value); // 3 + value.length
82 }
83
84 @Override
85 int predictSerializedSize() {
86 return super.predictSerializedSize() + 1 + 3 + value.length;
87 }
88
89 @Override
90 public String toString() {
91 return String.format("%s(%s)",
92 getClass().getSimpleName(),
93 Bytes.pretty(value));
94 }
95}

Callers

nothing calls this directly

Calls 1

UTF8Method · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…