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

Class ColumnPrefixFilter

src/ColumnPrefixFilter.java:43–97  ·  view source on GitHub ↗

Sets a binary prefix to filter results based on the column qualifier. Efficiently compares the column qualifier bytes up to the length of the prefix to see if it matches. Only setting this filter will return all rows that match the criteria but at the same will cost a full table scan. @since

Source from the content-addressed store, hash-verified

41 * @since 1.5
42 */
43public final class ColumnPrefixFilter extends ScanFilter {
44
45 private static final byte[] NAME = Bytes.ISO88591("org.apache.hadoop"
46 + ".hbase.filter.ColumnPrefixFilter");
47
48 private final byte[] prefix;
49
50 /**
51 * Constructor for a UTF-8 prefix string.
52 */
53 public ColumnPrefixFilter(final String prefix) {
54 this(Bytes.UTF8(prefix));
55 }
56
57 /**
58 * Constructor.
59 * @throws IllegalArgumentException if the prefix is an empty byte array.
60 */
61 public ColumnPrefixFilter(final byte[] prefix) {
62 if (prefix.length == 0) {
63 throw new IllegalArgumentException("Empty prefix");
64 }
65 this.prefix = prefix;
66 }
67
68 @Override
69 byte[] serialize() {
70 return FilterPB.ColumnPrefixFilter.newBuilder()
71 .setPrefix(Bytes.wrap(prefix))
72 .build()
73 .toByteArray();
74 }
75
76 @Override
77 byte[] name() {
78 return NAME;
79 }
80
81 @Override
82 int predictSerializedSize() {
83 return 1 + NAME.length + 3 + prefix.length;
84 }
85
86 @Override
87 void serializeOld(final ChannelBuffer buf) {
88 buf.writeByte((byte) NAME.length); // 1
89 buf.writeBytes(NAME); // 49
90 HBaseRpc.writeByteArray(buf, prefix); // 3 + prefix.length
91 }
92
93 public String toString() {
94 return "ColumnPrefixFilter(" + Bytes.pretty(prefix) + ")";
95 }
96
97}

Callers

nothing calls this directly

Calls 1

ISO88591Method · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…