0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ColumnPredicate.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
22 #ifndef Hypertable_Lib_ColumnPredicate_h
23 #define Hypertable_Lib_ColumnPredicate_h
24 
25 #include <Common/Serializable.h>
26 
27 
28 namespace Hypertable {
29 namespace Lib {
30 
31  using namespace std;
32 
35 
40  class ColumnPredicate : public Serializable {
41  public:
42  enum {
43  NO_OPERATION = 0,
44  EXACT_MATCH = 0x0001,
45  PREFIX_MATCH = 0x0002,
46  REGEX_MATCH = 0x0004,
47  VALUE_MATCH = 0x0007,
48  QUALIFIER_EXACT_MATCH = 0x0100,
49  QUALIFIER_PREFIX_MATCH = 0x0200,
50  QUALIFIER_REGEX_MATCH = 0x0400,
51  QUALIFIER_MATCH = 0x0700
52  };
53 
55 
56  ColumnPredicate(const char *family, const char *qualifier,
57  uint32_t op, const char *v, uint32_t vlen=0)
58  : column_family(family), column_qualifier(qualifier),
59  value(v), value_len(vlen), operation(op) {
60  if (!vlen && value)
61  value_len = strlen(value);
62  column_qualifier_len =
63  column_qualifier ? strlen(column_qualifier) : 0;
64  }
65 
66  ColumnPredicate(const uint8_t **bufp, size_t *remainp) {
67  decode(bufp, remainp);
68  }
69 
70  virtual ~ColumnPredicate() {}
71 
74  const string render_hql() const;
75 
76  const char *column_family {};
77  const char *column_qualifier {};
78  const char *value {};
79  uint32_t column_qualifier_len {};
80  uint32_t value_len {};
81  uint32_t operation {};
82 
83  private:
84 
87  uint8_t encoding_version() const override;
88 
92  size_t encoded_length_internal() const override;
93 
96  void encode_internal(uint8_t **bufp) const override;
97 
104  void decode_internal(uint8_t version, const uint8_t **bufp,
105  size_t *remainp) override;
106 
107  };
108 
109  std::ostream &operator<<(std::ostream &os, const ColumnPredicate &cp);
110 
112 
113 }}
114 
115 #endif // Hypertable_Lib_ColumnPredicate_h
STL namespace.
ColumnPredicate(const uint8_t **bufp, size_t *remainp)
ostream & operator<<(ostream &os, const CellInterval &ci)
Represents a column predicate (e.g.
Declarations for Serializable.
Hypertable definitions
Mixin class that provides a standard serialization interface.
Definition: Serializable.h:65
ColumnPredicate(const char *family, const char *qualifier, uint32_t op, const char *v, uint32_t vlen=0)