0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ScanContext.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 
26 
27 #ifndef Hypertable_RangeServer_ScanContext_h
28 #define Hypertable_RangeServer_ScanContext_h
29 
30 #include <Common/ByteString.h>
31 #include <Common/Error.h>
32 #include <Common/StringExt.h>
33 
35 #include <Hypertable/Lib/Key.h>
38 #include <Hypertable/Lib/Schema.h>
39 
40 #include <cassert>
41 #include <memory>
42 #include <utility>
43 #include <set>
44 
45 namespace Hypertable {
46 
47  using namespace std;
48 
52  class ScanContext {
53  public:
55  const ScanSpec *spec;
57  const RangeSpec *range;
61  Key start_key, end_key;
62  String start_row, end_row;
63  String start_qualifier, end_qualifier;
64  bool start_inclusive, end_inclusive;
65  bool single_row;
69  int64_t revision;
70  pair<int64_t, int64_t> time_interval;
71  bool family_mask[256];
72  vector<CellPredicate> cell_predicates;
73  RE2 *row_regexp;
75  typedef std::set<const char *, LtCstr, CstrAlloc> CstrRowSet;
76  CstrRowSet rowset;
77  uint32_t timeout_ms;
78 
88  ScanContext(int64_t rev, const ScanSpec *ss, const RangeSpec *range,
89  SchemaPtr &schema, std::set<uint8_t> *columns=0) :
90  cell_predicates(256), row_regexp(0), value_regexp(0), timeout_ms(0) {
91  initialize(rev, ss, range, schema, columns);
92  }
93 
100  ScanContext(int64_t rev, SchemaPtr &schema)
101  : cell_predicates(256), row_regexp(0), value_regexp(0), timeout_ms(0) {
102  initialize(rev, 0, 0, schema);
103  }
104 
111  : cell_predicates(256), row_regexp(0), value_regexp(0), timeout_ms(0) {
112  SchemaPtr schema;
113  initialize(rev, 0, 0, schema);
114  }
115 
122  : cell_predicates(256), row_regexp(0), value_regexp(0), timeout_ms(0) {
123  initialize(TIMESTAMP_MAX, 0, 0, schema);
124  }
125 
127  if (row_regexp != 0) {
128  delete row_regexp;
129  }
130  if (value_regexp != 0) {
131  delete value_regexp;
132  }
133  }
134 
136  scan_spec_builder = *spec;
137  spec = &scan_spec_builder.get();
138  range_managed = *range;
139  range = &range_managed;
140  }
141 
142  private:
143 
158  void initialize(int64_t rev, const ScanSpec *ss, const RangeSpec *range,
159  SchemaPtr &sp, std::set<uint8_t> *columns=0);
163  ScanContext(const ScanContext&);
164  ScanContext& operator = (const ScanContext&);
165 
167  };
168 
169  typedef std::shared_ptr<ScanContext> ScanContextPtr;
170 
171 }
172 
173 #endif // Hypertable_RangeServer_ScanContext_h
ScanSpecBuilder scan_spec_builder
Definition: ScanContext.h:56
SerializedKey start_serkey
Definition: ScanContext.h:60
void initialize(const String &name)
Public initialization function - creates a singleton instance of LogWriter.
Definition: Logger.cc:45
const RangeSpec * range
Definition: ScanContext.h:57
ScanSpec & get()
Returns the built ScanSpec object.
Definition: ScanSpec.h:566
Range specification.
Definition: RangeSpec.h:40
ScanContext(int64_t rev, SchemaPtr &schema)
Constructor.
Definition: ScanContext.h:100
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
STL namespace.
Scan context information.
Definition: ScanContext.h:52
DynamicBuffer dbuf
Definition: ScanContext.h:59
A dynamic, resizable and reference counted memory buffer.
Definition: DynamicBuffer.h:42
Declarations for Schema.
Scan predicate and control specification.
Definition: ScanSpec.h:56
const ScanSpec * spec
Definition: ScanContext.h:55
vector< CellPredicate > cell_predicates
Definition: ScanContext.h:72
The PageArena allocator is simple and fast, avoiding individual mallocs/frees.
Definition: PageArena.h:69
Helper class for building a ScanSpec.
Definition: ScanSpec.h:318
std::set< const char *, LtCstr, CstrAlloc > CstrRowSet
Definition: ScanContext.h:75
ScanContext(int64_t rev=TIMESTAMP_MAX)
Constructor.
Definition: ScanContext.h:110
pair< int64_t, int64_t > time_interval
Definition: ScanContext.h:70
Declarations for CellPredicate.
Declarations for RangeSpec and RangeSpecManaged.
Hypertable definitions
static const int64_t TIMESTAMP_MAX
Definition: KeySpec.h:35
Provides access to internal components of opaque key.
Definition: Key.h:40
A serializable ByteString.
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
ScanContext(SchemaPtr &schema)
Constructor.
Definition: ScanContext.h:121
ScanContext(int64_t rev, const ScanSpec *ss, const RangeSpec *range, SchemaPtr &schema, std::set< uint8_t > *columns=0)
Constructor.
Definition: ScanContext.h:88
String extensions and helpers: sets, maps, append operators etc.
Error codes, Exception handling, error logging.
Wrapper for RangeSpec providing member storage.
Definition: RangeSpec.h:89
RangeSpecManaged range_managed
Definition: ScanContext.h:58
std::shared_ptr< ScanContext > ScanContextPtr
Definition: ScanContext.h:169