0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
HqlParser.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_HqlParser_h
23 #define Hypertable_Lib_HqlParser_h
24 
25 //#define BOOST_SPIRIT_DEBUG ///$$$ DEFINE THIS WHEN DEBUGGING $$$///
26 
27 #ifdef BOOST_SPIRIT_DEBUG
28 #define BOOST_SPIRIT_DEBUG_OUT std::cerr
29 #define HQL_DEBUG(_expr_) std::cerr << __func__ <<": "<< _expr_ << std::endl
30 #define HQL_DEBUG_VAL(str, val) HQL_DEBUG(str <<" val="<< val)
31 #else
32 #define HQL_DEBUG(_expr_)
33 #define HQL_DEBUG_VAL(str, val)
34 #endif
35 
37 #include <Hypertable/Lib/Cells.h>
38 #include <Hypertable/Lib/Client.h>
39 #include <Hypertable/Lib/Key.h>
44 #include <Hypertable/Lib/Schema.h>
46 #include <Hypertable/Lib/Table.h>
48 
49 #include <Common/Error.h>
50 #include <Common/FileUtils.h>
51 #include <Common/Logger.h>
52 #include <Common/Time.h>
53 #include <Common/TimeInline.h>
54 
55 #include "HyperAppHelper/Unique.h"
56 
57 #include <boost/algorithm/string.hpp>
58 #include <boost/spirit/include/classic_confix.hpp>
59 #include <boost/spirit/include/classic_core.hpp>
60 #include <boost/spirit/include/classic_escape_char.hpp>
61 #include <boost/spirit/include/classic_symbols.hpp>
62 
63 #include <cctype>
64 #include <cstdlib>
65 #include <fstream>
66 #include <functional>
67 #include <iostream>
68 #include <set>
69 #include <sstream>
70 #include <vector>
71 
72 namespace Hypertable {
73  using namespace Lib;
74  namespace Hql {
75  using namespace boost;
76  using namespace boost::spirit;
77  using namespace boost::spirit::classic;
78 
79  enum {
122  };
123 
124  enum {
131  };
132 
133  enum {
136  };
137 
138  enum {
142  };
143 
144  enum {
149  };
150 
151  class InsertRecord {
152  public:
154  : timestamp(AUTO_ASSIGN), row_key_is_call(false), value_is_call(false)
155  { }
156 
157  void clear() {
158  timestamp = AUTO_ASSIGN;
159  row_key.clear();
160  column_key.clear();
161  value.clear();
162  row_key_is_call=false;
163  value_is_call=false;
164  }
165  ::int64_t timestamp;
166  std::string row_key;
168  std::string column_key;
169  std::string value;
171  };
172 
173  class RowInterval {
174  public:
175  RowInterval() : start_inclusive(true), start_set(false),
176  end(Key::END_ROW_MARKER), end_inclusive(true), end_set(false) { }
177 
178  void clear() {
179  start.clear();
180  end = Key::END_ROW_MARKER;
181  start_inclusive = end_inclusive = true;
182  start_set = end_set = false;
183  }
184  bool empty() { return !(start_set || end_set); }
185 
186  void set_start(const std::string &s, bool inclusive) {
187  HQL_DEBUG(s <<" inclusive="<< inclusive);
188  start = s;
189  start_inclusive = inclusive;
190  start_set = true;
191  }
192  void set_end(const std::string &s, bool inclusive) {
193  HQL_DEBUG(s <<" inclusive="<< inclusive);
194  end = s;
195  end_inclusive = inclusive;
196  end_set = true;
197  }
198  std::string start;
200  bool start_set;
201  std::string end;
203  bool end_set;
204  };
205 
206  class CellInterval {
207  public:
208  CellInterval() : start_inclusive(true), start_set(false),
209  end_inclusive(true), end_set(false) { }
210 
211  void clear() {
212  start_row = start_column = "";
213  end_row = end_column = "";
214  start_inclusive = end_inclusive = true;
215  start_set = end_set = false;
216  }
217 
218  bool empty() { return !(start_set || end_set); }
219 
220  void set_start(const std::string &row, const std::string &column, bool inclusive) {
221  HQL_DEBUG(row <<','<< column <<" inclusive="<< inclusive);
222  start_row = row;
223  start_column = column;
224  start_inclusive = inclusive;
225  start_set = true;
226  }
227  void set_end(const std::string &row, const std::string &column, bool inclusive) {
228  HQL_DEBUG(row <<','<< column <<" inclusive="<< inclusive);
229  end_row = row;
230  end_column = column;
231  end_inclusive = inclusive;
232  end_set = true;
233  }
234  std::string start_row;
235  std::string start_column;
237  bool start_set;
238  std::string end_row;
239  std::string end_column;
241  bool end_set;
242  };
243 
244  class ScanState {
245  public:
246  ScanState() { }
247 
248  void set_time_interval(::int64_t start, ::int64_t end) {
249  HQL_DEBUG("("<< start <<", "<< end <<")");
250  builder.set_time_interval(start, end);
251  start_time_set = end_time_set = true;
252  }
253  void set_start_time(::int64_t start) {
254  HQL_DEBUG(start);
255  builder.set_start_time(start);
256  start_time_set = true;
257  }
258  void set_end_time(::int64_t end) {
259  HQL_DEBUG(end);
260  builder.set_end_time(end);
261  end_time_set = true;
262  }
263  ::int64_t start_time() { return builder.get().time_interval.first; }
264  ::int64_t end_time() { return builder.get().time_interval.second; }
265 
267  std::string outfile;
268  bool display_timestamps {};
269  bool display_revisions {};
270  bool keys_only {};
271  std::string current_rowkey;
272  bool current_rowkey_set {};
275  std::string current_cell_row;
276  std::string current_cell_column;
277  bool start_time_set {};
278  bool end_time_set {};
279  ::int64_t current_timestamp {};
280  bool current_timestamp_set {};
281  int current_relop {};
282  int last_boolean_op {BOOLOP_AND};
283  int buckets {};
284  };
285 
286  class ParserState {
287  public:
289  System::initialize_tm(&tmval);
290  }
292  nsp = ns;
293  }
295  int command {};
296  std::string ns;
297  std::string table_name;
298  std::string pseudo_table_name;
299  std::string clone_table_name;
300  std::string new_table_name;
301  std::string str;
302  std::string output_file;
303  std::string input_file;
304  std::string source;
305  std::string destination;
306  std::string rs_name;
307  int input_file_src {};
308  std::string header_file;
309  int header_file_src {};
310  ::uint32_t group_commit_interval {};
313  std::vector<String> columns;
314  std::string timestamp_column;
315  int load_flags {};
316  uint32_t flags {};
319  ColumnFamilySpec *cf_spec {};
320  AccessGroupSpec *ag_spec {};
321  std::map<std::string, ColumnFamilySpec *> new_cf_map;
322  std::vector<ColumnFamilySpec *> new_cf_vector;
323  std::map<std::string, ColumnFamilySpec *> modified_cf_map;
324  std::vector<ColumnFamilySpec *> modified_cf_vector;
325  std::map<std::string, AccessGroupSpec *> new_ag_map;
326  std::vector<AccessGroupSpec *> new_ag_vector;
327  std::map<std::string, AccessGroupSpec *> modified_ag_map;
328  std::vector<AccessGroupSpec *> modified_ag_vector;
329  std::set<std::string> new_cf;
330  std::set<std::string> column_option_definition_set;
331  std::set<std::string> access_group_option_definition_set;
332  struct tm tmval;
333  ::uint32_t nanoseconds {};
334  double decimal_seconds {};
339  std::vector<String> delete_columns;
340  bool delete_all_columns {};
341  std::string delete_row;
342  ::int64_t delete_time {};
343  ::int64_t delete_version_time {};
345  std::vector<SystemVariable::Spec> variable_specs;
346  bool modify {};
347  bool if_exists {};
348  bool tables_only {};
349  bool with_ids {};
350  bool replay {};
351  std::string range_start_row;
352  std::string range_end_row;
353  ::int32_t scanner_id {-1};
354  ::int32_t row_uniquify_chars {};
355  bool escape {true};
356  bool nokeys {};
361  uint32_t current_column_predicate_operation {};
362  char field_separator {};
363 
364  void validate_function(const std::string &s) {
365  if (s=="guid")
366  return;
367  HT_THROW(Error::HQL_PARSE_ERROR, String("Unknown function "
368  "identifier '") + s + "()'");
369  }
370 
372  if (rec.row_key_is_call) {
373  execute_function(rec.row_key);
374  rec.row_key_is_call=false;
375  }
376 
377  if (rec.value_is_call) {
378  execute_function(rec.value);
379  rec.value_is_call=false;
380  }
381  }
382 
383  void execute_function(std::string &s) {
384  if (s=="guid") {
386  return;
387  }
388 
389  HT_THROW(Error::HQL_PARSE_ERROR, String("Unknown function "
390  "identifier '") + s + "()'");
391  }
392 
393  void check_and_set_column_option(const std::string &name,
394  const std::string &option) {
395  std::string key = name + "." + option;
396  if (column_option_definition_set.count(key) > 0)
398  "Multiple specifications of %s option for column '%s'",
399  option.c_str(), name.c_str());
400  column_option_definition_set.insert(key);
401  }
402 
403  void check_and_set_access_group_option(const std::string &name,
404  const std::string &option) {
405  std::string key = name + "." + option;
406  if (access_group_option_definition_set.count(key) > 0)
408  "Multiple specifications of %s option for access group '%s'",
409  option.c_str(), name.c_str());
410  access_group_option_definition_set.insert(key);
411  }
412 
413  ColumnFamilySpec *get_new_column_family(const std::string &name) {
414  auto iter = new_cf_map.find(name);
415  if (iter != new_cf_map.end())
416  return iter->second;
417  ColumnFamilySpec *cf = new ColumnFamilySpec(name);
418  new_cf_map[name] = cf;
419  new_cf_vector.push_back(cf);
420  return cf;
421  }
422 
423  ColumnFamilySpec *get_modified_column_family(const std::string &name) {
424  auto iter = modified_cf_map.find(name);
425  if (iter != modified_cf_map.end())
426  return iter->second;
427  HT_ASSERT(alter_schema);
428  ColumnFamilySpec *existing_cf {};
429  // Search for existing CF in modified AGs
430  for (auto ag : modified_ag_vector) {
431  if ((existing_cf = ag->get_column(name)) != nullptr)
432  break;
433  }
434  // If not found in modified AGs, fetch from schema
435  if (existing_cf == nullptr) {
436  existing_cf = alter_schema->get_column_family(name);
437  if (existing_cf == nullptr)
439  "Attempt to modify column '%s' which does not exist",
440  name.c_str());
441  }
442  ColumnFamilySpec *new_cf = new ColumnFamilySpec(name);
443  new_cf->set_id(existing_cf->get_id());
444  new_cf->set_access_group(existing_cf->get_access_group());
445  new_cf->set_value_index(existing_cf->get_value_index());
446  new_cf->set_qualifier_index(existing_cf->get_qualifier_index());
447  modified_cf_map[name] = new_cf;
448  modified_cf_vector.push_back(new_cf);
449  return new_cf;
450  }
451 
452  AccessGroupSpec *create_new_access_group(const std::string &name) {
453  if (new_ag_map.find(name) != new_ag_map.end())
455  "Multiple definitions for access group '%s'",
456  name.c_str());
457  AccessGroupSpec *ag = new AccessGroupSpec(name);
458  new_ag_map[name] = ag;
459  new_ag_vector.push_back(ag);
460  return ag;
461  }
462 
463  AccessGroupSpec *find_new_access_group(const std::string &name) {
464  auto iter = new_ag_map.find(name);
465  if (iter != new_ag_map.end())
466  return iter->second;
467  return nullptr;
468  }
469 
470  AccessGroupSpec *create_modified_access_group(const std::string &name) {
471  auto iter = modified_ag_map.find(name);
472  if (iter != modified_ag_map.end())
474  "Attempt to modify access group '%s' twice in the same command",
475  name.c_str());
476  HT_ASSERT(alter_schema);
477  auto existing_ag = alter_schema->get_access_group(name);
478  if (existing_ag == nullptr)
480  "Attempt to modify access group '%s' which does not exist",
481  name.c_str());
482  AccessGroupSpec *ag = new AccessGroupSpec(name);
483  modified_ag_map[name] = ag;
484  modified_ag_vector.push_back(ag);
485  return ag;
486  }
487 
488  AccessGroupSpec *find_modified_access_group(const std::string &name) {
489  auto iter = modified_ag_map.find(name);
490  if (iter != modified_ag_map.end())
491  return iter->second;
492  return nullptr;
493  }
494 
496  for (auto ag : modified_ag_vector) {
497  auto cf = ag->get_column(name);
498  if (cf)
499  return cf;
500  }
501  return nullptr;
502  }
503 
504  bool ag_spec_is_new() {
505  return create_schema ||
506  (alter_schema && new_ag_map.find(ag_spec->get_name()) != new_ag_map.end());
507  }
508 
509  };
510 
515  inline std::string strip_quotes(const char *str, size_t len) {
516  if (len > 1 && (*str == '\'' || *str == '"') && *str == *(str+len-1))
517  return String(str+1, len-2);
518  return String(str, len);
519  }
520 
521  inline std::string regex_from_literal(const char *str, size_t len) {
522  if (len > 0 && *str != '/')
523  return strip_quotes(str, len);
524  std::string regex = String(str+1, len-2);
525  std::string oldStr("\\/");
526  std::string newStr("/");
527  size_t pos = 0;
528  while((pos = regex.find(oldStr, pos)) != std::string::npos) {
529  regex.replace(pos, oldStr.length(), newStr);
530  pos += newStr.length();
531  }
532  return regex;
533  }
534 
535  inline bool invalid_column_name(const std::string &name) {
536  if (!isalpha(name[0]))
537  return false;
538  std::function<bool(char)> valid_char_predicate =
539  [](char c) -> bool {return isalnum(c) || c == '_' || c == '-';};
540  return find_if_not(name.begin(), name.end(), valid_char_predicate) != name.end();
541  }
542 
543  struct set_command {
544  set_command(ParserState &state, int cmd) : state(state), command(cmd) { }
545  void operator()(char const *, char const *) const {
546  state.command = command;
547  }
549  int command;
550  };
551 
553  set_namespace(ParserState &state) : state(state) { }
554  void operator()(char const *str, char const *end) const {
555  state.ns = strip_quotes(str, end-str);
556  }
558  };
559 
561  set_rangeserver(ParserState &state) : state(state) { }
562  void operator()(char const *str, char const *end) const {
563  state.rs_name = strip_quotes(str, end-str);
564  }
566  };
567 
568  struct set_table_name {
569  set_table_name(ParserState &state) : state(state) { }
570  void operator()(char const *str, char const *end) const {
571  std::string name = String(str, end-str);
572  const char *pseudo = strstr(name.c_str(), "^.");
573  if (pseudo) {
574  state.table_name = String(name.c_str(), pseudo);
575  trim_if(state.table_name, is_any_of("'\""));
576  state.pseudo_table_name = String(pseudo+1);
577  }
578  else {
579  state.table_name = name;
580  trim_if(state.table_name, is_any_of("'\""));
581  }
582  }
584  };
585 
587  set_new_table_name(ParserState &state) : state(state) { }
588  void operator()(char const *str, char const *end) const {
589  state.new_table_name = strip_quotes(str, end-str);
590  }
592  };
593 
595  start_alter_table(ParserState &state) : state(state) { }
596  void operator()(char const *str, char const *end) const {
597  std::string name = strip_quotes(str, end-str);
598  if (strstr(name.c_str(), "^."))
600  "Psudo-table '%s' schema cannot be altered", name.c_str());
601  state.table_name = name;
602  HT_ASSERT(state.nsp);
603  state.alter_schema = state.nsp->get_schema(name);
604  }
606  };
607 
609  set_clone_table_name(ParserState &state) : state(state) { }
610  void operator()(char const *str, char const *end) const {
611  state.clone_table_name = strip_quotes(str, end-str);
612  }
614  };
615 
617  set_range_start_row(ParserState &state) : state(state) { }
618  void operator()(char const *str, char const *end) const {
619  state.range_start_row = strip_quotes(str, end-str);
620  }
622  };
623 
625  set_range_end_row(ParserState &state) : state(state) { }
626  void operator()(char const *str, char const *end) const {
627  state.range_end_row = strip_quotes(str, end-str);
628  }
630  };
631 
632  struct set_source {
633  set_source(ParserState &state) : state(state) { }
634  void operator()(char const *str, char const *end) const {
635  state.source = strip_quotes(str, end-str);
636  }
638  };
639 
641  set_destination(ParserState &state) : state(state) { }
642  void operator()(char const *str, char const *end) const {
643  state.destination = strip_quotes(str, end-str);
644  }
646  };
647 
649  set_balance_algorithm(ParserState &state) : state(state) { }
650  void operator()(char const *str, char const *end) const {
651  state.balance_plan.algorithm = strip_quotes(str, end-str);
652  }
654  };
655 
657  add_range_move_spec(ParserState &state) : state(state) { }
658  void operator()(char const *str, char const *end) const {
659  RangeMoveSpecPtr move_spec = std::make_shared<RangeMoveSpec>();
660  move_spec->table.set_id(state.table_name);
661  move_spec->range.set_start_row(state.range_start_row);
662  move_spec->range.set_end_row(state.range_end_row);
663  move_spec->source_location = state.source;
664  move_spec->dest_location = state.destination;
665  state.balance_plan.moves.push_back(move_spec);
666  }
668  };
669 
671  balance_set_duration(ParserState &state) : state(state) { }
672  void operator()(size_t duration) const {
673  state.balance_plan.duration_millis = 1000*duration;
674  }
676  };
677 
678  struct set_if_exists {
679  set_if_exists(ParserState &state) : state(state) { }
680  void operator()(char const *str, char const *end) const {
681  state.if_exists = true;
682  }
684  };
685 
687  set_tables_only(ParserState &state) : state(state) { }
688  void operator()(char const *str, char const *end) const {
689  state.tables_only = true;
690  }
692  };
693 
694  struct set_with_ids {
695  set_with_ids(ParserState &state) : state(state) { }
696  void operator()(char const *str, char const *end) const {
697  state.with_ids = true;
698  }
700  };
701 
702  struct set_replay {
703  set_replay(ParserState &state) : state(state) { }
704  void operator()(char const *str, char const *end) const {
705  state.replay = true;
706  }
708  };
709 
711  start_create_table_statement(ParserState &state) : state(state) { }
712  void operator()(char const *str, char const *end) const {
713  std::string name = strip_quotes(str, end-str);
714  state.table_name = name;
715  state.create_schema = std::make_shared<Schema>();
716  }
718  };
719 
721  finish_create_table_statement(ParserState &state) : state(state) { }
722  void operator()(char const *, char const *) const {
723 
724  if (!state.clone_table_name.empty()) {
725  std::string schema_str = state.nsp->get_schema_str(state.clone_table_name, true);
726  state.create_schema.reset(Schema::new_instance(schema_str));
727  state.create_schema->clear_generation();
728  }
729  else if (state.input_file.empty()) {
730 
731  state.create_schema->set_group_commit_interval(state.group_commit_interval);
732  state.create_schema->set_access_group_defaults(state.table_ag_defaults);
733  state.create_schema->set_column_family_defaults(state.table_cf_defaults);
734 
735  // Assign columns with no access group to "default" access group,
736  // creating it if necessary
737  for (auto cf : state.new_cf_vector) {
738  // Verify that the column family was created
739  if (state.new_cf.count(cf->get_name()) == 0)
741  "Reference to undefined column '%s'", cf->get_name().c_str());
742  // If column family access group empty, assign it to the "default"
743  // access group
744  if (cf->get_access_group().empty()) {
745  cf->set_access_group("default");
746  if (state.new_ag_map.find("default") == state.new_ag_map.end())
747  state.create_new_access_group("default");
748  }
749  auto iter = state.new_ag_map.find(cf->get_access_group());
750  HT_ASSERT(iter != state.new_ag_map.end());
751  iter->second->add_column(cf);
752  }
753 
754  // Add access groups to schema
755  for (auto ag_spec : state.new_ag_vector)
756  state.create_schema->add_access_group(ag_spec);
757 
758  state.create_schema->validate();
759  }
760  state.command = COMMAND_CREATE_TABLE;
761  }
763  };
764 
766  finish_alter_table_statement(ParserState &state) : state(state) { }
767  void operator()(char const *, char const *) const {
768 
769  state.command = COMMAND_ALTER_TABLE;
770 
771  // If schema was supplied with WITH clause, just return
772  if (!state.input_file.empty())
773  return;
774 
775  // Verify column family modifications are OK then replace old column
776  // family with modified one
777  for (auto modified_cf : state.modified_cf_vector) {
778  AccessGroupSpec *ag_spec {};
779  auto iter = state.modified_ag_map.find(modified_cf->get_access_group());
780  if (iter != state.modified_ag_map.end())
781  ag_spec = iter->second;
782  else
783  ag_spec = state.alter_schema->get_access_group(modified_cf->get_access_group());
784  HT_ASSERT(ag_spec);
785  const ColumnFamilySpec *old_cf = ag_spec->replace_column(modified_cf);
786  HT_ASSERT(old_cf);
787  if (old_cf->get_option_time_order_desc() != modified_cf->get_option_time_order_desc())
789  "Modificaton of TIME ORDER option for column '%s' is not allowed.",
790  old_cf->get_name().c_str());
791  if (old_cf->get_option_counter() != modified_cf->get_option_counter())
793  "Modificaton of COUNTER option for column '%s' is not allowed.",
794  old_cf->get_name().c_str());
795  delete old_cf;
796  }
797 
798  // Add new columns to the appropriate access group
799  for (auto cf : state.new_cf_vector) {
800  if (cf->get_access_group().empty()) {
801  cf->set_access_group("default");
802  if (state.new_ag_map.find("default") == state.new_ag_map.end() &&
803  state.alter_schema->get_access_group("default") == nullptr)
804  state.create_new_access_group("default");
805  }
806  AccessGroupSpec *ag = state.find_modified_access_group(cf->get_access_group());
807  if (ag == nullptr) {
808  ag = state.alter_schema->get_access_group(cf->get_access_group());
809  if (ag == nullptr)
810  ag = state.find_new_access_group(cf->get_access_group());
811  }
812  HT_ASSERT(ag);
813  ag->add_column(cf);
814  }
815 
816  // Add access groups to schema
817  for (auto ag_spec : state.new_ag_vector)
818  state.alter_schema->add_access_group(ag_spec);
819 
820  // Replace modified access groups. Verify that all of the non-deleted
821  // column families in each modified access group were moved from the old
822  // access group to the modified one and move the deleted ones
823  for (auto modified_ag_spec : state.modified_ag_vector) {
824  string ag_name = modified_ag_spec->get_name();
825  auto old_ag_spec = state.alter_schema->get_access_group(ag_name);
826  for (auto old_cf : old_ag_spec->columns()) {
827  string cf_name = old_cf->get_name();
828  if (!old_cf->get_deleted())
830  "Missing column '%s' from modified access group '%s'",
831  cf_name.c_str(), ag_name.c_str());
832  modified_ag_spec->add_column(old_ag_spec->get_column(cf_name));
833  }
834  old_ag_spec->clear_columns();
835  old_ag_spec = state.alter_schema->replace_access_group(modified_ag_spec);
836  delete old_ag_spec;
837  }
838 
839  state.alter_schema->validate();
840  }
842  };
843 
845  set_modify_flag(ParserState &state, bool val) : state(state), value(val) { }
846  void operator()(char const *str, char const *end) const {
847  state.modify = value;
848  }
850  bool value;
851  };
852 
854  open_column_family(ParserState &state) : state(state) { }
855  void operator()(char const *str, char const *end) const {
856  std::string name = strip_quotes(str, end-str);
857 
858  if (state.modify) {
859  state.cf_spec = state.get_modified_column_family(name);
860  }
861  else {
862 
863  // sanity check name
864  if (invalid_column_name(name))
865  HT_THROWF(Error::HQL_PARSE_ERROR, "Invalid column name %s",
866  name.c_str());
867 
868  // Make sure column being added doesn't already exist
869  if (state.alter_schema) {
870  if (state.alter_schema->get_column_family(name))
872  "Attempt to add column '%s' which already exists",
873  name.c_str());
874  }
875 
876  if (state.new_cf.count(name) > 0)
878  "Column family '%s' multiply defined", name.c_str());
879 
880  state.new_cf.insert(name);
881  state.cf_spec = state.get_new_column_family(name);
882  }
883  }
885  };
886 
888  open_existing_column_family(ParserState &state) : state(state) { }
889  void operator()(char const *str, char const *end) const {
890  std::string name = strip_quotes(str, end-str);
891  HT_ASSERT(state.alter_schema);
892  state.cf_spec = state.alter_schema->get_column_family(name);
893  if (state.cf_spec == nullptr)
895  "Attempt to modify column '%s' which does not exist",
896  name.c_str());
897  }
899  };
900 
902  close_column_family(ParserState &state) : state(state) { }
903  void operator()(char const *str, char const *end) const {
904  state.cf_spec = nullptr;
905  }
907  };
908 
910  drop_column_family(ParserState &state) : state(state) { }
911  void operator()(char const *str, char const *end) const {
912  std::string name = strip_quotes(str, end-str);
913  HT_ASSERT(state.alter_schema);
914  bool drop_from_modified_ag {};
915  state.cf_spec = state.alter_schema->get_column_family(name);
916  if (state.cf_spec == nullptr) {
917  state.cf_spec = state.find_column_family_in_modified_ag(name);
918  if (state.cf_spec == nullptr)
920  "Attempt to drop column '%s' which does not exist",
921  name.c_str());
922  drop_from_modified_ag = true;
923  }
924  if (state.cf_spec->get_deleted())
926  "Attempt to drop column '%s' which is already dropped",
927  name.c_str());
928  if (drop_from_modified_ag) {
929  auto ag = state.find_modified_access_group(state.cf_spec->get_access_group());
930  HT_ASSERT(ag);
931  ag->drop_column(name);
932  }
933  else
934  state.alter_schema->drop_column_family(name);
935  }
937  };
938 
940  drop_value_index(ParserState &state) : state(state) { }
941  void operator()(char const *str, char const *end) const {
942  std::string name = strip_quotes(str, end-str);
943  HT_ASSERT(state.alter_schema);
944  ColumnFamilySpec *cf = state.find_column_family_in_modified_ag(name);
945  if (cf == nullptr) {
946  cf = state.alter_schema->get_column_family(name);
947  if (cf == nullptr)
948  HT_THROWF(Error::HQL_BAD_COMMAND, "Attempt to drop index from "
949  "column '%s' which does not exist", name.c_str());
950  }
951  cf->set_value_index(false);
952  }
954  };
955 
957  drop_qualifier_index(ParserState &state) : state(state) { }
958  void operator()(char const *str, char const *end) const {
959  std::string name = strip_quotes(str, end-str);
960  HT_ASSERT(state.alter_schema);
961  ColumnFamilySpec *cf = state.find_column_family_in_modified_ag(name);
962  if (cf == nullptr) {
963  cf = state.alter_schema->get_column_family(name);
964  if (cf == nullptr)
965  HT_THROWF(Error::HQL_BAD_COMMAND, "Attempt to drop index from "
966  "column '%s' which does not exist", name.c_str());
967  }
968  cf->set_qualifier_index(false);
969  }
971  };
972 
975  void operator()(char const *str, char const *end) const {
976  state.current_rename_column_old_name = strip_quotes(str, end-str);
977  HT_ASSERT(state.alter_schema);
978  state.cf_spec = state.alter_schema->get_column_family(state.current_rename_column_old_name);
979  if (state.cf_spec == nullptr)
981  "Attempt to rename column family '%s' which does not exist",
982  state.current_rename_column_old_name.c_str());
983  }
985  };
986 
989  void operator()(char const *str, char const *end) const {
990  std::string new_name = strip_quotes(str, end-str);
991  if (state.alter_schema->get_column_family(new_name))
993  "Attempt to rename column '%s' to '%s', which already exists",
994  state.current_rename_column_old_name.c_str(),
995  new_name.c_str());
996  state.alter_schema->rename_column_family(state.current_rename_column_old_name, new_name);
997  }
999  };
1000 
1001  struct set_counter {
1002  set_counter(ParserState &state) : state(state) { }
1003  void operator()(char const *str, char const *end) const {
1004  string value(str, end-str);
1005  bool bval {};
1006  if (!strcasecmp(value.c_str(), "counter") ||
1007  !strcasecmp(value.c_str(), "true"))
1008  bval = true;
1009  if (state.cf_spec) {
1010  state.check_and_set_column_option(state.cf_spec->get_name(), "COUNTER");
1011  state.cf_spec->set_option_counter(bval);
1012  }
1013  else if (state.ag_spec) {
1014  state.check_and_set_access_group_option(state.ag_spec->get_name(), "COUNTER");
1015  state.ag_spec->set_default_counter(bval);
1016  }
1017  else
1018  state.table_cf_defaults.set_counter(bval);
1019  }
1021  };
1022 
1024  set_max_versions(ParserState &state) : state(state) { }
1025  void operator()(char const *str, char const *end) const {
1026  if (state.cf_spec) {
1027  state.check_and_set_column_option(state.cf_spec->get_name(), "MAX_VERSIONS");
1028  state.cf_spec->set_option_max_versions((::int32_t)strtol(str, 0, 10));
1029  }
1030  else if (state.ag_spec) {
1031  state.check_and_set_access_group_option(state.ag_spec->get_name(), "MAX_VERSIONS");
1032  state.ag_spec->set_default_max_versions((::int32_t)strtol(str, 0, 10));
1033  }
1034  else
1035  state.table_cf_defaults.set_max_versions((::int32_t)strtol(str, 0, 10));
1036  }
1038  };
1039 
1041  set_time_order(ParserState &state) : state(state) { }
1042  void operator()(const char *str, const char *end) const {
1043  std::string val = String(str, end-str);
1044  to_lower(val);
1045  if (state.cf_spec) {
1046  state.check_and_set_column_option(state.cf_spec->get_name(), "TIME_ORDER");
1047  state.cf_spec->set_option_time_order_desc(val == "desc");
1048  }
1049  else if (state.ag_spec) {
1050  state.check_and_set_access_group_option(state.ag_spec->get_name(), "TIME_ORDER");
1051  state.ag_spec->set_default_time_order_desc(val == "desc");
1052  }
1053  else
1054  state.table_cf_defaults.set_time_order_desc(val == "desc");
1055  }
1057  };
1058 
1059  struct set_ttl {
1060  set_ttl(ParserState &state) : state(state) { }
1061  void operator()(char const *str, char const *end) const {
1062  char *unit_ptr;
1063  double ttl = strtod(str, &unit_ptr);
1064 
1065  while(*unit_ptr == ' ' && unit_ptr < end )
1066  ++unit_ptr;
1067 
1068  if (unit_ptr < end) {
1069  std::string unit_str = String(unit_ptr, end-unit_ptr);
1070  to_lower(unit_str);
1071 
1072  if (unit_str.find("month") == 0)
1073  ttl *= 2592000.0;
1074  else if (unit_str.find("week") == 0)
1075  ttl *= 604800.0;
1076  else if (unit_str.find("day") == 0)
1077  ttl *= 86400.0;
1078  else if (unit_str.find("hour") == 0)
1079  ttl *= 3600.0;
1080  else if (unit_str.find("minute") == 0)
1081  ttl *= 60.0;
1082  }
1083 
1084  if (state.cf_spec) {
1085  state.check_and_set_column_option(state.cf_spec->get_name(), "TTL");
1086  state.cf_spec->set_option_ttl(ttl);
1087  }
1088  else if (state.ag_spec) {
1089  state.check_and_set_access_group_option(state.ag_spec->get_name(), "TTL");
1090  state.ag_spec->set_default_ttl(ttl);
1091  }
1092  else
1093  state.table_cf_defaults.set_ttl(ttl);
1094  }
1096  };
1097 
1099  open_access_group(ParserState &state) : state(state) { }
1100  void operator()(char const *str, char const *end) const {
1101  std::string name = strip_quotes(str, end-str);
1102  if (state.modify)
1103  state.ag_spec = state.create_modified_access_group(name);
1104  else
1105  state.ag_spec = state.create_new_access_group(name);
1106  }
1108  };
1109 
1111  close_access_group(ParserState &state) : state(state) { }
1112  void operator()(char const *str, char const *end) const {
1113  state.ag_spec = nullptr;
1114  }
1116  };
1117 
1118  struct set_in_memory {
1119  set_in_memory(ParserState &state) : state(state) { }
1120  void operator()(char const *str, char const *end) const {
1121  string value(str, end-str);
1122  bool bval {};
1123  if (!strcasecmp(value.c_str(), "in_memory") ||
1124  !strcasecmp(value.c_str(), "true"))
1125  bval = true;
1126  if (state.ag_spec) {
1127  if (!state.ag_spec_is_new() &&
1128  !state.ag_spec->get_option_in_memory())
1130  "Modification of IN_MEMORY attribute for access group '%s'"
1131  " is not supported", state.ag_spec->get_name().c_str());
1132  state.ag_spec->set_option_in_memory(bval);
1133  }
1134  else
1135  state.table_ag_defaults.set_in_memory(bval);
1136  }
1138  };
1139 
1141  set_compressor(ParserState &state) : state(state) { }
1142  void operator()(char const *str, char const *end) const {
1143  std::string compressor = strip_quotes(str, end-str);
1144  to_lower(compressor);
1145  if (state.ag_spec) {
1146  if (!state.ag_spec_is_new() &&
1147  compressor != state.ag_spec->get_option_compressor())
1149  "Modification of COMPRESSOR attribute for access group '%s'"
1150  " is not supported", state.ag_spec->get_name().c_str());
1151  state.ag_spec->set_option_compressor(compressor);
1152  }
1153  else
1154  state.table_ag_defaults.set_compressor(compressor);
1155  }
1157  };
1158 
1159  struct set_blocksize {
1160  set_blocksize(ParserState &state) : state(state) { }
1161  void operator()(size_t blocksize) const {
1162  if (state.ag_spec)
1163  state.ag_spec->set_option_blocksize(blocksize);
1164  else
1165  state.table_ag_defaults.set_blocksize(blocksize);
1166  }
1168  };
1169 
1171  set_replication(ParserState &state) : state(state) { }
1172  void operator()(size_t replication) const {
1173  if (state.ag_spec) {
1174  if (!state.ag_spec_is_new() &&
1175  replication != (size_t)state.ag_spec->get_option_replication())
1177  "Modification of REPLICATION attribute for access group '%s'"
1178  " is not supported", state.ag_spec->get_name().c_str());
1179  if (replication >= 32768)
1181  "Invalid replication factor (%u) for access group '%s'",
1182  (unsigned)replication, state.ag_spec->get_name().c_str());
1183  state.ag_spec->set_option_replication(replication);
1184  }
1185  else
1186  state.table_ag_defaults.set_replication(replication);
1187  }
1189  };
1190 
1192  set_bloom_filter(ParserState &state) : state(state) { }
1193  void operator()(char const * str, char const *end) const {
1194  std::string bloom_filter = strip_quotes(str, end-str);
1195  to_lower(bloom_filter);
1196  if (state.ag_spec) {
1197  if (!state.ag_spec_is_new() &&
1198  bloom_filter != state.ag_spec->get_option_bloom_filter())
1200  "Modification of BLOOMFILTER attribute for access group '%s'"
1201  " is not supported", state.ag_spec->get_name().c_str());
1202  state.ag_spec->set_option_bloom_filter(bloom_filter);
1203  }
1204  else
1205  state.table_ag_defaults.set_bloom_filter(bloom_filter);
1206  }
1208  };
1209 
1211  access_group_add_column_family(ParserState &state) : state(state) { }
1212  void operator()(char const *str, char const *end) const {
1213  ColumnFamilySpec *cf = nullptr;
1214  std::string name = strip_quotes(str, end-str);
1215 
1216  if (state.modify) {
1217  if (state.ag_spec->get_column(name) != nullptr)
1218  HT_THROWF(Error::HQL_BAD_COMMAND, "Bad modify command - attempt to"
1219  " add column '%s' to access group '%s' twice",
1220  name.c_str(), state.ag_spec->get_name().c_str());
1221  cf = state.alter_schema->remove_column_family(name);
1222  if (cf && cf->get_access_group() != state.ag_spec->get_name())
1223  HT_THROWF(Error::HQL_BAD_COMMAND, "Bad modify command - moving"
1224  " column '%s' from access group '%s' to '%s' is not "
1225  "supported", name.c_str(), cf->get_access_group().c_str(),
1226  state.ag_spec->get_name().c_str());
1227  }
1228 
1229  if (cf == nullptr)
1230  cf = state.get_new_column_family(name);
1231 
1232  if (cf->get_access_group().empty())
1233  cf->set_access_group(state.ag_spec->get_name());
1234  else if (cf->get_access_group() != state.ag_spec->get_name())
1235  HT_THROWF(Error::HQL_BAD_COMMAND, "Attempt to add column '%s' to "
1236  "access group '%s' when it already belongs to access group"
1237  " '%s'", name.c_str(), state.ag_spec->get_name().c_str(),
1238  cf->get_access_group().c_str());
1239 
1240  if (state.modify)
1241  state.ag_spec->add_column(cf);
1242 
1243  }
1245  };
1246 
1247  struct create_index {
1248  create_index(ParserState &state) : state(state) { }
1249  void operator()(char const *str, char const *end) const {
1250  std::string name = strip_quotes(str, end-str);
1251  ColumnFamilySpec *cf = 0;
1252 
1253  if (state.alter_schema)
1254  cf = state.alter_schema->get_column_family(name);
1255 
1256  if (cf == 0)
1257  cf = state.get_new_column_family(name);
1258 
1259  if (cf->get_value_index())
1261  "Index for column family '%s' %s defined",
1262  name.c_str(), state.alter_schema ? "already" : "multiply");
1263 
1264  if (cf->get_option_counter())
1266  "Attempt to define value index for COUNTER column '%s'",
1267  name.c_str());
1268 
1269  cf->set_value_index(true);
1270  }
1272  };
1273 
1275  create_qualifier_index(ParserState &state) : state(state) { }
1276  void operator()(char const *str, char const *end) const {
1277  std::string name = strip_quotes(str, end-str);
1278  ColumnFamilySpec *cf = 0;
1279 
1280  if (state.alter_schema)
1281  cf = state.alter_schema->get_column_family(name);
1282 
1283  if (cf == 0)
1284  cf = state.get_new_column_family(name);
1285 
1286  if (cf->get_qualifier_index())
1288  "Qualifier index for column family '%s' %s defined",
1289  name.c_str(), state.alter_schema ? "already" : "multiply");
1290 
1291  if (cf->get_option_counter())
1293  "Attempt to define qualifier index for COUNTER column '%s'",
1294  name.c_str());
1295 
1296  cf->set_qualifier_index(true);
1297  }
1299  };
1300 
1302  scan_set_no_cache(ParserState &state) : state(state) { }
1303  void operator()(char const *str, char const *end) const {
1304  state.scan.builder.set_do_not_cache(true);
1305  }
1307  };
1308 
1310  scan_set_row_regexp(ParserState &state) : state(state) { }
1311  void operator()(char const *str, char const *end) const {
1312  std::string regexp(str, end-str);
1313  trim_if(regexp, boost::is_any_of("'\""));
1314  state.scan.builder.set_row_regexp(regexp.c_str());
1315  }
1317  };
1318 
1320  scan_set_value_regexp(ParserState &state) : state(state) { }
1321  void operator()(char const *str, char const *end) const {
1322  std::string regexp(str, end-str);
1323  trim_if(regexp, boost::is_any_of("'\""));
1324  state.scan.builder.set_value_regexp(regexp.c_str());
1325  }
1327  };
1328 
1330  scan_set_column_predicate_name(ParserState &state) : state(state) { }
1331  void operator()(char const *str, char const *end) const {
1332  state.current_column_predicate_name = String(str, end-str);
1333  }
1335  };
1336 
1339  : state(state), operation(operation) { }
1340  void operator()(char const *str, char const *end) const {
1341  state.current_column_predicate_operation |= operation;
1342  if (operation == ColumnPredicate::QUALIFIER_REGEX_MATCH)
1343  state.current_column_predicate_qualifier =
1344  regex_from_literal(str, end-str);
1345  else
1346  state.current_column_predicate_qualifier =
1347  strip_quotes(str, end-str);
1348  state.scan.builder.set_and_column_predicates(state.scan.last_boolean_op == BOOLOP_AND);
1349  }
1350  void operator()(char c) const {
1351  HT_ASSERT(c == '*');
1352  state.current_column_predicate_operation |=
1354  state.current_column_predicate_qualifier.clear();
1355  state.scan.builder.set_and_column_predicates(state.scan.last_boolean_op == BOOLOP_AND);
1356  }
1358  uint32_t operation;
1359  };
1360 
1362  scan_set_column_predicate_value(ParserState &state, uint32_t operation=0)
1363  : state(state), operation(operation) { }
1364  void operator()(char const *str, char const *end) const {
1365  std::string s;
1366  if (operation == ColumnPredicate::REGEX_MATCH)
1367  s = regex_from_literal(str, end-str);
1368  else
1369  s = strip_quotes(str, end-str);
1370  state.current_column_predicate_operation |= operation;
1371  state.scan.builder.add_column_predicate(state.current_column_predicate_name.c_str(),
1372  state.current_column_predicate_qualifier.c_str(),
1373  state.current_column_predicate_operation,
1374  s.c_str());
1375  state.current_column_predicate_name.clear();
1376  state.current_column_predicate_qualifier.clear();
1377  state.current_column_predicate_operation = 0;
1378  state.scan.builder.set_and_column_predicates(state.scan.last_boolean_op == BOOLOP_AND);
1379  }
1380  void operator()(char c) const {
1381  HT_ASSERT(c == ')');
1382  state.current_column_predicate_operation |= operation;
1383  state.scan.builder.add_column_predicate(state.current_column_predicate_name.c_str(),
1384  state.current_column_predicate_qualifier.c_str(),
1385  state.current_column_predicate_operation, "");
1386  state.current_column_predicate_name.clear();
1387  state.current_column_predicate_qualifier.clear();
1388  state.current_column_predicate_operation = 0;
1389  state.scan.builder.set_and_column_predicates(state.scan.last_boolean_op == BOOLOP_AND);
1390  }
1392  uint32_t operation;
1393  };
1394 
1397  : state(state), operation(operation) { }
1398  void operator()(char c) const {
1399  state.scan.builder.add_column_predicate(state.current_column_predicate_name.c_str(),
1400  state.current_column_predicate_qualifier.c_str(),
1401  operation, "");
1402  }
1404  uint32_t operation;
1405  };
1406 
1408  set_group_commit_interval(ParserState &state) : state(state) { }
1409  void operator()(size_t interval) const {
1410  if (state.group_commit_interval != 0)
1411  HT_THROW(Error::HQL_PARSE_ERROR, "GROUP_COMMIT_INTERVAL multiply defined");
1412  state.group_commit_interval = (::uint32_t)interval;
1413  }
1415  };
1416 
1417  struct set_help {
1418  set_help(ParserState &state) : state(state) { }
1419  void operator()(char const *str, char const *end) const {
1420  state.command = COMMAND_HELP;
1421  state.str = String(str, end-str);
1422  size_t offset = state.str.find_first_of(' ');
1423  if (offset != String::npos) {
1424  state.str = state.str.substr(offset+1);
1425  trim(state.str);
1426  to_lower(state.str);
1427  }
1428  else
1429  state.str = "";
1430  }
1432  };
1433 
1434  struct set_str {
1435  set_str(ParserState &state) : state(state) { }
1436  void operator()(char const *str, char const *end) const {
1437  state.str = String(str, end-str);
1438  trim_if(state.str, is_any_of("'\""));
1439  }
1441  };
1442 
1444  set_output_file(ParserState &state) : state(state) { }
1445  void operator()(char const *str, char const *end) const {
1446  state.output_file = String(str, end-str);
1447  trim_if(state.output_file, is_any_of("'\""));
1448  FileUtils::expand_tilde(state.output_file);
1449  }
1451  };
1452 
1454  set_input_file(ParserState &state) : state(state) { }
1455  void operator()(char const *str, char const *end) const {
1456  std::string file = String(str, end-str);
1457  trim_if(file, is_any_of("'\""));
1458 
1459  if (boost::algorithm::starts_with(file, "fs://")) {
1460  state.input_file_src = DFS_FILE;
1461  state.input_file = file.substr(5);
1462  }
1463  else if (boost::algorithm::starts_with(file, "dfs://")) {
1464  state.input_file_src = DFS_FILE;
1465  state.input_file = file.substr(6);
1466  }
1467  else if (file.compare("-") == 0) {
1468  state.input_file_src = STDIN;
1469  }
1470  else {
1471  state.input_file_src = LOCAL_FILE;
1472  if (boost::algorithm::starts_with(file, "file://"))
1473  state.input_file = file.substr(7);
1474  else
1475  state.input_file = file;
1476  FileUtils::expand_tilde(state.input_file);
1477  }
1478  }
1479 
1481  };
1482 
1484  set_header_file(ParserState &state) : state(state) { }
1485  void operator()(char const *str, char const *end) const {
1486  std::string file = String(str, end-str);
1487  trim_if(file, is_any_of("'\""));
1488 
1489  state.header_file_src = LOCAL_FILE;
1490  if (boost::algorithm::starts_with(file, "fs://") ||
1491  boost::algorithm::starts_with(file, "dfs://")) {
1493  "Header file must be in local filesystem, not in the brokered FS");
1494  }
1495  else {
1496  if (boost::algorithm::starts_with(file, "file://"))
1497  state.header_file = file.substr(7);
1498  else
1499  state.header_file = file;
1500  FileUtils::expand_tilde(state.header_file);
1501  }
1502  }
1504  };
1505 
1507  set_dup_key_cols(ParserState &state) : state(state) { }
1508  void operator()(char const *str, char const *end) const {
1509  if (*str != '0' && strncasecmp(str, "no", 2) &&
1510  strncasecmp(str, "off", 3) &&
1511  strncasecmp(str, "false", 4))
1512  state.load_flags |= LoadDataFlags::DUP_KEY_COLS;
1513  }
1515  };
1516 
1518  set_dup_key_cols_true(ParserState &state) : state(state) { }
1519  void operator()(char const *str, char const *end) const {
1520  state.load_flags |= LoadDataFlags::DUP_KEY_COLS;
1521  }
1523  };
1524 
1525  struct add_column {
1526  add_column(ParserState &state) : state(state) { }
1527  void operator()(char const *str, char const *end) const {
1528  std::string column(str, end-str);
1529  trim_if(column, is_any_of("'\""));
1530  state.columns.push_back(column);
1531  }
1533  };
1534 
1536  set_timestamp_column(ParserState &state) : state(state) { }
1537  void operator()(char const *str, char const *end) const {
1538  state.timestamp_column = String(str, end-str);
1539  trim_if(state.timestamp_column, is_any_of("'\""));
1540  }
1542  };
1543 
1545  set_row_uniquify_chars(ParserState &state) : state(state) { }
1546  void operator()(int nchars) const {
1547  state.row_uniquify_chars = nchars;
1548  }
1550  };
1551 
1553  set_ignore_unknown_cfs(ParserState &state) : state(state) { }
1554  void operator()(char const *str, char const *end) const {
1555  state.load_flags |= LoadDataFlags::IGNORE_UNKNOWN_COLUMNS;
1556  }
1558  };
1559 
1561  set_single_cell_format(ParserState &state) : state(state) { }
1562  void operator()(char const *str, char const *end) const {
1563  state.load_flags |= LoadDataFlags::SINGLE_CELL_FORMAT;
1564  }
1566  };
1567 
1569  set_field_separator(ParserState &state) : state(state) { }
1570  void operator()(char const *str, char const *end) const {
1571  std::string field_separator(str, end-str);
1572  trim_if(field_separator, is_any_of("'\""));
1573  if (field_separator.length() != 1)
1575  "Field separator must be a single character");
1576  state.field_separator = field_separator[0];
1577  }
1579  };
1580 
1582  scan_add_column_family(ParserState &state, int qualifier_flag=0) : state(state),
1583  qualifier_flag(qualifier_flag) { }
1584  void operator()(char const *str, char const *end) const {
1585  std::string column_name(str, end-str);
1586  trim_if(column_name, is_any_of("'\""));
1587  if (qualifier_flag == NO_QUALIFIER)
1588  state.scan.builder.add_column(column_name.c_str());
1589  else
1590  state.current_column_family = column_name;
1591  }
1594  };
1595 
1597  scan_add_column_qualifier(ParserState &state, int _qualifier_flag=0)
1598  : state(state), qualifier_flag(_qualifier_flag) { }
1599  void operator()(char const *str, char const *end) const {
1600  std::string qualifier(str, end-str);
1601  std::string qualified_column = state.current_column_family
1602  + (qualifier_flag == PREFIX_QUALIFIER
1603  ? ":^"
1604  : ":")
1605  + qualifier;
1606  state.scan.builder.add_column(qualified_column.c_str());
1607  }
1608  void operator()(const char c) const {
1609  HT_ASSERT(c == '*');
1610  std::string qualified_column = state.current_column_family + ":*";
1611  state.scan.builder.add_column(qualified_column.c_str());
1612  }
1615  };
1616 
1617 
1619  scan_set_display_timestamps(ParserState &state) : state(state) { }
1620  void operator()(char const *str, char const *end) const {
1621  state.scan.display_timestamps=true;
1622  }
1624  };
1625 
1627  scan_set_display_revisions(ParserState &state) : state(state) { }
1628  void operator()(char const *str, char const *end) const {
1629  state.scan.display_revisions=true;
1630  }
1632  };
1633 
1635  scan_clear_display_timestamps(ParserState &state) : state(state) { }
1636  void operator()(char const *str, char const *end) const {
1637  state.scan.display_timestamps=false;
1638  }
1640  };
1641 
1643  scan_add_row_interval(ParserState &state) : state(state) { }
1644  void operator()(char const *str, char const *end) const {
1645  RowInterval &ri = state.scan.current_ri;
1646  HT_ASSERT(!ri.empty());
1647  state.scan.builder.add_row_interval(ri.start.c_str(),
1648  ri.start_inclusive, ri.end.c_str(), ri.end_inclusive);
1649  ri.clear();
1650  }
1652  };
1653 
1655  scan_set_cell_row(ParserState &state) : state(state) { }
1656  void operator()(char const *str, char const *end) const {
1657  state.scan.current_cell_row = strip_quotes(str,end-str);
1658  }
1660  };
1661 
1663  scan_set_cell_column(ParserState &state) : state(state) { }
1664  void operator()(char const *str, char const *end) const {
1665  CellInterval &ci = state.scan.current_ci;
1666  std::string &row = state.scan.current_cell_row;
1667  std::string &column = state.scan.current_cell_column;
1668 
1669  column = String(str, end-str);
1670  trim_if(column, is_any_of("'\""));
1671 
1672  if (state.scan.current_relop) {
1673  switch (state.scan.current_relop) {
1674  case RELOP_EQ:
1675  if (!ci.empty())
1676  HT_THROW(Error::HQL_PARSE_ERROR, "Bad cell expression");
1677  ci.set_start(row, column, true);
1678  ci.set_end(row, column, true);
1679  break;
1680  case RELOP_LT:
1681  if (ci.end_set)
1682  HT_THROW(Error::HQL_PARSE_ERROR, "Bad cell expression");
1683  ci.set_end(row, column, false);
1684  break;
1685  case RELOP_LE:
1686  if (ci.end_set)
1687  HT_THROW(Error::HQL_PARSE_ERROR, "Bad cell expression");
1688  ci.set_end(row, column, true);
1689  break;
1690  case RELOP_GT:
1691  if (ci.start_set)
1692  HT_THROW(Error::HQL_PARSE_ERROR, "Bad cell expression");
1693  ci.set_start(row, column, false);
1694  break;
1695  case RELOP_GE:
1696  if (ci.start_set)
1697  HT_THROW(Error::HQL_PARSE_ERROR, "Bad cell expression");
1698  ci.set_start(row, column, true);
1699  break;
1700  case RELOP_SW:
1701  if (!ci.empty())
1702  HT_THROW(Error::HQL_PARSE_ERROR, "Bad cell expression");
1703  ci.set_start(row, column, true);
1704  column.append(1, static_cast<char>(0xff));
1705  ci.set_end(row, column, false);
1706  break;
1707  }
1708  if (!ci.end_set)
1710 
1711  state.scan.builder.add_cell_interval(ci.start_row.c_str(),
1712  ci.start_column.c_str(), ci.start_inclusive, ci.end_row.c_str(),
1713  ci.end_column.c_str(), ci.end_inclusive);
1714  ci.clear();
1715  row.clear();
1716  column.clear();
1717  state.scan.current_relop = 0;
1718  }
1719  }
1721  };
1722 
1723  struct scan_set_row {
1724  scan_set_row(ParserState &state) : state(state) { }
1725  void operator()(char const *str, char const *end) const {
1726  state.scan.current_rowkey = strip_quotes(str, end-str);
1727  if (state.scan.current_relop != 0) {
1728  switch (state.scan.current_relop) {
1729  case RELOP_EQ:
1730  if (!state.scan.current_ri.empty())
1731  HT_THROW(Error::HQL_PARSE_ERROR, "Bad row expressions.");
1732  state.scan.current_ri.set_start(state.scan.current_rowkey, true);
1733  state.scan.current_ri.set_end(state.scan.current_rowkey, true);
1734  break;
1735  case RELOP_LT:
1736  if (state.scan.current_ri.end_set)
1737  HT_THROW(Error::HQL_PARSE_ERROR, "Bad row expressions.");
1738  state.scan.current_ri.set_end(state.scan.current_rowkey, false);
1739  break;
1740  case RELOP_LE:
1741  if (state.scan.current_ri.end_set)
1742  HT_THROW(Error::HQL_PARSE_ERROR, "Bad row expressions.");
1743  state.scan.current_ri.set_end(state.scan.current_rowkey, true);
1744  break;
1745  case RELOP_GT:
1746  if (state.scan.current_ri.start_set)
1747  HT_THROW(Error::HQL_PARSE_ERROR, "Bad row expressions.");
1748  state.scan.current_ri.set_start(state.scan.current_rowkey, false);
1749  break;
1750  case RELOP_GE:
1751  if (state.scan.current_ri.start_set)
1752  HT_THROW(Error::HQL_PARSE_ERROR, "Bad row expressions.");
1753  state.scan.current_ri.set_start(state.scan.current_rowkey, true);
1754  break;
1755  case RELOP_SW:
1756  if (!state.scan.current_ri.empty())
1757  HT_THROW(Error::HQL_PARSE_ERROR, "Bad row expressions.");
1758  state.scan.current_ri.set_start(state.scan.current_rowkey, true);
1759  str = state.scan.current_rowkey.c_str();
1760  end = str + state.scan.current_rowkey.length();
1761  const char *ptr;
1762  for (ptr = end - 1; ptr > str; --ptr) {
1763  if (::uint8_t(*ptr) < 0xffu) {
1764  std::string temp_str(str, ptr - str);
1765  temp_str.append(1, (*ptr) + 1);
1766  state.scan.current_ri.set_end(temp_str, false);
1767  break;
1768  }
1769  }
1770  if (ptr == str) {
1771  state.scan.current_rowkey.append(4, (char)0xff);
1772  state.scan.current_ri.set_end(state.scan.current_rowkey, false);
1773  }
1774  }
1775  state.scan.current_rowkey_set = false;
1776  state.scan.current_relop = 0;
1777  }
1778  else {
1779  state.scan.current_rowkey_set = true;
1780  state.scan.current_cell_row.clear();
1781  }
1782  }
1784  };
1785 
1787  scan_set_buckets(ParserState &state) : state(state) { }
1788  void operator()(int ival) const {
1789  if (state.scan.buckets != 0)
1791  "SELECT BUCKETS predicate multiply defined.");
1792  state.scan.buckets = ival;
1793  }
1795  };
1796 
1798  scan_set_max_versions(ParserState &state) : state(state) { }
1799  void operator()(int ival) const {
1800  if (state.scan.builder.get().max_versions != 0)
1802  "SELECT MAX_VERSIONS predicate multiply defined.");
1803  state.scan.builder.set_max_versions(ival);
1804  }
1806  };
1807 
1809  scan_set_row_limit(ParserState &state) : state(state) { }
1810  void operator()(int ival) const {
1811  if (state.scan.builder.get().row_limit != 0)
1813  "SELECT LIMIT predicate multiply defined.");
1814  state.scan.builder.set_row_limit(ival);
1815  }
1817  };
1818 
1820  scan_set_cell_limit(ParserState &state) : state(state) { }
1821  void operator()(int ival) const {
1822  if (state.scan.builder.get().cell_limit != 0)
1824  "SELECT CELL_LIMIT predicate multiply defined.");
1825  state.scan.builder.set_cell_limit(ival);
1826  }
1828  };
1829 
1831  scan_set_cell_limit_per_family(ParserState &state) : state(state) { }
1832  void operator()(int ival) const {
1833  if (state.scan.builder.get().cell_limit_per_family != 0)
1835  "SELECT CELL_LIMIT_PER_FAMILY predicate multiply defined.");
1836  state.scan.builder.set_cell_limit_per_family(ival);
1837  }
1839  };
1840 
1842  scan_set_row_offset(ParserState &state) : state(state) { }
1843  void operator()(int ival) const {
1844  if (state.scan.builder.get().row_offset != 0)
1846  "SELECT OFFSET predicate multiply defined.");
1847  if (state.scan.builder.get().cell_offset != 0)
1849  "SELECT OFFSET predicate not allowed in combination with "
1850  "CELL_OFFSET.");
1851  state.scan.builder.set_row_offset(ival);
1852  }
1854  };
1855 
1857  scan_set_cell_offset(ParserState &state) : state(state) { }
1858  void operator()(int ival) const {
1859  if (state.scan.builder.get().cell_offset != 0)
1861  "SELECT CELL_OFFSET predicate multiply defined.");
1862  if (state.scan.builder.get().row_offset != 0)
1864  "SELECT OFFSET predicate not allowed in combination with "
1865  "OFFSET.");
1866  state.scan.builder.set_cell_offset(ival);
1867  }
1869  };
1870 
1872  scan_set_outfile(ParserState &state) : state(state) { }
1873  void operator()(char const *str, char const *end) const {
1874  if (state.scan.outfile != "")
1876  "SELECT INTO FILE multiply defined.");
1877  state.scan.outfile = String(str, end-str);
1878  trim_if(state.scan.outfile, is_any_of("'\""));
1879  }
1881  };
1882 
1883  struct scan_set_year {
1884  scan_set_year(ParserState &state) : state(state) { }
1885  void operator()(int ival) const {
1886  HQL_DEBUG_VAL("scan_set_year", ival);
1887  state.tmval.tm_year = ival - 1900;
1888  }
1890  };
1891 
1893  scan_set_month(ParserState &state) : state(state) { }
1894  void operator()(int ival) const {
1895  HQL_DEBUG_VAL("scan_set_month", ival);
1896  state.tmval.tm_mon = ival-1;
1897  }
1899  };
1900 
1901  struct scan_set_day {
1902  scan_set_day(ParserState &state) : state(state) { }
1903  void operator()(int ival) const {
1904  HQL_DEBUG_VAL("scan_set_day", ival);
1905  state.tmval.tm_mday = ival;
1906  }
1908  };
1909 
1911  scan_set_seconds(ParserState &state) : state(state) { }
1912  void operator()(int ival) const {
1913  HQL_DEBUG_VAL("scan_set_seconds", ival);
1914  state.tmval.tm_sec = ival;
1915  }
1917  };
1918 
1920  scan_set_minutes(ParserState &state) : state(state) { }
1921  void operator()(int ival) const {
1922  HQL_DEBUG_VAL("scan_set_minutes", ival);
1923  state.tmval.tm_min = ival;
1924  }
1926  };
1927 
1929  scan_set_hours(ParserState &state) : state(state) { }
1930  void operator()(int ival) const {
1931  HQL_DEBUG_VAL("scan_set_hours", ival);
1932  state.tmval.tm_hour = ival;
1933  }
1935  };
1936 
1938  scan_set_decimal_seconds(ParserState &state) : state(state) { }
1939  void operator()(double dval) const {
1940  HQL_DEBUG_VAL("scan_set_decimal_seconds", dval);
1941  state.decimal_seconds = dval;
1942  }
1944  };
1945 
1947  scan_set_nanoseconds(ParserState &state) : state(state) { }
1948  void operator()(int ival) const {
1949  HQL_DEBUG_VAL("scan_set_nanoseconds", ival);
1950  state.nanoseconds = ival;
1951  }
1953  };
1954 
1956  scan_set_relop(ParserState &state, int relop)
1957  : state(state), relop(relop) { }
1958  void operator()(char const *str, char const *end) const {
1959  process();
1960  }
1961  void operator()(const char c) const {
1962  process();
1963  }
1964  void process() const {
1965  if (state.scan.current_timestamp_set) {
1966  switch (relop) {
1967  case RELOP_EQ:
1968  if (state.scan.start_time_set || state.scan.end_time_set)
1969  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
1970  state.scan.set_time_interval(state.scan.current_timestamp,
1971  state.scan.current_timestamp);
1972  break;
1973  case RELOP_GT:
1974  if (state.scan.end_time_set ||
1975  (state.scan.start_time_set &&
1976  state.scan.start_time() >= state.scan.current_timestamp))
1977  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
1978  state.scan.set_end_time(state.scan.current_timestamp);
1979  break;
1980  case RELOP_GE:
1981  if (state.scan.end_time_set ||
1982  (state.scan.start_time_set &&
1983  state.scan.start_time() > state.scan.current_timestamp))
1984  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
1985  state.scan.set_end_time(state.scan.current_timestamp + 1);
1986  break;
1987  case RELOP_LT:
1988  if (state.scan.start_time_set ||
1989  (state.scan.end_time_set &&
1990  state.scan.start_time() <= (state.scan.current_timestamp + 1)))
1991  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
1992  state.scan.set_start_time(state.scan.current_timestamp + 1);
1993  break;
1994  case RELOP_LE:
1995  if (state.scan.start_time_set ||
1996  (state.scan.end_time_set &&
1997  state.scan.end_time() <= state.scan.current_timestamp))
1998  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
1999  state.scan.set_start_time(state.scan.current_timestamp);
2000  break;
2001  case RELOP_SW:
2002  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp operator (=^)");
2003  }
2004  state.scan.current_timestamp_set = false;
2005  state.scan.current_relop = 0;
2006  }
2007  else if (state.scan.current_rowkey_set) {
2008  HT_ASSERT(state.scan.current_rowkey_set);
2009 
2010  switch (relop) {
2011  case RELOP_EQ:
2012  state.scan.current_ri.set_start(state.scan.current_rowkey, true);
2013  state.scan.current_ri.set_end(state.scan.current_rowkey, true);
2014  break;
2015  case RELOP_LT:
2016  state.scan.current_ri.set_start(state.scan.current_rowkey, false);
2017  break;
2018  case RELOP_LE:
2019  state.scan.current_ri.set_start(state.scan.current_rowkey, true);
2020  break;
2021  case RELOP_GT:
2022  state.scan.current_ri.set_end(state.scan.current_rowkey, false);
2023  break;
2024  case RELOP_GE:
2025  state.scan.current_ri.set_end(state.scan.current_rowkey, true);
2026  break;
2027  case RELOP_SW:
2028  HT_THROW(Error::HQL_PARSE_ERROR, "Bad use of operator (=^)");
2029  }
2030  state.scan.current_rowkey_set = false;
2031  state.scan.current_relop = 0;
2032  }
2033  else if (state.scan.current_cell_row.size()
2034  && state.scan.current_ci.empty()) {
2035  std::string &row = state.scan.current_cell_row;
2036  std::string &column = state.scan.current_cell_column;
2037 
2038  switch (relop) {
2039  case RELOP_EQ:
2040  state.scan.current_ci.set_start(row, column, true);
2041  state.scan.current_ci.set_end(row, column, true);
2042  break;
2043  case RELOP_LT:
2044  state.scan.current_ci.set_start(row, column, false);
2045  break;
2046  case RELOP_LE:
2047  state.scan.current_ci.set_start(row, column, true);
2048  break;
2049  case RELOP_GT:
2050  state.scan.current_ci.set_end(row, column, false);
2051  break;
2052  case RELOP_GE:
2053  state.scan.current_ci.set_end(row, column, true);
2054  case RELOP_SW:
2055  HT_THROW(Error::HQL_PARSE_ERROR, "Bad use of operator (=^)");
2056  }
2057  row.clear();
2058  column.clear();
2059  state.scan.current_relop = 0;
2060  }
2061  else
2062  state.scan.current_relop = relop;
2063  }
2065  int relop;
2066  };
2067 
2069  scan_set_boolop(ParserState &state, int boolop)
2070  : state(state), boolop(boolop) { }
2071  void operator()(char const *str, char const *end) const {
2072  state.scan.last_boolean_op = boolop;
2073  }
2075  int boolop;
2076  };
2077 
2078  struct scan_set_time {
2079  scan_set_time(ParserState &state) : state(state){ }
2080  void operator()(char const *str, char const *end) const {
2081  std::string time_str = strip_quotes(str, end-str);
2082 
2083  try {
2084  state.scan.current_timestamp = parse_ts(time_str.c_str());
2085  }
2086  catch (std::runtime_error &e) {
2088  "Unable to parse timestamp - '%s'",
2089  time_str.c_str());
2090  }
2091  if (state.scan.current_relop != 0) {
2092  switch (state.scan.current_relop) {
2093  case RELOP_EQ:
2094  if (state.scan.start_time_set || state.scan.end_time_set)
2095  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
2096  state.scan.set_time_interval(state.scan.current_timestamp,
2097  state.scan.current_timestamp + 1);
2098  break;
2099  case RELOP_LT:
2100  if (state.scan.end_time_set ||
2101  (state.scan.start_time_set &&
2102  state.scan.start_time() >= state.scan.current_timestamp))
2103  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
2104  state.scan.set_end_time(state.scan.current_timestamp);
2105  break;
2106  case RELOP_LE:
2107  if (state.scan.end_time_set ||
2108  (state.scan.start_time_set &&
2109  state.scan.start_time() > state.scan.current_timestamp))
2110  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
2111  state.scan.set_end_time(state.scan.current_timestamp + 1);
2112  break;
2113  case RELOP_GT:
2114  if (state.scan.start_time_set ||
2115  (state.scan.end_time_set &&
2116  state.scan.end_time() <= (state.scan.current_timestamp + 1)))
2117  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
2118  state.scan.set_start_time(state.scan.current_timestamp + 1);
2119  break;
2120  case RELOP_GE:
2121  if (state.scan.start_time_set ||
2122  (state.scan.end_time_set &&
2123  state.scan.end_time() <= state.scan.current_timestamp))
2124  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp expression");
2125  state.scan.set_start_time(state.scan.current_timestamp);
2126  break;
2127  case RELOP_SW:
2128  HT_THROW(Error::HQL_PARSE_ERROR, "Bad timestamp operator (=^)");
2129  }
2130  state.scan.current_relop = 0;
2131  state.scan.current_timestamp_set = false;
2132  }
2133  else
2134  state.scan.current_timestamp_set = true;
2135 
2136  System::initialize_tm(&state.tmval);
2137  state.decimal_seconds = 0;
2138  state.nanoseconds = 0;
2139  }
2141  };
2142 
2144  scan_set_return_deletes(ParserState &state) : state(state) { }
2145  void operator()(char const *str, char const *end) const {
2146  state.scan.builder.set_return_deletes(true);
2147  }
2149  };
2150 
2152  scan_set_scan_and_filter_rows(ParserState &state) : state(state) { }
2153  void operator()(char const *str, char const *end) const {
2154  state.scan.builder.set_scan_and_filter_rows(true);
2155  }
2157  };
2158 
2159  struct set_noescape {
2160  set_noescape(ParserState &state) : state(state) { }
2161  void operator()(char const *str, char const *end) const {
2162  state.escape = false;
2163  state.load_flags |= LoadDataFlags::NO_ESCAPE;
2164  }
2166  };
2167 
2168  struct set_no_log {
2169  set_no_log(ParserState &state) : state(state) { }
2170  void operator()(char const *str, char const *end) const {
2171  state.load_flags |= LoadDataFlags::NO_LOG;
2172  }
2174  };
2175 
2177  scan_set_keys_only(ParserState &state) : state(state) { }
2178  void operator()(char const *str, char const *end) const {
2179  state.scan.keys_only=true;
2180  state.scan.builder.set_keys_only(true);
2181  }
2183  };
2184 
2186  set_insert_timestamp(ParserState &state) : state(state) { }
2187  void operator()(char const *str, char const *end) const {
2188  std::string time_str = strip_quotes(str, end-str);
2189 
2190  try {
2191  state.current_insert_value.timestamp = parse_ts(time_str.c_str());
2192  }
2193  catch (std::runtime_error &e) {
2195  "Unable to parse INSERT timestamp - '%s'",
2196  time_str.c_str());
2197  }
2198  }
2200  };
2201 
2203  set_insert_rowkey(ParserState &state) : state(state) { }
2204  void operator()(char const *str, char const *end) const {
2205  state.current_insert_value.row_key =
2206  strip_quotes(str, end-str);
2207  }
2209  };
2210 
2212  set_insert_rowkey_call(ParserState &state) : state(state) { }
2213  void operator()(char const *str, char const *end) const {
2214  to_lower(state.current_insert_value.row_key);
2215  state.validate_function(state.current_insert_value.row_key);
2216  state.current_insert_value.row_key_is_call = true;
2217  }
2219  };
2220 
2222  set_insert_columnkey(ParserState &state) : state(state) { }
2223  void operator()(char const *str, char const *end) const {
2224  state.current_insert_value.column_key = String(str, end-str);
2225  trim_if(state.current_insert_value.column_key, is_any_of("'\""));
2226  }
2228  };
2229 
2231  set_insert_value(ParserState &state) : state(state) { }
2232  void operator()(char const *str, char const *end) const {
2233  state.current_insert_value.value = String(str, end-str);
2234  trim_if(state.current_insert_value.value, is_any_of("'\""));
2235  }
2237  };
2238 
2240  set_insert_value_call(ParserState &state) : state(state) { }
2241  void operator()(char const *str, char const *end) const {
2242  to_lower(state.current_insert_value.value);
2243  state.validate_function(state.current_insert_value.value);
2244  state.current_insert_value.value_is_call = true;
2245  }
2247  };
2248 
2250  add_insert_value(ParserState &state) : state(state) { }
2251  void operator()(char const *str, char const *end) const {
2252  const InsertRecord &rec = state.current_insert_value;
2253  char *cq;
2254  Cell cell;
2255 
2256  state.execute_all_functions(state.current_insert_value);
2257 
2258  cell.row_key = rec.row_key.c_str();
2259  cell.column_family = rec.column_key.c_str();
2260 
2261  if ((cq = (char*)strchr(rec.column_key.c_str(), ':')) != 0) {
2262  *cq++ = 0;
2263  cell.column_qualifier = cq;
2264  }
2265  cell.timestamp = rec.timestamp;
2266  cell.value = (::uint8_t *)rec.value.c_str();
2267  cell.value_len = rec.value.length();
2268  cell.flag = FLAG_INSERT;
2269  state.inserts.add(cell);
2270  state.current_insert_value.clear();
2271  }
2273  };
2274 
2275  struct delete_column {
2276  delete_column(ParserState &state) : state(state) { }
2277  void operator()(char const *str, char const *end) const {
2278  std::string column(str, end-str);
2279  trim_if(column, is_any_of("'\""));
2280  state.delete_columns.push_back(column);
2281  }
2282  void operator()(const char c) const {
2283  state.delete_all_columns = true;
2284  }
2286  };
2287 
2289  delete_set_row(ParserState &state) : state(state) { }
2290  void operator()(char const *str, char const *end) const {
2291  state.delete_row = strip_quotes(str, end-str);
2292  }
2294  };
2295 
2297  set_delete_timestamp(ParserState &state) : state(state) { }
2298  void operator()(char const *str, char const *end) const {
2299  std::string time_str = strip_quotes(str, end-str);
2300 
2301  try {
2302  state.delete_time = parse_ts(time_str.c_str());
2303  }
2304  catch (std::runtime_error &e) {
2306  "Unable to parse DELETE timestamp - '%s'",
2307  time_str.c_str());
2308  }
2309  }
2311  };
2312 
2314  set_delete_version_timestamp(ParserState &state) : state(state) { }
2315  void operator()(char const *str, char const *end) const {
2316  std::string time_str = strip_quotes(str, end-str);
2317 
2318  try {
2319  state.delete_version_time = parse_ts(time_str.c_str());
2320  }
2321  catch (std::runtime_error &e) {
2323  "Unable to parse DELETE timestamp - '%s'",
2324  time_str.c_str());
2325  }
2326  }
2328  };
2329 
2331  set_scanner_id(ParserState &state) : state(state) { }
2332  void operator()(char const *str, char const *end) const {
2333  state.scanner_id = (::uint32_t)strtol(str, 0, 10);
2334  }
2336  };
2337 
2338  struct set_nokeys {
2339  set_nokeys(ParserState &state) : state(state) { }
2340  void operator()(char const *str, char const *end) const {
2341  state.nokeys=true;
2342  }
2344  };
2345 
2347  set_flags_range_type(ParserState &state) : state(state) { }
2348  void operator()(char const *str, char const *end) const {
2349  std::string range_type_str = String(str, end-str);
2350  trim_if(range_type_str, is_any_of("'\""));
2351  to_lower(range_type_str);
2352  if (range_type_str == "all")
2354  else if (range_type_str == "root")
2356  else if (range_type_str == "metadata")
2358  else if (range_type_str == "system")
2360  else if (range_type_str == "user")
2362  else
2364  format("Invalid range type specifier: %s", range_type_str.c_str()));
2365 
2366  }
2368  };
2369 
2371  set_flags_compaction_type(ParserState &state) : state(state) { }
2372  void operator()(char const *str, char const *end) const {
2373  std::string compaction_type_str = String(str, end-str);
2374  trim_if(compaction_type_str, is_any_of("'\""));
2375  to_lower(compaction_type_str);
2376  if (compaction_type_str == "minor")
2378  else if (compaction_type_str == "major")
2380  else if (compaction_type_str == "merging")
2382  else if (compaction_type_str == "gc")
2384  else
2386  format("Invalid compaction type specifier: %s", compaction_type_str.c_str()));
2387 
2388  }
2390  };
2391 
2393  set_flags_index_type(ParserState &state) : state(state) { }
2394  void operator()(char const *str, char const *end) const {
2395  std::string index_type_str = String(str, end-str);
2396  to_lower(index_type_str);
2397  if (index_type_str == "value")
2398  state.flags = TableParts::VALUE_INDEX;
2399  else if (index_type_str == "qualifier")
2400  state.flags = TableParts::QUALIFIER_INDEX;
2401  else
2403  format("Invalid index type specifier: %s", index_type_str.c_str()));
2404  }
2406  };
2407 
2408 
2410  set_variable_name(ParserState &state) : state(state) { }
2411  void operator()(char const *str, char const *end) const {
2412  std::string name = String(str, end-str);
2413  to_upper(name);
2414  state.current_variable_spec.code = SystemVariable::string_to_code(name);
2415  if (state.current_variable_spec.code == -1)
2417  format("Unrecognized variable name: %s", name.c_str()));
2418  }
2420  };
2421 
2423  set_variable_value(ParserState &state) : state(state) { }
2424  void operator()(char const *str, char const *end) const {
2425  std::string value = String(str, end-str);
2426  to_lower(value);
2427  if (value == "true")
2428  state.current_variable_spec.value = true;
2429  else
2430  state.current_variable_spec.value = false;
2431  state.variable_specs.push_back(state.current_variable_spec);
2432  }
2434  };
2435 
2436 
2437  struct Parser : grammar<Parser> {
2438  Parser(ParserState &state) : state(state) { }
2439 
2440  template <typename ScannerT>
2441  struct definition {
2442  definition(Parser const &self) {
2443  keywords =
2444  "access", "ACCESS", "Access", "GROUP", "group", "Group",
2445  "from", "FROM", "From", "start_time", "START_TIME", "Start_Time",
2446  "Start_time", "end_time", "END_TIME", "End_Time", "End_time",
2447  "into", "INTO", "Into", "table", "TABLE", "Table", "NAMESPACE", "Namespace",
2448  "cells", "CELLS", "value", "VALUE", "regexp", "REGEXP", "wait", "WAIT"
2449  "for", "FOR", "maintenance", "MAINTENANCE", "index", "INDEX",
2450  "qualifier", "QUALIFIER";
2451 
2455  chlit<> ONE('1');
2456  chlit<> ZERO('0');
2457  chlit<> SINGLEQUOTE('\'');
2458  chlit<> DOUBLEQUOTE('"');
2459  chlit<> QUESTIONMARK('?');
2460  chlit<> PLUS('+');
2461  chlit<> MINUS('-');
2462  chlit<> STAR('*');
2463  chlit<> SLASH('/');
2464  chlit<> COMMA(',');
2465  chlit<> SEMI(';');
2466  chlit<> COLON(':');
2467  chlit<> EQUAL('=');
2468  strlit<> DOUBLEEQUAL("==");
2469  chlit<> LT('<');
2470  strlit<> LE("<=");
2471  strlit<> GE(">=");
2472  chlit<> GT('>');
2473  strlit<> SW("=^");
2474  strlit<> RE("=~");
2475  strlit<> QUALPREFIX(":^");
2476  chlit<> LPAREN('(');
2477  chlit<> RPAREN(')');
2478  chlit<> LBRACK('[');
2479  chlit<> RBRACK(']');
2480  chlit<> POINTER('^');
2481  chlit<> DOT('.');
2482  strlit<> DOTDOT("..");
2483  strlit<> DOUBLEQUESTIONMARK("??");
2484  chlit<> PIPE('|');
2485 
2489  typedef inhibit_case<strlit<> > Token;
2490 
2491  Token CREATE = as_lower_d["create"];
2492  Token DROP = as_lower_d["drop"];
2493  Token BALANCE = as_lower_d["balance"];
2494  Token DURATION = as_lower_d["duration"];
2495  Token ADD = as_lower_d["add"];
2496  Token MODIFY = as_lower_d["modify"];
2497  Token USE = as_lower_d["use"];
2498  Token RENAME = as_lower_d["rename"];
2499  Token COLUMN = as_lower_d["column"];
2500  Token COLUMNS = as_lower_d["columns"];
2501  Token FAMILY = as_lower_d["family"];
2502  Token ALTER = as_lower_d["alter"];
2503  Token HELP = as_lower_d["help"];
2504  Token NAMESPACE = as_lower_d["namespace"];
2505  Token DATABASE = as_lower_d["database"];
2506  Token TABLE = as_lower_d["table"];
2507  Token TABLES = as_lower_d["tables"];
2508  Token TO = as_lower_d["to"];
2509  Token TTL = as_lower_d["ttl"];
2510  Token TYPE = as_lower_d["type"];
2511  Token COUNTER = as_lower_d["counter"];
2512  Token MONTHS = as_lower_d["months"];
2513  Token MONTH = as_lower_d["month"];
2514  Token WEEKS = as_lower_d["weeks"];
2515  Token WEEK = as_lower_d["week"];
2516  Token DAYS = as_lower_d["days"];
2517  Token DAY = as_lower_d["day"];
2518  Token HOURS = as_lower_d["hours"];
2519  Token HOUR = as_lower_d["hour"];
2520  Token MINUTES = as_lower_d["minutes"];
2521  Token MINUTE = as_lower_d["minute"];
2522  Token SECONDS = as_lower_d["seconds"];
2523  Token SECOND = as_lower_d["second"];
2524  Token IN_MEMORY = as_lower_d["in_memory"];
2525  Token BLOCKSIZE = as_lower_d["blocksize"];
2526  Token ACCESS = as_lower_d["access"];
2527  Token GROUP = as_lower_d["group"];
2528  Token INDEX = as_lower_d["index"];
2529  Token QUALIFIER = as_lower_d["qualifier"];
2530  Token DESCRIBE = as_lower_d["describe"];
2531  Token SHOW = as_lower_d["show"];
2532  Token GET = as_lower_d["get"];
2533  Token LISTING = as_lower_d["listing"];
2534  Token ESC_HELP = as_lower_d["\\h"];
2535  Token SELECT = as_lower_d["select"];
2536  Token STOP = as_lower_d["stop"];
2537  Token START_TIME = as_lower_d["start_time"];
2538  Token END_TIME = as_lower_d["end_time"];
2539  Token FROM = as_lower_d["from"];
2540  Token WHERE = as_lower_d["where"];
2541  Token REGEXP = as_lower_d["regexp"];
2542  Token ROW = as_lower_d["row"];
2543  Token CELL = as_lower_d["cell"];
2544  Token CELLS = as_lower_d["cells"];
2545  Token ROW_KEY_COLUMN = as_lower_d["row_key_column"];
2546  Token TIMESTAMP_COLUMN = as_lower_d["timestamp_column"];
2547  Token HEADER_FILE = as_lower_d["header_file"];
2548  Token ROW_UNIQUIFY_CHARS = as_lower_d["row_uniquify_chars"];
2549  Token IGNORE_UNKNOWN_CFS = as_lower_d["ignore_unknown_cfs"];
2550  Token IGNORE_UNKNOWN_COLUMNS = as_lower_d["ignore_unknown_columns"];
2551  Token DUP_KEY_COLS = as_lower_d["dup_key_cols"];
2552  Token DUPLICATE_KEY_COLUMNS = as_lower_d["duplicate_key_columns"];
2553  Token NO_TIMESTAMPS = as_lower_d["no_timestamps"];
2554  Token START_ROW = as_lower_d["start_row"];
2555  Token END_ROW = as_lower_d["end_row"];
2556  Token INCLUSIVE = as_lower_d["inclusive"];
2557  Token EXCLUSIVE = as_lower_d["exclusive"];
2558  Token MAX_VERSIONS = as_lower_d["max_versions"];
2559  Token REVS = as_lower_d["revs"];
2560  Token LIMIT = as_lower_d["limit"];
2561  Token CELL_LIMIT = as_lower_d["cell_limit"];
2562  Token CELL_LIMIT_PER_FAMILY = as_lower_d["cell_limit_per_family"];
2563  Token OFFSET = as_lower_d["offset"];
2564  Token CELL_OFFSET = as_lower_d["cell_offset"];
2565  Token INTO = as_lower_d["into"];
2566  Token FILE = as_lower_d["file"];
2567  Token LOAD = as_lower_d["load"];
2568  Token DATA = as_lower_d["data"];
2569  Token INFILE = as_lower_d["infile"];
2570  Token TIMESTAMP = as_lower_d["timestamp"];
2571  Token TIME_ORDER = as_lower_d["time_order"];
2572  Token ASC = as_lower_d["asc"];
2573  Token DESC = as_lower_d["desc"];
2574  Token VERSION = as_lower_d["version"];
2575  Token INSERT = as_lower_d["insert"];
2576  Token DELETE = as_lower_d["delete"];
2577  Token VALUE = as_lower_d["value"];
2578  Token VALUES = as_lower_d["values"];
2579  Token COMPRESSOR = as_lower_d["compressor"];
2580  Token GROUP_COMMIT_INTERVAL = as_lower_d["group_commit_interval"];
2581  Token DUMP = as_lower_d["dump"];
2582  Token PSEUDO = as_lower_d["pseudo"];
2583  Token STATS = as_lower_d["stats"];
2584  Token STARTS = as_lower_d["starts"];
2585  Token WITH = as_lower_d["with"];
2586  Token IF = as_lower_d["if"];
2587  Token NOT = as_lower_d["not"];
2588  Token EXISTS = as_lower_d["exists"];
2589  Token DISPLAY_TIMESTAMPS = as_lower_d["display_timestamps"];
2590  Token DISPLAY_REVISIONS = as_lower_d["display_revisions"];
2591  Token RETURN_DELETES = as_lower_d["return_deletes"];
2592  Token SCAN_AND_FILTER_ROWS = as_lower_d["scan_and_filter_rows"];
2593  Token KEYS_ONLY = as_lower_d["keys_only"];
2594  Token RANGE = as_lower_d["range"];
2595  Token UPDATE = as_lower_d["update"];
2596  Token SCANNER = as_lower_d["scanner"];
2597  Token ON = as_lower_d["on"];
2598  Token DESTROY = as_lower_d["destroy"];
2599  Token FETCH = as_lower_d["fetch"];
2600  Token SCANBLOCK = as_lower_d["scanblock"];
2601  Token CLOSE = as_lower_d["close"];
2602  Token SHUTDOWN = as_lower_d["shutdown"];
2603  Token MASTER = as_lower_d["master"];
2604  Token REPLAY = as_lower_d["replay"];
2605  Token START = as_lower_d["start"];
2606  Token COMMIT = as_lower_d["commit"];
2607  Token LOG = as_lower_d["log"];
2608  Token BLOOMFILTER = as_lower_d["bloomfilter"];
2609  Token TRUE = as_lower_d["true"];
2610  Token FALSE = as_lower_d["false"];
2611  Token AND = as_lower_d["and"];
2612  Token OR = as_lower_d["or"];
2613  Token LIKE = as_lower_d["like"];
2614  Token NO_CACHE = as_lower_d["no_cache"];
2615  Token NOESCAPE = as_lower_d["noescape"];
2616  Token NO_ESCAPE = as_lower_d["no_escape"];
2617  Token NO_LOG = as_lower_d["no_log"];
2618  Token IDS = as_lower_d["ids"];
2619  Token NOKEYS = as_lower_d["nokeys"];
2620  Token SINGLE_CELL_FORMAT = as_lower_d["single_cell_format"];
2621  Token BUCKETS = as_lower_d["buckets"];
2622  Token REPLICATION = as_lower_d["replication"];
2623  Token WAIT = as_lower_d["wait"];
2624  Token FOR = as_lower_d["for"];
2625  Token MAINTENANCE = as_lower_d["maintenance"];
2626  Token HEAPCHECK = as_lower_d["heapcheck"];
2627  Token ALGORITHM = as_lower_d["algorithm"];
2628  Token COMPACT = as_lower_d["compact"];
2629  Token ALL = as_lower_d["all"];
2630  Token ROOT = as_lower_d["root"];
2631  Token METADATA = as_lower_d["metadata"];
2632  Token SYSTEM = as_lower_d["system"];
2633  Token USER = as_lower_d["user"];
2634  Token RANGES = as_lower_d["ranges"];
2635  Token MINOR = as_lower_d["minor"];
2636  Token MAJOR = as_lower_d["major"];
2637  Token MERGING = as_lower_d["merging"];
2638  Token GC = as_lower_d["gc"];
2639  Token FS = as_lower_d["fs"];
2640  Token SET = as_lower_d["set"];
2641  Token REBUILD = as_lower_d["rebuild"];
2642  Token INDICES = as_lower_d["indices"];
2643  Token STATUS = as_lower_d["status"];
2644 
2648  boolean_literal
2649  = lexeme_d[TRUE | FALSE]
2650  ;
2651 
2652  identifier
2653  = lexeme_d[(alpha_p >> *(alnum_p | '_')) - (keywords)];
2654 
2655  string_literal
2656  = single_string_literal
2657  | double_string_literal
2658  ;
2659 
2660  pseudo_table_reference
2661  = lexeme_d["^." >> +alnum_p >> *('.' >> +alnum_p)]
2662  ;
2663 
2664  parameter_list
2665  = ch_p('(') >> ch_p(')')
2666  ;
2667 
2668  single_string_literal
2669  = confix_p(SINGLEQUOTE, *lex_escape_ch_p, SINGLEQUOTE);
2670 
2671  double_string_literal
2672  = confix_p(DOUBLEQUOTE, *lex_escape_ch_p, DOUBLEQUOTE);
2673 
2674  user_identifier
2675  = identifier
2676  | string_literal
2677  ;
2678 
2679  string_literal
2680  = single_string_literal
2681  | double_string_literal
2682  ;
2683 
2684  table_identifier
2685  = user_identifier >> *pseudo_table_reference
2686  ;
2687 
2688  regexp_literal
2689  = confix_p(SLASH, *lex_escape_ch_p , SLASH);
2690 
2691  statement
2692  = select_statement[set_command(self.state, COMMAND_SELECT)]
2693  | use_namespace_statement[set_command(self.state,
2695  | create_namespace_statement[set_command(self.state,
2697  | create_table_statement[finish_create_table_statement(self.state)]
2698  | describe_table_statement[set_command(self.state,
2700  | load_data_statement[set_command(self.state, COMMAND_LOAD_DATA)]
2701  | show_statement[set_command(self.state, COMMAND_SHOW_CREATE_TABLE)]
2702  | help_statement[set_help(self.state)]
2703  | insert_statement[set_command(self.state, COMMAND_INSERT)]
2704  | delete_statement[set_command(self.state, COMMAND_DELETE)]
2705  | get_listing_statement[set_command(self.state,
2707  | drop_namespace_statement[set_command(self.state, COMMAND_DROP_NAMESPACE)]
2708  | drop_table_statement[set_command(self.state, COMMAND_DROP_TABLE)]
2709  | rename_table_statement[set_command(self.state, COMMAND_RENAME_TABLE)]
2710  | alter_table_statement[finish_alter_table_statement(self.state)]
2711  | load_range_statement[set_command(self.state, COMMAND_LOAD_RANGE)]
2712  | dump_statement[set_command(self.state, COMMAND_DUMP)]
2713  | dump_table_statement[set_command(self.state, COMMAND_DUMP_TABLE)]
2714  | dump_pseudo_table_statement[set_command(self.state, COMMAND_DUMP_PSEUDO_TABLE)]
2715  | update_statement[set_command(self.state, COMMAND_UPDATE)]
2716  | create_scanner_statement[set_command(self.state,
2718  | destroy_scanner_statement[set_command(self.state,
2720  | fetch_scanblock_statement[set_command(self.state,
2722  | close_statement[set_command(self.state, COMMAND_CLOSE)]
2723  | shutdown_statement[set_command(self.state, COMMAND_SHUTDOWN)]
2724  | shutdown_master_statement[set_command(self.state, COMMAND_SHUTDOWN_MASTER)]
2725  | status_statement[set_command(self.state, COMMAND_STATUS)]
2726  | drop_range_statement[set_command(self.state, COMMAND_DROP_RANGE)]
2727  | replay_start_statement[set_command(self.state,
2729  | replay_log_statement[set_command(self.state, COMMAND_REPLAY_LOG)]
2730  | replay_commit_statement[set_command(self.state,
2732  | exists_table_statement[set_command(self.state, COMMAND_EXISTS_TABLE)]
2733  | wait_for_maintenance_statement[set_command(self.state, COMMAND_WAIT_FOR_MAINTENANCE)]
2734  | balance_statement[set_command(self.state, COMMAND_BALANCE)]
2735  | heapcheck_statement[set_command(self.state, COMMAND_HEAPCHECK)]
2736  | compact_statement[set_command(self.state, COMMAND_COMPACT)]
2737  | stop_statement[set_command(self.state, COMMAND_STOP)]
2738  | set_statement[set_command(self.state, COMMAND_SET)]
2739  | rebuild_indices_statement[set_command(self.state, COMMAND_REBUILD_INDICES)]
2740  ;
2741 
2742  rebuild_indices_statement
2743  = REBUILD
2744  >> *(index_type_spec[set_flags_index_type(self.state)])
2745  >> INDICES >> user_identifier[set_table_name(self.state)]
2746  ;
2747 
2748  index_type_spec
2749  = (VALUE | QUALIFIER)
2750  ;
2751 
2752  set_statement
2753  = SET >> set_variable_spec >> *(COMMA >> set_variable_spec )
2754  ;
2755 
2756  set_variable_spec
2757  = identifier[set_variable_name(self.state)]
2758  >> '=' >> (TRUE | FALSE)[set_variable_value(self.state)]
2759  ;
2760 
2761  stop_statement
2762  = STOP >> user_identifier[set_rangeserver(self.state)]
2763  ;
2764 
2765  compact_statement
2766  = COMPACT >> *(compact_type_option)
2767  >> TABLE >> user_identifier[set_table_name(self.state)]
2768  >> *(string_literal[set_str(self.state)])
2769  | COMPACT >> *(compact_type_option) >> RANGES
2770  >> (range_type[set_flags_range_type(self.state)]
2771  >> *(PIPE >> range_type[set_flags_range_type(self.state)]))
2772  ;
2773 
2774  range_type
2775  = ALL
2776  | ROOT
2777  | METADATA
2778  | SYSTEM
2779  | USER
2780  ;
2781 
2782  compact_type_option
2783  = TYPE >> '=' >> compaction_type[set_flags_compaction_type(self.state)]
2784  ;
2785 
2786  compaction_type
2787  = MINOR
2788  | MAJOR
2789  | MERGING
2790  | GC
2791  ;
2792 
2793  heapcheck_statement
2794  = HEAPCHECK >> *(string_literal[set_output_file(self.state)])
2795  ;
2796 
2797  balance_statement
2798  = BALANCE >> !(ALGORITHM >> EQUAL >> user_identifier[set_balance_algorithm(self.state)])
2799  >> *(range_move_spec_list)
2800  >> *(balance_option_spec)
2801  ;
2802 
2803  range_move_spec_list
2804  = range_move_spec[add_range_move_spec(self.state)] >> *(COMMA
2805  >> range_move_spec[add_range_move_spec(self.state)])
2806  ;
2807 
2808  range_move_spec
2809  = LPAREN
2810  >> range_spec >> COMMA
2811  >> string_literal[set_source(self.state)] >> COMMA
2812  >> string_literal[set_destination(self.state)]
2813  >> RPAREN
2814  ;
2815 
2816  balance_option_spec
2817  = DURATION >> EQUAL >> uint_p[balance_set_duration(self.state)]
2818  ;
2819 
2820  drop_range_statement
2821  = DROP >> RANGE >> range_spec
2822  ;
2823 
2824  replay_start_statement
2825  = REPLAY >> START
2826  ;
2827 
2828  replay_log_statement
2829  = REPLAY >> LOG >> user_identifier[set_input_file(self.state)]
2830  ;
2831 
2832  replay_commit_statement
2833  = REPLAY >> COMMIT
2834  ;
2835 
2836  close_statement
2837  = CLOSE
2838  ;
2839 
2840  wait_for_maintenance_statement
2841  = WAIT >> FOR >> MAINTENANCE
2842  ;
2843 
2844  shutdown_statement
2845  = SHUTDOWN
2846  ;
2847 
2848  shutdown_master_statement
2849  = SHUTDOWN >> MASTER
2850  ;
2851 
2852  status_statement
2853  = STATUS
2854  ;
2855 
2856  fetch_scanblock_statement
2857  = FETCH >> SCANBLOCK >> !(lexeme_d[(+digit_p)[
2858  set_scanner_id(self.state)]])
2859  ;
2860 
2861  destroy_scanner_statement
2862  = DESTROY >> SCANNER >> !(lexeme_d[(+digit_p)[
2863  set_scanner_id(self.state)]])
2864  ;
2865 
2866  create_scanner_statement
2867  = CREATE >> SCANNER >> ON >> range_spec
2868  >> !where_clause
2869  >> *(option_spec)
2870  ;
2871 
2872  update_statement
2873  = UPDATE >> user_identifier[set_table_name(self.state)]
2874  >> user_identifier[set_input_file(self.state)]
2875  ;
2876 
2877  load_range_statement
2878  = LOAD >> RANGE >> range_spec >> !(REPLAY[set_replay(self.state)])
2879  ;
2880 
2881  dump_statement
2882  = DUMP >> !(NOKEYS[set_nokeys(self.state)])
2883  >> string_literal[set_output_file(self.state)]
2884  ;
2885 
2886  dump_table_option_spec
2887  = MAX_VERSIONS >> *EQUAL >> uint_p[scan_set_max_versions(self.state)]
2888  | BUCKETS >> uint_p[scan_set_buckets(self.state)]
2889  | REVS >> !EQUAL >> uint_p[scan_set_max_versions(self.state)]
2890  | INTO >> FILE >> string_literal[scan_set_outfile(self.state)]
2891  | NO_TIMESTAMPS[scan_clear_display_timestamps(self.state)]
2892  | FS >> EQUAL >> single_string_literal[set_field_separator(self.state)]
2893  ;
2894 
2895  dump_table_statement
2896  = DUMP >> TABLE[scan_set_display_timestamps(self.state)]
2897  >> table_identifier[set_table_name(self.state)]
2898  >> !(COLUMNS >> ('*' | (column_selection >> *(COMMA >> column_selection))))
2899  >> !(dump_where_clause)
2900  >> *(dump_table_option_spec)
2901  ;
2902 
2903  dump_pseudo_table_statement
2904  = DUMP >> PSEUDO >> TABLE >> table_identifier[set_table_name(self.state)]
2905  >> INTO >> FILE >> string_literal[set_output_file(self.state)]
2906  ;
2907 
2908  range_spec
2909  = user_identifier[set_table_name(self.state)]
2910  >> LBRACK >> !(user_identifier[set_range_start_row(self.state)])
2911  >> DOTDOT
2912  >> (user_identifier | DOUBLEQUESTIONMARK)[
2913  set_range_end_row(self.state)] >> RBRACK
2914  ;
2915 
2916  drop_table_statement
2917  = DROP >> TABLE >> !(IF >> EXISTS[set_if_exists(self.state)])
2918  >> user_identifier[set_table_name(self.state)]
2919  ;
2920  rename_table_statement
2921  = RENAME >> TABLE
2922  >> user_identifier[set_table_name(self.state)]
2923  >> TO
2924  >> user_identifier[set_new_table_name(self.state)]
2925  ;
2926 
2927  alter_table_statement
2928  = ALTER >> TABLE >> user_identifier[start_alter_table(self.state)]
2929  >> ( WITH >> string_literal[set_input_file(self.state)] |
2930  +(ADD >> create_definitions
2931  | MODIFY[set_modify_flag(self.state, true)] >>
2932  create_definitions[set_modify_flag(self.state, false)]
2933  | drop_specification
2934  | RENAME >> COLUMN >> FAMILY >> rename_column_definition) )
2935  ;
2936 
2937  exists_table_statement
2938  = EXISTS >> TABLE >> user_identifier[set_table_name(self.state)]
2939  ;
2940 
2941  get_listing_statement
2942  = (SHOW >> TABLES[set_tables_only(self.state)]) | (GET >> LISTING)
2943  ;
2944 
2945  delete_statement
2946  = DELETE >> delete_column_clause
2947  >> FROM >> user_identifier[set_table_name(self.state)]
2948  >> WHERE >> ROW >> EQUAL >> string_literal[
2949  delete_set_row(self.state)]
2950  >> !(TIMESTAMP >> string_literal[set_delete_timestamp(self.state)]
2951  | VERSION >> string_literal[set_delete_version_timestamp(self.state)])
2952  ;
2953 
2954  delete_column_clause
2955  = (STAR[delete_column(self.state)] | (column_name[
2956  delete_column(self.state)]
2957  >> *(COMMA >> column_name[delete_column(self.state)])))
2958  ;
2959 
2960  insert_statement
2961  = INSERT >> INTO >> user_identifier[set_table_name(self.state)]
2962  >> VALUES >> insert_value_list
2963  ;
2964 
2965  insert_value_list
2966  = insert_value[add_insert_value(self.state)] >> *(COMMA
2967  >> insert_value[add_insert_value(self.state)])
2968  ;
2969 
2970  insert_value
2971  =
2972  (
2973  LPAREN
2974  >> ( string_literal[set_insert_rowkey(self.state)]
2975  | identifier[set_insert_rowkey(self.state)] >>
2976  parameter_list[set_insert_rowkey_call(self.state)] )
2977  >> COMMA
2978  >> string_literal[set_insert_columnkey(self.state)] >> COMMA
2979  >> ( string_literal[set_insert_value(self.state)]
2980  | identifier[set_insert_value(self.state)] >>
2981  parameter_list[set_insert_value_call(self.state)] )
2982  >> RPAREN
2983  | LPAREN
2984  >> string_literal[set_insert_timestamp(self.state)] >> COMMA
2985  >> ( string_literal[set_insert_rowkey(self.state)]
2986  | identifier[set_insert_rowkey(self.state)] >>
2987  parameter_list[set_insert_rowkey_call(self.state)] )
2988  >> COMMA
2989  >> string_literal[set_insert_columnkey(self.state)] >> COMMA
2990  >> ( string_literal[set_insert_value(self.state)]
2991  | identifier[set_insert_value(self.state)] >>
2992  parameter_list[set_insert_value_call(self.state)] )
2993  >> RPAREN
2994  )
2995  ;
2996 
2997  show_statement
2998  = (SHOW >> CREATE >> TABLE >> user_identifier[set_table_name(self.state)])
2999  ;
3000 
3001  help_statement
3002  = (HELP | ESC_HELP | QUESTIONMARK) >> *anychar_p
3003  ;
3004 
3005  describe_table_statement
3006  = DESCRIBE >> TABLE >> !(WITH >> IDS[set_with_ids(self.state)])
3007  >> user_identifier[set_table_name(self.state)]
3008  ;
3009 
3010  create_table_statement
3011  = CREATE >> TABLE
3012  >> user_identifier[start_create_table_statement(self.state)]
3013  >> ( LIKE >> user_identifier[set_clone_table_name(self.state)] |
3014  WITH >> string_literal[set_input_file(self.state)] |
3015  (create_definitions) >> *(table_option) )
3016  ;
3017 
3018  create_namespace_statement
3019  = CREATE >> (NAMESPACE | DATABASE)
3020  >> user_identifier[set_namespace(self.state)]
3021  >> !(IF >> NOT >> EXISTS[set_if_exists(self.state)])
3022  ;
3023 
3024  use_namespace_statement
3025  = USE >> user_identifier[set_namespace(self.state)]
3026  ;
3027 
3028  drop_namespace_statement
3029  = DROP >> (NAMESPACE | DATABASE) >> !(IF >> EXISTS[set_if_exists(self.state)])
3030  >> user_identifier[set_namespace(self.state)]
3031  ;
3032 
3033  table_option
3034  = GROUP_COMMIT_INTERVAL >> *EQUAL >> uint_p[set_group_commit_interval(self.state)]
3035  | access_group_option
3036  | column_option
3037  ;
3038 
3039  create_definitions
3040  = LPAREN >> create_definition
3041  >> *(COMMA >> create_definition)
3042  >> RPAREN
3043  ;
3044 
3045  create_definition
3046  = column_definition[close_column_family(self.state)]
3047  | access_group_definition[close_access_group(self.state)]
3048  | index_definition
3049  ;
3050 
3051  drop_specification
3052  = DROP >> LPAREN >> column_name[drop_column_family(self.state)]
3053  >> *(COMMA >> column_name[drop_column_family(self.state)])
3054  >> RPAREN
3055  | DROP >> *VALUE >> INDEX >> LPAREN
3056  >> column_name[drop_value_index(self.state)]
3057  >> *(COMMA >> column_name[drop_value_index(self.state)])
3058  >> RPAREN
3059  | DROP >> QUALIFIER >> INDEX >> LPAREN
3060  >> column_name[drop_qualifier_index(self.state)]
3061  >> *(COMMA >> column_name[drop_qualifier_index(self.state)])
3062  >> RPAREN
3063  ;
3064 
3065  rename_column_definition
3066  = LPAREN
3067  >> column_name[set_rename_column_family_old_name(self.state)] >> COMMA
3068  >> column_name[set_rename_column_family_new_name(self.state)]
3069  >> RPAREN
3070  ;
3071 
3072  modify_column_definitions
3073  = LPAREN
3074  >> modify_column_definition[close_column_family(self.state)]
3075  >> *(COMMA >> modify_column_definition[close_column_family(self.state)])
3076  >> RPAREN
3077  ;
3078 
3079  modify_column_definition
3080  = column_name[open_existing_column_family(self.state)] >> *(column_option)
3081  ;
3082 
3083  column_name
3084  = (identifier | string_literal)
3085  ;
3086 
3087  column_definition
3088  = column_name[open_column_family(self.state)] >> *(column_option)
3089  ;
3090 
3091  column_option
3092  = max_versions_option
3093  | time_order_option
3094  | ttl_option
3095  | counter_option
3096  ;
3097 
3098  max_versions_option
3099  = (MAX_VERSIONS | REVS) >> *EQUAL
3100  >> lexeme_d[(+digit_p)[set_max_versions(self.state)]]
3101  ;
3102 
3103  time_order_option
3104  = TIME_ORDER >> ASC[set_time_order(self.state)]
3105  | TIME_ORDER >> DESC[set_time_order(self.state)]
3106  ;
3107 
3108  ttl_option
3109  = TTL >> *EQUAL >> duration[set_ttl(self.state)]
3110  ;
3111 
3112  counter_option
3113  = COUNTER >> boolean_literal[set_counter(self.state)]
3114  | COUNTER[set_counter(self.state)]
3115  ;
3116 
3117  duration
3118  = ureal_p >> !(MONTHS | MONTH | WEEKS | WEEK | DAYS | DAY | HOURS |
3119  HOUR | MINUTES | MINUTE | SECONDS | SECOND)
3120  ;
3121 
3122  access_group_definition
3123  = ACCESS >> GROUP
3124  >> user_identifier[open_access_group(self.state)]
3125  >> LPAREN
3126  >> !(column_name[access_group_add_column_family(self.state)]
3127  >> *(COMMA >> column_name[access_group_add_column_family(self.state)]))
3128  >> RPAREN
3129  >> *(access_group_option | column_option)
3130  ;
3131 
3132  index_definition
3133  = QUALIFIER >> INDEX
3134  >> user_identifier[create_qualifier_index(self.state)]
3135  | INDEX
3136  >> user_identifier[create_index(self.state)]
3137  ;
3138 
3139  access_group_option
3140  = in_memory_option
3141  | blocksize_option
3142  | replication_option
3143  | COMPRESSOR >> *EQUAL >> string_literal[
3144  set_compressor(self.state)]
3145  | bloom_filter_option
3146  ;
3147 
3148  bloom_filter_option
3149  = BLOOMFILTER >> *EQUAL
3150  >> string_literal[set_bloom_filter(self.state)]
3151  ;
3152 
3153  in_memory_option
3154  = IN_MEMORY >> boolean_literal[set_in_memory(self.state)]
3155  | IN_MEMORY[set_in_memory(self.state)]
3156  ;
3157 
3158  blocksize_option
3159  = BLOCKSIZE >> *EQUAL >> uint_p[
3160  set_blocksize(self.state)]
3161  ;
3162 
3163  replication_option
3164  = REPLICATION >> *EQUAL >> uint_p[
3165  set_replication(self.state)]
3166  ;
3167 
3168  select_statement
3169  = SELECT >> !(CELLS)
3170  >> ('*' | (column_selection >> *(COMMA >> column_selection)))
3171  >> FROM >> user_identifier[set_table_name(self.state)]
3172  >> !where_clause
3173  >> *(option_spec)
3174  ;
3175 
3176  column_selection
3177  = (identifier[scan_add_column_family(self.state)] >> QUALPREFIX >>
3178  user_identifier[scan_add_column_qualifier(self.state,
3179  PREFIX_QUALIFIER)])
3180  | (identifier[scan_add_column_family(self.state)]
3181  >> COLON
3182  >> user_identifier[scan_add_column_qualifier(self.state)])
3183  | (identifier[scan_add_column_family(self.state)]
3184  >> COLON
3185  >> STAR[scan_add_column_qualifier(self.state)])
3186  | (identifier[scan_add_column_family(self.state)]
3187  >> COLON
3188  >> regexp_literal[scan_add_column_qualifier(self.state)])
3189  | (identifier[scan_add_column_family(self.state, NO_QUALIFIER)])
3190  ;
3191 
3192  where_clause
3193  = WHERE
3194  >> where_predicate
3195  >> *(AND[scan_set_boolop(self.state, BOOLOP_AND)] >> where_predicate)
3196  ;
3197 
3198  dump_where_clause
3199  = WHERE
3200  >> dump_where_predicate
3201  >> *(AND[scan_set_boolop(self.state, BOOLOP_AND)] >> dump_where_predicate)
3202  ;
3203 
3204  relop
3205  = SW[scan_set_relop(self.state, RELOP_SW)]
3206  | EQUAL[scan_set_relop(self.state, RELOP_EQ)]
3207  | LE[scan_set_relop(self.state, RELOP_LE)]
3208  | LT[scan_set_relop(self.state, RELOP_LT)]
3209  | GE[scan_set_relop(self.state, RELOP_GE)]
3210  | GT[scan_set_relop(self.state, RELOP_GT)]
3211  ;
3212 
3213  time_predicate
3214  = !(string_literal[scan_set_time(self.state)] >> relop) >>
3215  TIMESTAMP >> relop >> string_literal[scan_set_time(self.state)]
3216  ;
3217 
3218  row_interval
3219  = !(string_literal[scan_set_row(self.state)] >> relop) >>
3220  ROW >> relop >> string_literal[scan_set_row(self.state)]
3221  ;
3222 
3223  row_predicate
3224  = row_interval[scan_add_row_interval(self.state)]
3225  | LPAREN >> row_interval[scan_add_row_interval(self.state)] >>
3226  *( OR >> row_interval[scan_add_row_interval(self.state)]) >> RPAREN
3227  | ROW >> REGEXP >> string_literal[scan_set_row_regexp(self.state)]
3228  ;
3229 
3230  cell_spec
3231  = string_literal[scan_set_cell_row(self.state)]
3232  >> COMMA >> string_literal[scan_set_cell_column(self.state)]
3233  ;
3234 
3235  cell_interval
3236  = !(cell_spec >> relop) >> CELL >> relop >> cell_spec
3237  ;
3238 
3239  cell_predicate
3240  = cell_interval
3241  | LPAREN >> cell_interval >> *( OR >> cell_interval ) >> RPAREN
3242  ;
3243 
3244  value_predicate
3245  = VALUE >> REGEXP >> string_literal[scan_set_value_regexp(self.state)]
3246  ;
3247 
3248  column_match
3249  = identifier[scan_set_column_predicate_name(self.state)]
3250  >> !column_qualifier_spec
3251  >> '='
3252  >> string_literal[scan_set_column_predicate_value(self.state, ColumnPredicate::EXACT_MATCH)]
3253  | identifier[scan_set_column_predicate_name(self.state)]
3254  >> !column_qualifier_spec
3255  >> SW
3256  >> string_literal[scan_set_column_predicate_value(self.state, ColumnPredicate::PREFIX_MATCH)]
3257  | identifier[scan_set_column_predicate_name(self.state)]
3258  >> !column_qualifier_spec
3259  >> RE
3260  >> regexp_literal[scan_set_column_predicate_value(self.state, ColumnPredicate::REGEX_MATCH)]
3261  | REGEXP >> LPAREN
3262  >> identifier[scan_set_column_predicate_name(self.state)]
3263  >> !column_qualifier_spec
3264  >> COMMA
3265  >> string_literal[scan_set_column_predicate_value(self.state, ColumnPredicate::REGEX_MATCH)]
3266  >> RPAREN
3267  | EXISTS >> LPAREN
3268  >> identifier[scan_set_column_predicate_name(self.state)]
3269  >> column_qualifier_spec
3270  >> RPAREN[scan_set_column_predicate_value(self.state)]
3271  ;
3272 
3273  column_qualifier_spec
3274  = COLON
3278  ;
3279 
3280  column_predicate
3281  = column_match >> *( OR[scan_set_boolop(self.state, BOOLOP_OR)] >> column_match )
3282  ;
3283 
3284  where_predicate
3285  = cell_predicate
3286  | row_predicate
3287  | time_predicate
3288  | value_predicate
3289  | column_predicate
3290  ;
3291 
3292  dump_where_predicate
3293  = ROW >> REGEXP >> string_literal[scan_set_row_regexp(self.state)]
3294  | time_predicate
3295  | value_predicate
3296  ;
3297 
3298  option_spec
3299  = MAX_VERSIONS >> *EQUAL >> uint_p[scan_set_max_versions(self.state)]
3300  | REVS >> !EQUAL >> uint_p[scan_set_max_versions(self.state)]
3301  | LIMIT >> EQUAL >> uint_p[scan_set_row_limit(self.state)]
3302  | LIMIT >> uint_p[scan_set_row_limit(self.state)]
3303  | CELL_LIMIT >> EQUAL >> uint_p[scan_set_cell_limit(self.state)]
3304  | CELL_LIMIT >> uint_p[scan_set_cell_limit(self.state)]
3305  | CELL_LIMIT_PER_FAMILY >> EQUAL >> uint_p[scan_set_cell_limit_per_family(self.state)]
3306  | CELL_LIMIT_PER_FAMILY >> uint_p[scan_set_cell_limit_per_family(self.state)]
3307  | OFFSET >> EQUAL >> uint_p[scan_set_row_offset(self.state)]
3308  | OFFSET >> uint_p[scan_set_row_offset(self.state)]
3309  | CELL_OFFSET >> EQUAL >> uint_p[scan_set_cell_offset(self.state)]
3310  | CELL_OFFSET >> uint_p[scan_set_cell_offset(self.state)]
3311  | INTO >> FILE >> string_literal[scan_set_outfile(self.state)]
3312  | DISPLAY_TIMESTAMPS[scan_set_display_timestamps(self.state)]
3313  | DISPLAY_REVISIONS[scan_set_display_revisions(self.state)]
3314  | RETURN_DELETES[scan_set_return_deletes(self.state)]
3315  | KEYS_ONLY[scan_set_keys_only(self.state)]
3316  | NO_CACHE[scan_set_no_cache(self.state)]
3317  | NOESCAPE[set_noescape(self.state)]
3318  | NO_ESCAPE[set_noescape(self.state)]
3319  | SCAN_AND_FILTER_ROWS[scan_set_scan_and_filter_rows(self.state)]
3320  | FS >> EQUAL >> single_string_literal[set_field_separator(self.state)]
3321  ;
3322 
3323  unused_tokens
3324  = START_TIME
3325  | END_TIME
3326  | START_ROW
3327  | END_ROW
3328  | INCLUSIVE
3329  | EXCLUSIVE
3330  | STATS
3331  | STARTS
3332  ;
3333 
3334  datetime
3335  = date >> time
3336  ;
3337 
3338  uint_parser<unsigned int, 10, 2, 2> uint2_p;
3339  uint_parser<unsigned int, 10, 4, 4> uint4_p;
3340 
3341  date
3342  = lexeme_d[limit_d(0u, 9999u)[uint4_p[scan_set_year(self.state)]]
3343  >> '-' // Year
3344  >> limit_d(1u, 12u)[uint2_p[scan_set_month(self.state)]]
3345  >> '-' // Month 01..12
3346  >> limit_d(1u, 31u)[uint2_p[scan_set_day(self.state)]]
3347  // Day 01..31
3348  ];
3349 
3350  time
3351  = lexeme_d[limit_d(0u, 23u)[uint2_p[scan_set_hours(self.state)]]
3352  >> COLON // Hours 00..23
3353  >> limit_d(0u, 59u)[uint2_p[scan_set_minutes(self.state)]]
3354  >> COLON // Minutes 00..59
3355  >> limit_d(0u, 59u)[uint2_p[scan_set_seconds(self.state)]]
3356  >> // Seconds 00..59
3357  !(real_p[scan_set_decimal_seconds(self.state)] |
3358  COLON >> uint_p[scan_set_nanoseconds(self.state)])
3359  ];
3360 
3361  year
3362  = lexeme_d[limit_d(0u, 9999u)[uint4_p[scan_set_year(self.state)]]]
3363  ;
3364 
3365  load_data_statement
3366  = LOAD >> DATA >> INFILE
3367  >> !(load_data_option >> *(load_data_option))
3368  >> load_data_input
3369  >> INTO
3370  >> (TABLE >> user_identifier[set_table_name(self.state)]
3371  | FILE >> user_identifier[set_output_file(self.state)])
3372  ;
3373 
3374  load_data_input
3375  = string_literal[set_input_file(self.state)]
3376  ;
3377 
3378  load_data_option
3379  = ROW_KEY_COLUMN >> EQUAL >> user_identifier[
3380  add_column(self.state)] >> *(PLUS >> user_identifier[
3381  add_column(self.state)])
3382  | TIMESTAMP_COLUMN >> EQUAL >> user_identifier[
3383  set_timestamp_column(self.state)]
3384  | HEADER_FILE >> EQUAL >> string_literal[
3385  set_header_file(self.state)]
3386  | ROW_UNIQUIFY_CHARS >> EQUAL >> uint_p[
3387  set_row_uniquify_chars(self.state)]
3388  | DUP_KEY_COLS >> EQUAL >> boolean_literal[
3389  set_dup_key_cols(self.state)]
3390  | DUP_KEY_COLS[set_dup_key_cols_true(self.state)]
3391  | DUPLICATE_KEY_COLUMNS[set_dup_key_cols_true(self.state)]
3392  | NOESCAPE[set_noescape(self.state)]
3393  | NO_ESCAPE[set_noescape(self.state)]
3394  | IGNORE_UNKNOWN_CFS[set_ignore_unknown_cfs(self.state)]
3395  | IGNORE_UNKNOWN_COLUMNS[set_ignore_unknown_cfs(self.state)]
3396  | SINGLE_CELL_FORMAT[set_single_cell_format(self.state)]
3397  | FS >> EQUAL >> single_string_literal[set_field_separator(self.state)]
3398  | NO_LOG[set_no_log(self.state)]
3399  ;
3400 
3405 #ifdef BOOST_SPIRIT_DEBUG
3406  BOOST_SPIRIT_DEBUG_RULE(column_definition);
3407  BOOST_SPIRIT_DEBUG_RULE(column_name);
3408  BOOST_SPIRIT_DEBUG_RULE(column_option);
3409  BOOST_SPIRIT_DEBUG_RULE(column_match);
3410  BOOST_SPIRIT_DEBUG_RULE(column_predicate);
3411  BOOST_SPIRIT_DEBUG_RULE(column_qualifier_spec);
3412  BOOST_SPIRIT_DEBUG_RULE(column_selection);
3413  BOOST_SPIRIT_DEBUG_RULE(create_definition);
3414  BOOST_SPIRIT_DEBUG_RULE(create_definitions);
3415  BOOST_SPIRIT_DEBUG_RULE(drop_specification);
3416  BOOST_SPIRIT_DEBUG_RULE(rename_column_definition);
3417  BOOST_SPIRIT_DEBUG_RULE(modify_column_definitions);
3418  BOOST_SPIRIT_DEBUG_RULE(modify_column_definition);
3419  BOOST_SPIRIT_DEBUG_RULE(create_table_statement);
3420  BOOST_SPIRIT_DEBUG_RULE(create_namespace_statement);
3421  BOOST_SPIRIT_DEBUG_RULE(use_namespace_statement);
3422  BOOST_SPIRIT_DEBUG_RULE(drop_namespace_statement);
3423  BOOST_SPIRIT_DEBUG_RULE(duration);
3424  BOOST_SPIRIT_DEBUG_RULE(identifier);
3425  BOOST_SPIRIT_DEBUG_RULE(user_identifier);
3426  BOOST_SPIRIT_DEBUG_RULE(max_versions_option);
3427  BOOST_SPIRIT_DEBUG_RULE(time_order_option);
3428  BOOST_SPIRIT_DEBUG_RULE(statement);
3429  BOOST_SPIRIT_DEBUG_RULE(string_literal);
3430  BOOST_SPIRIT_DEBUG_RULE(parameter_list);
3431  BOOST_SPIRIT_DEBUG_RULE(single_string_literal);
3432  BOOST_SPIRIT_DEBUG_RULE(double_string_literal);
3433  BOOST_SPIRIT_DEBUG_RULE(regexp_literal);
3434  BOOST_SPIRIT_DEBUG_RULE(ttl_option);
3435  BOOST_SPIRIT_DEBUG_RULE(counter_option);
3436  BOOST_SPIRIT_DEBUG_RULE(access_group_definition);
3437  BOOST_SPIRIT_DEBUG_RULE(index_definition);
3438  BOOST_SPIRIT_DEBUG_RULE(access_group_option);
3439  BOOST_SPIRIT_DEBUG_RULE(bloom_filter_option);
3440  BOOST_SPIRIT_DEBUG_RULE(in_memory_option);
3441  BOOST_SPIRIT_DEBUG_RULE(blocksize_option);
3442  BOOST_SPIRIT_DEBUG_RULE(replication_option);
3443  BOOST_SPIRIT_DEBUG_RULE(help_statement);
3444  BOOST_SPIRIT_DEBUG_RULE(describe_table_statement);
3445  BOOST_SPIRIT_DEBUG_RULE(show_statement);
3446  BOOST_SPIRIT_DEBUG_RULE(select_statement);
3447  BOOST_SPIRIT_DEBUG_RULE(where_clause);
3448  BOOST_SPIRIT_DEBUG_RULE(where_predicate);
3449  BOOST_SPIRIT_DEBUG_RULE(time_predicate);
3450  BOOST_SPIRIT_DEBUG_RULE(cell_interval);
3451  BOOST_SPIRIT_DEBUG_RULE(cell_predicate);
3452  BOOST_SPIRIT_DEBUG_RULE(cell_spec);
3453  BOOST_SPIRIT_DEBUG_RULE(relop);
3454  BOOST_SPIRIT_DEBUG_RULE(row_interval);
3455  BOOST_SPIRIT_DEBUG_RULE(row_predicate);
3456  BOOST_SPIRIT_DEBUG_RULE(value_predicate);
3457  BOOST_SPIRIT_DEBUG_RULE(option_spec);
3458  BOOST_SPIRIT_DEBUG_RULE(unused_tokens);
3459  BOOST_SPIRIT_DEBUG_RULE(datetime);
3460  BOOST_SPIRIT_DEBUG_RULE(date);
3461  BOOST_SPIRIT_DEBUG_RULE(time);
3462  BOOST_SPIRIT_DEBUG_RULE(year);
3463  BOOST_SPIRIT_DEBUG_RULE(load_data_statement);
3464  BOOST_SPIRIT_DEBUG_RULE(load_data_input);
3465  BOOST_SPIRIT_DEBUG_RULE(load_data_option);
3466  BOOST_SPIRIT_DEBUG_RULE(insert_statement);
3467  BOOST_SPIRIT_DEBUG_RULE(insert_value_list);
3468  BOOST_SPIRIT_DEBUG_RULE(insert_value);
3469  BOOST_SPIRIT_DEBUG_RULE(delete_statement);
3470  BOOST_SPIRIT_DEBUG_RULE(delete_column_clause);
3471  BOOST_SPIRIT_DEBUG_RULE(table_option);
3472  BOOST_SPIRIT_DEBUG_RULE(get_listing_statement);
3473  BOOST_SPIRIT_DEBUG_RULE(drop_table_statement);
3474  BOOST_SPIRIT_DEBUG_RULE(rename_table_statement);
3475  BOOST_SPIRIT_DEBUG_RULE(alter_table_statement);
3476  BOOST_SPIRIT_DEBUG_RULE(exists_table_statement);
3477  BOOST_SPIRIT_DEBUG_RULE(load_range_statement);
3478  BOOST_SPIRIT_DEBUG_RULE(dump_statement);
3479  BOOST_SPIRIT_DEBUG_RULE(dump_where_clause);
3480  BOOST_SPIRIT_DEBUG_RULE(dump_where_predicate);
3481  BOOST_SPIRIT_DEBUG_RULE(dump_table_option_spec);
3482  BOOST_SPIRIT_DEBUG_RULE(dump_table_statement);
3483  BOOST_SPIRIT_DEBUG_RULE(dump_pseudo_table_statement);
3484  BOOST_SPIRIT_DEBUG_RULE(range_spec);
3485  BOOST_SPIRIT_DEBUG_RULE(update_statement);
3486  BOOST_SPIRIT_DEBUG_RULE(create_scanner_statement);
3487  BOOST_SPIRIT_DEBUG_RULE(destroy_scanner_statement);
3488  BOOST_SPIRIT_DEBUG_RULE(fetch_scanblock_statement);
3489  BOOST_SPIRIT_DEBUG_RULE(close_statement);
3490  BOOST_SPIRIT_DEBUG_RULE(shutdown_statement);
3491  BOOST_SPIRIT_DEBUG_RULE(shutdown_master_statement);
3492  BOOST_SPIRIT_DEBUG_RULE(status_statement);
3493  BOOST_SPIRIT_DEBUG_RULE(drop_range_statement);
3494  BOOST_SPIRIT_DEBUG_RULE(replay_start_statement);
3495  BOOST_SPIRIT_DEBUG_RULE(replay_log_statement);
3496  BOOST_SPIRIT_DEBUG_RULE(replay_commit_statement);
3497  BOOST_SPIRIT_DEBUG_RULE(balance_statement);
3498  BOOST_SPIRIT_DEBUG_RULE(balance_option_spec);
3499  BOOST_SPIRIT_DEBUG_RULE(range_move_spec_list);
3500  BOOST_SPIRIT_DEBUG_RULE(range_move_spec);
3501  BOOST_SPIRIT_DEBUG_RULE(heapcheck_statement);
3502  BOOST_SPIRIT_DEBUG_RULE(compact_statement);
3503  BOOST_SPIRIT_DEBUG_RULE(compact_type_option);
3504  BOOST_SPIRIT_DEBUG_RULE(compaction_type);
3505  BOOST_SPIRIT_DEBUG_RULE(metadata_sync_statement);
3506  BOOST_SPIRIT_DEBUG_RULE(metadata_sync_option_spec);
3507  BOOST_SPIRIT_DEBUG_RULE(stop_statement);
3508  BOOST_SPIRIT_DEBUG_RULE(range_type);
3509  BOOST_SPIRIT_DEBUG_RULE(table_identifier);
3510  BOOST_SPIRIT_DEBUG_RULE(pseudo_table_reference);
3511  BOOST_SPIRIT_DEBUG_RULE(dump_pseudo_table_statement);
3512  BOOST_SPIRIT_DEBUG_RULE(set_statement);
3513  BOOST_SPIRIT_DEBUG_RULE(set_variable_spec);
3514  BOOST_SPIRIT_DEBUG_RULE(rebuild_indices_statement);
3515  BOOST_SPIRIT_DEBUG_RULE(index_type_spec);
3516 #endif
3517  }
3518 
3519  rule<ScannerT> const&
3520  start() const { return statement; }
3521 
3522  symbols<> keywords;
3523 
3524  rule<ScannerT> boolean_literal, column_definition, column_name,
3525  column_option, create_definition, create_definitions,
3526  drop_specification,
3527  rename_column_definition, create_table_statement, duration,
3528  modify_column_definitions, modify_column_definition,
3529  create_namespace_statement, use_namespace_statement,
3530  drop_namespace_statement, identifier, user_identifier,
3531  max_versions_option, time_order_option, statement,
3532  single_string_literal, double_string_literal, string_literal,
3533  parameter_list, regexp_literal, ttl_option, counter_option,
3534  access_group_definition, index_definition, access_group_option,
3535  bloom_filter_option, in_memory_option,
3536  blocksize_option, replication_option, help_statement,
3537  describe_table_statement, show_statement, select_statement,
3538  where_clause, where_predicate,
3539  time_predicate, relop, row_interval, row_predicate, column_match,
3540  column_predicate, column_qualifier_spec, value_predicate, column_selection,
3541  option_spec, unused_tokens, datetime, date, time, year,
3542  load_data_statement, load_data_input, load_data_option, insert_statement,
3543  insert_value_list, insert_value, delete_statement,
3544  delete_column_clause, table_option, table_option_in_memory,
3545  table_option_blocksize, table_option_replication, get_listing_statement,
3546  drop_table_statement, alter_table_statement,rename_table_statement,
3547  load_range_statement,
3548  dump_statement, dump_where_clause, dump_where_predicate,
3549  dump_table_statement, dump_table_option_spec, range_spec,
3550  exists_table_statement, update_statement, create_scanner_statement,
3551  destroy_scanner_statement, fetch_scanblock_statement,
3552  close_statement, shutdown_statement, shutdown_master_statement,
3553  drop_range_statement, replay_start_statement, replay_log_statement,
3554  replay_commit_statement, cell_interval, cell_predicate,
3555  cell_spec, wait_for_maintenance_statement, move_range_statement,
3556  balance_statement, range_move_spec_list, range_move_spec,
3557  balance_option_spec, heapcheck_statement, compact_statement,
3558  compact_type_option, compaction_type,
3559  metadata_sync_statement, metadata_sync_option_spec, stop_statement,
3560  range_type, table_identifier, pseudo_table_reference,
3561  dump_pseudo_table_statement, set_statement, set_variable_spec,
3562  rebuild_indices_statement, index_type_spec, status_statement;
3563  };
3564 
3566  };
3567  }
3568 }
3569 
3570 #endif // Hypertable_Lib_HqlParser_h
void set_id(int32_t id)
Sets column ID.
std::map< std::string, AccessGroupSpec * > modified_ag_map
Definition: HqlParser.h:327
void set_end_time(::int64_t end)
Definition: HqlParser.h:258
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:680
add_column(ParserState &state)
Definition: HqlParser.h:1526
set_str(ParserState &state)
Definition: HqlParser.h:1435
close_column_family(ParserState &state)
Definition: HqlParser.h:902
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2372
scan_set_cell_row(ParserState &state)
Definition: HqlParser.h:1655
set_counter(ParserState &state)
Definition: HqlParser.h:1002
std::string current_rename_column_old_name
Definition: HqlParser.h:357
set_delete_timestamp(ParserState &state)
Definition: HqlParser.h:2297
scan_set_seconds(ParserState &state)
Definition: HqlParser.h:1911
scan_set_row_offset(ParserState &state)
Definition: HqlParser.h:1842
std::vector< ColumnFamilySpec * > modified_cf_vector
Definition: HqlParser.h:324
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1445
void operator()(size_t duration) const
Definition: HqlParser.h:672
ColumnFamilySpec * get_new_column_family(const std::string &name)
Definition: HqlParser.h:413
add_range_move_spec(ParserState &state)
Definition: HqlParser.h:657
set_range_end_row(ParserState &state)
Definition: HqlParser.h:625
open_existing_column_family(ParserState &state)
Definition: HqlParser.h:888
scan_set_boolop(ParserState &state, int boolop)
Definition: HqlParser.h:2069
set_max_versions(ParserState &state)
Definition: HqlParser.h:1024
scan_set_cell_column(ParserState &state)
Definition: HqlParser.h:1663
Balance plan.
Definition: BalancePlan.h:38
Boost library.
Definition: Properties.cc:39
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2394
set_blocksize(ParserState &state)
Definition: HqlParser.h:1160
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
bool invalid_column_name(const std::string &name)
Definition: HqlParser.h:535
bool get_option_counter() const
Gets the counter option.
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1636
set_new_table_name(ParserState &state)
Definition: HqlParser.h:587
scan_set_row_limit(ParserState &state)
Definition: HqlParser.h:1809
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2080
scan_set_decimal_seconds(ParserState &state)
Definition: HqlParser.h:1938
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2170
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1276
String format(const char *fmt,...)
Returns a String using printf like format facilities Vanilla snprintf is about 1.5x faster than this...
Definition: String.cc:37
bool get_option_time_order_desc() const
Gets time order desc option.
std::vector< AccessGroupSpec * > modified_ag_vector
Definition: HqlParser.h:328
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1321
static const uint32_t FLAG_INSERT
Definition: KeySpec.h:47
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1485
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1570
ParserState(NamespacePtr &ns)
Definition: HqlParser.h:291
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1656
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2251
set_single_cell_format(ParserState &state)
Definition: HqlParser.h:1561
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1061
Declarations for SystemVariable.
start_create_table_statement(ParserState &state)
Definition: HqlParser.h:711
void set_end(const std::string &s, bool inclusive)
Definition: HqlParser.h:192
drop_qualifier_index(ParserState &state)
Definition: HqlParser.h:957
set_variable_value(ParserState &state)
Definition: HqlParser.h:2423
set_clone_table_name(ParserState &state)
Definition: HqlParser.h:609
scan_set_keys_only(ParserState &state)
Definition: HqlParser.h:2177
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:618
Po::typed_value< String > * str(String *v=0)
Definition: Properties.h:166
std::map< std::string, ColumnFamilySpec * > modified_cf_map
Definition: HqlParser.h:323
bool get_value_index() const
Gets value index flag.
Column family specification.
std::string current_column_predicate_qualifier
Definition: HqlParser.h:360
void set_qualifier_index(bool value)
Sets qualifier index flag.
const char * column_qualifier
Definition: Cell.h:68
void validate_function(const std::string &s)
Definition: HqlParser.h:364
set_insert_columnkey(ParserState &state)
Definition: HqlParser.h:2222
set_help(ParserState &state)
Definition: HqlParser.h:1418
Specification for column family options.
scan_add_column_family(ParserState &state, int qualifier_flag=0)
Definition: HqlParser.h:1582
set_input_file(ParserState &state)
Definition: HqlParser.h:1454
std::map< std::string, AccessGroupSpec * > new_ag_map
Definition: HqlParser.h:325
scan_set_value_regexp(ParserState &state)
Definition: HqlParser.h:1320
set_balance_algorithm(ParserState &state)
Definition: HqlParser.h:649
set_range_start_row(ParserState &state)
Definition: HqlParser.h:617
scan_set_outfile(ParserState &state)
Definition: HqlParser.h:1872
scan_set_max_versions(ParserState &state)
Definition: HqlParser.h:1798
static void initialize_tm(struct tm *tmval)
Initialize struct tm.
Definition: System.cc:94
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2213
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1725
open_access_group(ParserState &state)
Definition: HqlParser.h:1099
std::string current_cell_column
Definition: HqlParser.h:276
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2187
ColumnFamilyOptions table_cf_defaults
Definition: HqlParser.h:311
set_rangeserver(ParserState &state)
Definition: HqlParser.h:561
add_insert_value(ParserState &state)
Definition: HqlParser.h:2250
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1562
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1249
void operator()(int ival) const
Definition: HqlParser.h:1858
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2071
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:570
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2145
void operator()(const char c) const
Definition: HqlParser.h:1961
Specification for access group options.
void operator()(int ival) const
Definition: HqlParser.h:1894
scan_set_row(ParserState &state)
Definition: HqlParser.h:1724
set_if_exists(ParserState &state)
Definition: HqlParser.h:679
Declarations for Schema.
String generate_guid()
Generates a new GUID.
Definition: Unique.h:44
void operator()(int ival) const
Definition: HqlParser.h:1948
std::vector< ColumnFamilySpec * > new_cf_vector
Definition: HqlParser.h:322
ScanSpecBuilder builder
Definition: HqlParser.h:266
#define HQL_DEBUG(_expr_)
Definition: HqlParser.h:32
int string_to_code(const std::string &var_string)
Converts variable string to variable code.
set_insert_rowkey_call(ParserState &state)
Definition: HqlParser.h:2212
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1112
std::shared_ptr< Namespace > NamespacePtr
Shared smart pointer to Namespace.
Definition: Namespace.h:333
#define HT_ASSERT(_e_)
Definition: Logger.h:396
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:634
scan_set_cell_offset(ParserState &state)
Definition: HqlParser.h:1857
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:596
void set_value_index(bool value)
Sets value index flag.
set_header_file(ParserState &state)
Definition: HqlParser.h:1484
#define HQL_DEBUG_VAL(str, val)
Definition: HqlParser.h:33
void operator()(const char c) const
Definition: HqlParser.h:2282
set_insert_value(ParserState &state)
Definition: HqlParser.h:2231
finish_alter_table_statement(ParserState &state)
Definition: HqlParser.h:766
Declarations for RangeServerProtocol.
void operator()(const char c) const
Definition: HqlParser.h:1608
void operator()(size_t interval) const
Definition: HqlParser.h:1409
std::map< std::string, ColumnFamilySpec * > new_cf_map
Definition: HqlParser.h:321
void operator()(size_t replication) const
Definition: HqlParser.h:1172
scan_set_year(ParserState &state)
Definition: HqlParser.h:1884
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1527
File system utility functions.
void set_start(const std::string &s, bool inclusive)
Definition: HqlParser.h:186
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1599
set_command(ParserState &state, int cmd)
Definition: HqlParser.h:544
set_compressor(ParserState &state)
Definition: HqlParser.h:1141
const char * USER
Definition: Operation.cc:50
std::string current_rowkey
Definition: HqlParser.h:271
void operator()(char const *, char const *) const
Definition: HqlParser.h:722
set_insert_rowkey(ParserState &state)
Definition: HqlParser.h:2203
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:911
set_variable_name(ParserState &state)
Definition: HqlParser.h:2410
delete_column(ParserState &state)
Definition: HqlParser.h:2276
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2153
std::string strip_quotes(const char *str, size_t len)
Creates string with outer quotes stripped off.
Definition: HqlParser.h:515
void check_and_set_column_option(const std::string &name, const std::string &option)
Definition: HqlParser.h:393
std::string current_column_family
Definition: HqlParser.h:358
void execute_all_functions(InsertRecord &rec)
Definition: HqlParser.h:371
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2232
std::vector< String > columns
Definition: HqlParser.h:313
set_output_file(ParserState &state)
Definition: HqlParser.h:1444
bool get_qualifier_index() const
Gets qualifier index flag.
set_insert_value_call(ParserState &state)
Definition: HqlParser.h:2240
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:610
AccessGroupSpec * create_modified_access_group(const std::string &name)
Definition: HqlParser.h:470
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1025
std::string regex_from_literal(const char *str, size_t len)
Definition: HqlParser.h:521
Logging routines and macros.
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1628
void escape(String &str, const String &escape_chars)
Escapes a string.
Definition: Escaper.cc:34
set_dup_key_cols(ParserState &state)
Definition: HqlParser.h:1507
void operator()(int ival) const
Definition: HqlParser.h:1810
set_in_memory(ParserState &state)
Definition: HqlParser.h:1119
void operator()(int ival) const
Definition: HqlParser.h:1843
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2223
set_with_ids(ParserState &state)
Definition: HqlParser.h:695
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:696
std::string current_cell_row
Definition: HqlParser.h:275
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1537
const std::string & get_access_group() const
Gets access group name.
const char * row_key
Definition: Cell.h:66
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:855
set_table_name(ParserState &state)
Definition: HqlParser.h:569
Helper class for building a ScanSpec.
Definition: ScanSpec.h:318
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2277
ColumnFamilySpec * find_column_family_in_modified_ag(const std::string &name)
Definition: HqlParser.h:495
void operator()(char const *, char const *) const
Definition: HqlParser.h:545
void operator()(int ival) const
Definition: HqlParser.h:1903
ColumnFamilySpec * get_modified_column_family(const std::string &name)
Definition: HqlParser.h:423
set_modify_flag(ParserState &state, bool val)
Definition: HqlParser.h:845
void operator()(const char *str, const char *end) const
Definition: HqlParser.h:1042
void set_time_interval(::int64_t start,::int64_t end)
Definition: HqlParser.h:248
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:889
AccessGroupSpec * find_modified_access_group(const std::string &name)
Definition: HqlParser.h:488
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1664
set_field_separator(ParserState &state)
Definition: HqlParser.h:1569
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1120
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1193
scan_set_nanoseconds(ParserState &state)
Definition: HqlParser.h:1947
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2178
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:712
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:941
AccessGroupOptions table_ag_defaults
Definition: HqlParser.h:312
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1142
const char * METADATA
Definition: Operation.cc:48
Holds a variable code and boolean value.
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1508
SystemVariable::Spec current_variable_spec
Definition: HqlParser.h:344
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1620
Time related declarations.
set_timestamp_column(ParserState &state)
Definition: HqlParser.h:1536
static bool expand_tilde(String &fname)
Expands a leading tilde character in a filename.
Definition: FileUtils.cc:472
Parser(ParserState &state)
Definition: HqlParser.h:2438
int64_t parse_ts(const char *ts)
Inline function which parses a string with a timestamp in localtime and returns a 64bit nanosecond ti...
Definition: TimeInline.h:64
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1958
Access group specification.
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2204
scan_set_minutes(ParserState &state)
Definition: HqlParser.h:1920
scan_add_row_interval(ParserState &state)
Definition: HqlParser.h:1643
Hypertable definitions
static Schema * new_instance(const std::string &buf)
Creates schema object from XML schema string.
Definition: Schema.cc:202
drop_column_family(ParserState &state)
Definition: HqlParser.h:910
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2332
const std::string & get_name() const
Gets column family name.
scan_set_column_predicate_operation(ParserState &state, uint32_t operation)
Definition: HqlParser.h:1396
An inline helper function to parse timestamps in YYYY-mm-dd[ HH:MM[:SS[.SS|:NS]]] format...
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1873
#define LOG(_lvl_, _fmt_,...)
Definition: bmz-test.c:54
scan_set_time(ParserState &state)
Definition: HqlParser.h:2079
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1519
const bool ON
Constant representing on
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:658
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2424
void operator()(int ival) const
Definition: HqlParser.h:1788
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:562
std::set< std::string > new_cf
Definition: HqlParser.h:329
scan_set_cell_limit(ParserState &state)
Definition: HqlParser.h:1820
set_flags_range_type(ParserState &state)
Definition: HqlParser.h:2347
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2411
scan_set_relop(ParserState &state, int relop)
Definition: HqlParser.h:1956
void operator()(char const *, char const *) const
Definition: HqlParser.h:767
void operator()(int ival) const
Definition: HqlParser.h:1799
set_dup_key_cols_true(ParserState &state)
Definition: HqlParser.h:1518
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:650
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1100
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1455
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2298
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1003
set_flags_index_type(ParserState &state)
Definition: HqlParser.h:2393
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1419
void operator()(size_t blocksize) const
Definition: HqlParser.h:1161
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1340
InsertRecord current_insert_value
Definition: HqlParser.h:336
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:846
void set_access_group(const std::string &ag)
Sets access group.
const char * column_family
Definition: Cell.h:67
scan_set_display_revisions(ParserState &state)
Definition: HqlParser.h:1627
set_replay(ParserState &state)
Definition: HqlParser.h:703
scan_set_buckets(ParserState &state)
Definition: HqlParser.h:1787
#define HT_THROWF(_code_, _fmt_,...)
Definition: Error.h:490
Provides access to internal components of opaque key.
Definition: Key.h:40
void operator()(int ival) const
Definition: HqlParser.h:1921
open_column_family(ParserState &state)
Definition: HqlParser.h:854
ParserState & state
Definition: HqlParser.h:3565
scan_set_day(ParserState &state)
Definition: HqlParser.h:1902
set_group_commit_interval(ParserState &state)
Definition: HqlParser.h:1408
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1331
set_destination(ParserState &state)
Definition: HqlParser.h:641
set_flags_compaction_type(ParserState &state)
Definition: HqlParser.h:2371
const char * SYSTEM
Definition: Operation.cc:49
AccessGroupSpec * find_new_access_group(const std::string &name)
Definition: HqlParser.h:463
set_ttl(ParserState &state)
Definition: HqlParser.h:1060
close_access_group(ParserState &state)
Definition: HqlParser.h:1111
const char * ROOT
Definition: Operation.cc:47
definition(Parser const &self)
Definition: HqlParser.h:2442
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1584
scan_set_column_predicate_qualifier(ParserState &state, uint32_t operation)
Definition: HqlParser.h:1338
rule< ScannerT > const & start() const
Definition: HqlParser.h:3520
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2290
void check_and_set_access_group_option(const std::string &name, const std::string &option)
Definition: HqlParser.h:403
std::set< std::string > access_group_option_definition_set
Definition: HqlParser.h:331
void operator()(double dval) const
Definition: HqlParser.h:1939
std::vector< String > delete_columns
Definition: HqlParser.h:339
create_qualifier_index(ParserState &state)
Definition: HqlParser.h:1275
scan_set_row_regexp(ParserState &state)
Definition: HqlParser.h:1310
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:642
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2348
void set_start_time(::int64_t start)
Definition: HqlParser.h:253
set_nokeys(ParserState &state)
Definition: HqlParser.h:2339
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:958
scan_add_column_qualifier(ParserState &state, int _qualifier_flag=0)
Definition: HqlParser.h:1597
uint32_t value_len
Definition: Cell.h:72
std::shared_ptr< RangeMoveSpec > RangeMoveSpecPtr
create_index(ParserState &state)
Definition: HqlParser.h:1248
void operator()(int ival) const
Definition: HqlParser.h:1912
std::string current_column_predicate_name
Definition: HqlParser.h:359
AccessGroupSpec * create_new_access_group(const std::string &name)
Definition: HqlParser.h:452
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:554
set_scanner_id(ParserState &state)
Definition: HqlParser.h:2331
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:704
void operator()(int nchars) const
Definition: HqlParser.h:1546
scan_set_column_predicate_value(ParserState &state, uint32_t operation=0)
Definition: HqlParser.h:1362
std::shared_ptr< Schema > SchemaPtr
Smart pointer to Schema.
Definition: Schema.h:465
delete_set_row(ParserState &state)
Definition: HqlParser.h:2289
void operator()(int ival) const
Definition: HqlParser.h:1930
static const int64_t AUTO_ASSIGN
Definition: KeySpec.h:38
scan_set_hours(ParserState &state)
Definition: HqlParser.h:1929
uint8_t flag
Definition: Cell.h:73
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:688
set_namespace(ParserState &state)
Definition: HqlParser.h:553
set_time_order(ParserState &state)
Definition: HqlParser.h:1041
set_replication(ParserState &state)
Definition: HqlParser.h:1171
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1303
void operator()(int ival) const
Definition: HqlParser.h:1885
set_bloom_filter(ParserState &state)
Definition: HqlParser.h:1192
balance_set_duration(ParserState &state)
Definition: HqlParser.h:671
scan_set_return_deletes(ParserState &state)
Definition: HqlParser.h:2144
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:903
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1436
Encapsulates decomposed key and value.
Definition: Cell.h:32
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1311
std::set< std::string > column_option_definition_set
Definition: HqlParser.h:330
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2340
set_no_log(ParserState &state)
Definition: HqlParser.h:2169
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:975
void set_start(const std::string &row, const std::string &column, bool inclusive)
Definition: HqlParser.h:220
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:588
std::vector< AccessGroupSpec * > new_ag_vector
Definition: HqlParser.h:326
Error codes, Exception handling, error logging.
#define HT_THROW(_code_, _msg_)
Definition: Error.h:478
void add_column(ColumnFamilySpec *cf)
Adds column family specification.
static const char * END_ROW_MARKER
Definition: Key.h:49
set_tables_only(ParserState &state)
Definition: HqlParser.h:687
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1554
set_source(ParserState &state)
Definition: HqlParser.h:633
set_insert_timestamp(ParserState &state)
Definition: HqlParser.h:2186
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1212
start_alter_table(ParserState &state)
Definition: HqlParser.h:595
scan_set_month(ParserState &state)
Definition: HqlParser.h:1893
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2315
scan_set_no_cache(ParserState &state)
Definition: HqlParser.h:1302
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1644
set_ignore_unknown_cfs(ParserState &state)
Definition: HqlParser.h:1553
set_row_uniquify_chars(ParserState &state)
Definition: HqlParser.h:1545
const uint8_t * value
Definition: Cell.h:71
void execute_function(std::string &s)
Definition: HqlParser.h:383
void set_end(const std::string &row, const std::string &column, bool inclusive)
Definition: HqlParser.h:227
set_noescape(ParserState &state)
Definition: HqlParser.h:2160
std::vector< SystemVariable::Spec > variable_specs
Definition: HqlParser.h:345
Declarations for TableParts.
void operator()(int ival) const
Definition: HqlParser.h:1821
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2161
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:2241
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:1364
int64_t timestamp
Definition: Cell.h:69
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:626
void operator()(char const *str, char const *end) const
Definition: HqlParser.h:989
drop_value_index(ParserState &state)
Definition: HqlParser.h:940