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

Class SubstringComparator

src/SubstringComparator.java:42–97  ·  view source on GitHub ↗

A substring comparator used in comparison filters such as RowFilter, QualifierFilter, and ValueFilter. A Substring comparator matches any value which contains the provided substring. Only EQUAL and NOT_EQUAL comparisons are valid with this comparator. @since 1.6

Source from the content-addressed store, hash-verified

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

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…