49 std::set<uint8_t> *columns) {
51 int32_t max_versions = 0;
53 const char *qualifier;
56 bool is_regexp, is_prefix;
76 memset(family_mask,
true, 256*
sizeof(
bool));
78 memset(family_mask,
false, 256*
sizeof(
bool));
79 max_versions = spec->max_versions;
85 if (spec && spec->columns.size() > 0) {
88 for (
auto cfstr : spec->columns) {
90 cfstr = (
const char *)arena.dup(cfstr);
92 ScanSpec::parse_column(cfstr, family, &qualifier, &qualifier_len,
93 &has_qualifier, &is_regexp, &is_prefix);
94 cf_spec = schema->get_column_family(family.c_str());
100 columns->insert(cf_spec->
get_id());
102 family_mask[cf_spec->
get_id()] =
true;
106 is_regexp ? ColumnPredicate::QUALIFIER_REGEX_MATCH :
107 (is_prefix ? ColumnPredicate::QUALIFIER_PREFIX_MATCH :
108 ColumnPredicate::QUALIFIER_EXACT_MATCH);
111 cell_predicates[cf_spec->
get_id()].add_column_predicate(cp,
id++);
117 cell_predicates[cf_spec->
get_id()].cutoff_time = now
119 if (max_versions == 0)
123 cell_predicates[cf_spec->
get_id()].max_versions = max_versions;
129 cell_predicates[cf_spec->
get_id()].counter =
true;
135 family_mask[0] =
true;
137 for (
auto ag_spec : schema->get_access_groups()) {
138 for (
auto cf_spec : ag_spec->columns()) {
139 if (cf_spec->
get_id() == 0)
141 "Bad ID for Column Family '%s'", cf_spec->
get_name().c_str());
143 family_mask[cf_spec->
get_id()] =
false;
146 family_mask[cf_spec->
get_id()] =
true;
150 cell_predicates[cf_spec->
get_id()].cutoff_time = now
153 if (max_versions == 0)
157 cell_predicates[cf_spec->
get_id()].max_versions = max_versions;
159 cell_predicates[cf_spec->
get_id()].max_versions =
164 cell_predicates[cf_spec->
get_id()].counter =
true;
176 has_cell_interval =
false;
177 has_start_cf_qualifier =
false;
178 start_inclusive = end_inclusive =
true;
179 restricted_range =
true;
184 if (!spec->row_intervals.empty()) {
186 start_row = spec->row_intervals.front().start;
187 start_inclusive = spec->row_intervals.front().start_inclusive;
190 if (spec->row_intervals.back().end[0] == 0)
191 end_row = Key::END_ROW_MARKER;
193 end_row = spec->row_intervals.back().end;
194 end_inclusive = spec->row_intervals.back().end_inclusive;
196 if (!strcmp(spec->row_intervals.front().start, spec->row_intervals.back().end))
200 if (spec->scan_and_filter_rows) {
201 for (
const auto &ri : spec->row_intervals) {
202 rowset.insert(arena.dup(ri.start));
204 end_row = *rowset.rbegin();
205 end_inclusive =
true;
206 single_row = rowset.size() == 1;
209 else if (!spec->cell_intervals.empty()) {
213 has_cell_interval =
true;
215 if (*spec->cell_intervals[0].start_column) {
216 ptr = strchr(spec->cell_intervals[0].start_column,
':');
218 ptr = spec->cell_intervals[0].start_column
219 + strlen(spec->cell_intervals[0].start_column);
220 start_qualifier =
"";
223 start_qualifier = ptr+1;
224 start_key.column_qualifier = start_qualifier.c_str();
225 start_key.column_qualifier_len = start_qualifier.length();
226 has_start_cf_qualifier =
true;
228 column_family_str =
String(spec->cell_intervals[0].start_column,
229 ptr - spec->cell_intervals[0].start_column);
230 if ((cf_spec = schema->get_column_family(column_family_str)) == 0)
232 format(
"Bad column family (%s)", column_family_str.c_str()));
234 start_key.column_family_code = cf_spec->
get_id();
236 start_row = spec->cell_intervals[0].start_row;
237 start_inclusive = spec->cell_intervals[0].start_inclusive;
241 start_qualifier =
"";
242 start_inclusive =
true;
245 if (*spec->cell_intervals[0].end_column) {
246 ptr = strchr(spec->cell_intervals[0].end_column,
':');
248 ptr = spec->cell_intervals[0].end_column
249 + strlen(spec->cell_intervals[0].end_column);
253 end_qualifier = ptr+1;
254 end_key.column_qualifier = end_qualifier.c_str();
255 end_key.column_qualifier_len = end_qualifier.length();
258 column_family_str =
String(spec->cell_intervals[0].end_column,
259 ptr - spec->cell_intervals[0].end_column);
260 if ((cf_spec = schema->get_column_family(column_family_str)) == 0)
262 column_family_str.c_str());
264 end_key.column_family_code = cf_spec->
get_id();
266 end_row = spec->cell_intervals[0].end_row;
267 end_inclusive = spec->cell_intervals[0].end_inclusive;
270 end_row = Key::END_ROW_MARKER;
274 if (!strcmp(spec->cell_intervals[0].start_row,
275 spec->cell_intervals[0].end_row))
278 if (single_row && ((end_key.column_family_code == start_key.column_family_code
279 && start_qualifier.compare(end_qualifier) > 0)
280 || start_key.column_family_code > end_key.column_family_code))
286 end_row = Key::END_ROW_MARKER;
289 if (start_row.compare(end_row) > 0)
294 end_row = Key::END_ROW_MARKER;
297 if (start_row ==
"" && end_row == Key::END_ROW_MARKER)
298 restricted_range =
false;
300 assert(start_row <= end_row);
302 start_key.row = start_row.c_str();
303 start_key.row_len = start_row.length();
305 end_key.row = end_row.c_str();
306 end_key.row_len = end_row.length();
308 dbuf.reserve(start_row.length() + start_qualifier.length()
309 + end_row.length() + end_qualifier.length() + 64);
313 if (spec && !spec->cell_intervals.empty()) {
319 if (start_key.column_qualifier == 0)
320 tmp_str = Key::END_ROW_MARKER;
322 tmp_str = start_key.column_qualifier;
323 tmp_str.append(1, 1);
327 start_key.column_family_code,
330 start_serkey.ptr = dbuf.base;
331 end_serkey.ptr = dbuf.ptr;
337 if (end_key.column_qualifier == 0)
338 tmp_str = Key::END_ROW_MARKER;
340 tmp_str = end_key.column_qualifier;
341 tmp_str.append(1, 1);
348 if (start_inclusive || start_key.row_len == 0)
351 tmp_str = start_key.row;
352 tmp_str.append(1, 1);
355 start_serkey.ptr = dbuf.base;
356 end_serkey.ptr = dbuf.ptr;
360 tmp_str = end_key.row;
361 tmp_str.append(1, 1);
368 if (spec->row_regexp && *spec->row_regexp != 0) {
369 row_regexp =
new RE2(spec->row_regexp);
370 if (!row_regexp->ok()) {
372 + spec->row_regexp +
" to regexp -" + row_regexp->error_arg());
375 if (spec->value_regexp && *spec->value_regexp != 0) {
376 value_regexp =
new RE2(spec->value_regexp);
377 if (!value_regexp->ok()) {
379 + spec->value_regexp +
" to regexp -" + value_regexp->error_arg());
383 for (
const auto& cp : spec->column_predicates) {
384 if (cp.column_family && *cp.column_family) {
385 cf_spec = schema->get_column_family(cp.column_family);
388 "Invalid column family '%s'", cp.column_family);
390 if (cf_spec->
get_id() == 0) {
392 "Bad id for column family '%s'", cf_spec->
get_name().c_str());
397 cell_predicates[cf_spec->
get_id()].add_column_predicate(cp,
id++);
void initialize(const String &name)
Public initialization function - creates a singleton instance of LogWriter.
std::string String
A String is simply a typedef to std::string.
bool get_option_counter() const
Gets the counter option.
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
time_t get_option_ttl() const
Gets ttl option.
pair< int64_t, int64_t > time_interval
bool get_value_index() const
Gets value index flag.
Column family specification.
static const uint32_t FLAG_DELETE_CELL
static const int64_t TIMESTAMP_MIN
Scan predicate and control specification.
Declarations for ScanContext.
bool get_qualifier_index() const
Gets qualifier index flag.
Logging routines and macros.
Compatibility Macros for C/C++.
int32_t get_id() const
Gets column ID.
static const int64_t TIMESTAMP_NULL
Represents a column predicate (e.g.
Time related declarations.
const std::string & get_name() const
Gets column family name.
void create_key_and_append(DynamicBuffer &dst_buf, const Key &key, bool time_order_asc)
int32_t get_option_max_versions() const
Gets max versions option.
static const int64_t TIMESTAMP_MAX
#define HT_THROWF(_code_, _fmt_,...)
bool get_deleted() const
Gets deleted flag.
const char * column_qualifier
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
uint32_t column_qualifier_len
#define HT_THROW(_code_, _msg_)
int64_t get_ts64()
Returns the current time in nanoseconds as a 64bit number.