CUBRID Engine  latest
access_json_table.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 //
20 // access_json_table.hpp - defines structures required to access json table spec type.
21 //
22 
23 #ifndef _ACCESS_JSON_TABLE_H_
24 #define _ACCESS_JSON_TABLE_H_
25 
26 #include <string>
27 #include <vector>
28 
29 #include <cstdint>
30 
31 #include "json_table_def.h"
32 #include "object_domain.h"
33 
34 // forward declarations
35 struct db_value;
36 struct tp_domain;
37 class regu_variable_node;
38 class JSON_DOC;
39 class JSON_ITERATOR;
40 
41 namespace cubxasl
42 {
43  namespace json_table
44  {
45 
46  struct column
47  {
49  char *m_path;
53  db_value *m_output_value_pointer; // should match xasl->outptr_list value pointers
54 
55  // there are three types of columns based on how they function:
56  // extract from path, exists at path or ordinality
58 
59  column ();
60 
61  void init ();
62  int evaluate (const JSON_DOC &input, size_t ordinality);
63  void clear_xasl (bool is_final_clear = true);
64 
65  private:
66  int evaluate_extract (const JSON_DOC &input);
67  int evaluate_exists (const JSON_DOC &input);
68  int evaluate_ordinality (size_t ordinality);
69 
70  int trigger_on_error (const JSON_DOC &input, const TP_DOMAIN_STATUS &status_cast, db_value &value_out);
71  int trigger_on_empty (db_value &value_out);
72  };
73 
74  struct node
75  {
76  char *m_path;
77  size_t m_ordinality; // will be used to count the row ordinality
78  column *m_output_columns; // columns part of output only
80  node *m_nested_nodes; // nested nodes
82  size_t m_id; // identifier for each node
85 
86  node (void);
87 
88  void init ();
89  void clear_columns (bool is_final_clear);
90  void clear_iterators (bool is_final_clear);
91  void clear_xasl (bool is_final_clear = true);
92  void init_iterator ();
93  void init_ordinality ();
94  };
95 
96  struct spec_node
97  {
100  std::size_t m_node_count; // the total number of nodes
101 
102  spec_node ();
103 
104  void init ();
105  void clear_xasl (bool is_final_clear = true);
106  };
107 
108  } // namespace json_table
109 } // namespace cubxasl
110 
111 // to be used outside namespace
115 
116 #endif // _ACCESS_JSON_TABLE_H_
int evaluate_ordinality(size_t ordinality)
int evaluate_extract(const JSON_DOC &input)
regu_variable_node * m_json_reguvar
json_table_column_behavior m_on_empty
int trigger_on_error(const JSON_DOC &input, const TP_DOMAIN_STATUS &status_cast, db_value &value_out)
enum tp_domain_status TP_DOMAIN_STATUS
json_table_column_behavior m_on_error
static int input()
Definition: cnvlex.c:1661
json_table_column_function m_function
int evaluate_exists(const JSON_DOC &input)
json_table_column_function
int trigger_on_empty(db_value &value_out)
int evaluate(const JSON_DOC &input, size_t ordinality)
void clear_xasl(bool is_final_clear=true)