27 #ifndef HYPERTABLE_CELLPREDICATE_H
28 #define HYPERTABLE_CELLPREDICATE_H
34 #include <boost/shared_ptr.hpp>
52 qualifier_len(cp.column_qualifier_len), value_len(cp.value_len),
53 operation(cp.operation), id(id) {
55 [](
char *p ) {
delete[] p; });
56 char *ptr = buffer.get();
71 if (!qualifier_regex) {
72 std::string pattern(qualifier, (
size_t)qualifier_len);
73 qualifier_regex.reset(
new RE2(pattern));
75 return RE2::PartialMatch(str, *qualifier_regex);
79 std::string pattern(value, (
size_t)value_len);
80 value_regex.reset(
new RE2(pattern));
82 return RE2::PartialMatch(str, *value_regex);
84 const char *qualifier {};
102 cutoff_time(0), max_versions(0), counter(false), indexed(false) { }
105 const char* value,
size_t value_len,
106 std::bitset<32> &matching) {
107 for (
auto & cp : patterns) {
108 if (pattern_match(cp, qualifier, qualifier_len, value, value_len))
109 matching.set(cp->id);
119 bool matches(
const char *qualifier,
size_t qualifier_len,
120 const char* value,
size_t value_len) {
121 if (patterns.empty())
123 for (
auto & cp : patterns) {
124 if (pattern_match(cp, qualifier, qualifier_len, value, value_len))
131 size_t qualifier_len,
const char* value,
137 if (qualifier_len != cp->qualifier_len ||
138 memcmp(qualifier, cp->qualifier, qualifier_len))
142 if (qualifier_len < cp->qualifier_len)
144 const char *p1 = qualifier;
145 const char *p2 = cp->qualifier;
146 const char *prefix_end = cp->qualifier + cp->qualifier_len;
147 for (; p2 < prefix_end; ++p1,++p2) {
151 if (p2 != prefix_end)
155 if (!cp->regex_qualifier_match(qualifier))
163 if (cp->value_len != value_len ||
164 memcmp(cp->value, value, cp->value_len))
168 if (cp->value_len > value_len ||
169 memcmp(cp->value, value, cp->value_len))
173 if (!cp->regex_value_match(value))
181 patterns.push_back(std::make_shared<CellPattern>(column_predicate,
id));
205 #endif // HYPERTABLE_CELLPREDICATE_H
std::vector< CellPatternPtr > patterns
Vector of patterns used in predicate match.
uint32_t max_versions
Max versions (0 for all versions)
void add_column_predicate(const ColumnPredicate &column_predicate, size_t id)
Po::typed_value< String > * str(String *v=0)
CellPattern(const ColumnPredicate &cp, size_t id)
bool matches(const char *qualifier, size_t qualifier_len, const char *value, size_t value_len)
Evaluates predicate for the given cell.
std::shared_ptr< CellPattern > CellPatternPtr
Smart pointer to CellPattern.
int64_t cutoff_time
TTL cutoff time.
bool indexed
Column family is indexed.
bool regex_qualifier_match(const char *str)
Represents a column predicate (e.g.
bool counter
Column family has counter option.
boost::shared_ptr< RE2 > value_regex
boost::shared_ptr< RE2 > qualifier_regex
const char * column_qualifier
bool pattern_match(CellPatternPtr &cp, const char *qualifier, size_t qualifier_len, const char *value, size_t value_len)
uint32_t column_qualifier_len
CellPredicate()
Default constructor.
bool regex_value_match(const char *str)
void all_matches(const char *qualifier, size_t qualifier_len, const char *value, size_t value_len, std::bitset< 32 > &matching)
std::shared_ptr< char > buffer