OmniSciDB  7bf56492aa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
details::RelAlgDispatcher Class Reference
+ Collaboration diagram for details::RelAlgDispatcher:

Public Member Functions

 RelAlgDispatcher (const Catalog_Namespace::Catalog &cat)
 
std::vector< std::shared_ptr
< RelAlgNode > > 
run (const rapidjson::Value &rels, RelAlgDagBuilder &root_dag_builder)
 

Private Member Functions

std::shared_ptr< RelScandispatchTableScan (const rapidjson::Value &scan_ra)
 
std::shared_ptr< RelProjectdispatchProject (const rapidjson::Value &proj_ra, RelAlgDagBuilder &root_dag_builder)
 
std::shared_ptr< RelFilterdispatchFilter (const rapidjson::Value &filter_ra, RelAlgDagBuilder &root_dag_builder)
 
std::shared_ptr< RelAggregatedispatchAggregate (const rapidjson::Value &agg_ra)
 
std::shared_ptr< RelJoindispatchJoin (const rapidjson::Value &join_ra, RelAlgDagBuilder &root_dag_builder)
 
std::shared_ptr< RelSortdispatchSort (const rapidjson::Value &sort_ra)
 
std::shared_ptr< RelModifydispatchModify (const rapidjson::Value &logical_modify_ra)
 
std::shared_ptr< RelTableFunctiondispatchTableFunction (const rapidjson::Value &table_func_ra, RelAlgDagBuilder &root_dag_builder)
 
std::shared_ptr< RelLogicalValuesdispatchLogicalValues (const rapidjson::Value &logical_values_ra)
 
std::vector< std::shared_ptr
< const RelAlgNode > > 
getRelAlgInputs (const rapidjson::Value &node)
 
std::shared_ptr< const RelAlgNodeprev (const rapidjson::Value &crt_node)
 

Private Attributes

const Catalog_Namespace::Catalogcat_
 
std::vector< std::shared_ptr
< RelAlgNode > > 
nodes_
 

Detailed Description

Definition at line 1942 of file RelAlgDagBuilder.cpp.

Constructor & Destructor Documentation

details::RelAlgDispatcher::RelAlgDispatcher ( const Catalog_Namespace::Catalog cat)
inline

Definition at line 1944 of file RelAlgDagBuilder.cpp.

1944 : cat_(cat) {}
const Catalog_Namespace::Catalog & cat_

Member Function Documentation

std::shared_ptr<RelAggregate> details::RelAlgDispatcher::dispatchAggregate ( const rapidjson::Value &  agg_ra)
inlineprivate

Definition at line 2018 of file RelAlgDagBuilder.cpp.

References CHECK(), CHECK_EQ, field(), getRelAlgInputs(), anonymous_namespace{RelAlgDagBuilder.cpp}::indices_from_json_array(), anonymous_namespace{RelAlgDagBuilder.cpp}::parse_aggregate_expr(), and anonymous_namespace{RelAlgDagBuilder.cpp}::strings_from_json_array().

Referenced by run().

2018  {
2019  const auto inputs = getRelAlgInputs(agg_ra);
2020  CHECK_EQ(size_t(1), inputs.size());
2021  const auto fields = strings_from_json_array(field(agg_ra, "fields"));
2022  const auto group = indices_from_json_array(field(agg_ra, "group"));
2023  for (size_t i = 0; i < group.size(); ++i) {
2024  CHECK_EQ(i, group[i]);
2025  }
2026  if (agg_ra.HasMember("groups") || agg_ra.HasMember("indicator")) {
2027  throw QueryNotSupported("GROUP BY extensions not supported");
2028  }
2029  const auto& aggs_json_arr = field(agg_ra, "aggs");
2030  CHECK(aggs_json_arr.IsArray());
2031  std::vector<std::unique_ptr<const RexAgg>> aggs;
2032  for (auto aggs_json_arr_it = aggs_json_arr.Begin();
2033  aggs_json_arr_it != aggs_json_arr.End();
2034  ++aggs_json_arr_it) {
2035  aggs.emplace_back(parse_aggregate_expr(*aggs_json_arr_it));
2036  }
2037  return std::make_shared<RelAggregate>(group.size(), aggs, fields, inputs.front());
2038  }
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::unique_ptr< const RexAgg > parse_aggregate_expr(const rapidjson::Value &expr)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::vector< size_t > indices_from_json_array(const rapidjson::Value &json_idx_arr) noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelFilter> details::RelAlgDispatcher::dispatchFilter ( const rapidjson::Value &  filter_ra,
RelAlgDagBuilder root_dag_builder 
)
inlineprivate

Definition at line 2007 of file RelAlgDagBuilder.cpp.

References cat_, CHECK(), CHECK_EQ, field(), getRelAlgInputs(), anonymous_namespace{RelAlgDagBuilder.cpp}::node_id(), and anonymous_namespace{RelAlgDagBuilder.cpp}::parse_scalar_expr().

Referenced by run().

2008  {
2009  const auto inputs = getRelAlgInputs(filter_ra);
2010  CHECK_EQ(size_t(1), inputs.size());
2011  const auto id = node_id(filter_ra);
2012  CHECK(id);
2013  auto condition =
2014  parse_scalar_expr(field(filter_ra, "condition"), cat_, root_dag_builder);
2015  return std::make_shared<RelFilter>(condition, inputs.front());
2016  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
const Catalog_Namespace::Catalog & cat_
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::unique_ptr< const RexScalar > parse_scalar_expr(const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
unsigned node_id(const rapidjson::Value &ra_node) noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelJoin> details::RelAlgDispatcher::dispatchJoin ( const rapidjson::Value &  join_ra,
RelAlgDagBuilder root_dag_builder 
)
inlineprivate

Definition at line 2040 of file RelAlgDagBuilder.cpp.

References cat_, CHECK_EQ, field(), getRelAlgInputs(), json_str(), anonymous_namespace{RelAlgDagBuilder.cpp}::parse_scalar_expr(), and anonymous_namespace{RelAlgDagBuilder.cpp}::to_join_type().

Referenced by run().

2041  {
2042  const auto inputs = getRelAlgInputs(join_ra);
2043  CHECK_EQ(size_t(2), inputs.size());
2044  const auto join_type = to_join_type(json_str(field(join_ra, "joinType")));
2045  auto filter_rex =
2046  parse_scalar_expr(field(join_ra, "condition"), cat_, root_dag_builder);
2047  return std::make_shared<RelJoin>(inputs[0], inputs[1], filter_rex, join_type);
2048  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
JoinType to_join_type(const std::string &join_type_name)
const Catalog_Namespace::Catalog & cat_
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::unique_ptr< const RexScalar > parse_scalar_expr(const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelLogicalValues> details::RelAlgDispatcher::dispatchLogicalValues ( const rapidjson::Value &  logical_values_ra)
inlineprivate

Definition at line 2198 of file RelAlgDagBuilder.cpp.

References CHECK(), CHECK_EQ, field(), json_str(), anonymous_namespace{RelAlgDagBuilder.cpp}::parse_literal(), and anonymous_namespace{RelAlgDagBuilder.cpp}::parse_type().

Referenced by run().

2199  {
2200  const auto& tuple_type_arr = field(logical_values_ra, "type");
2201  CHECK(tuple_type_arr.IsArray());
2202  std::vector<TargetMetaInfo> tuple_type;
2203  for (auto tuple_type_arr_it = tuple_type_arr.Begin();
2204  tuple_type_arr_it != tuple_type_arr.End();
2205  ++tuple_type_arr_it) {
2206  const auto component_type = parse_type(*tuple_type_arr_it);
2207  const auto component_name = json_str(field(*tuple_type_arr_it, "name"));
2208  tuple_type.emplace_back(component_name, component_type);
2209  }
2210  const auto& inputs_arr = field(logical_values_ra, "inputs");
2211  CHECK(inputs_arr.IsArray());
2212  const auto& tuples_arr = field(logical_values_ra, "tuples");
2213  CHECK(tuples_arr.IsArray());
2214 
2215  if (inputs_arr.Size()) {
2216  throw QueryNotSupported("Inputs not supported in logical values yet.");
2217  }
2218 
2219  std::vector<RelLogicalValues::RowValues> values;
2220  if (tuples_arr.Size()) {
2221  for (const auto& row : tuples_arr.GetArray()) {
2222  CHECK(row.IsArray());
2223  const auto values_json = row.GetArray();
2224  if (!values.empty()) {
2225  CHECK_EQ(values[0].size(), values_json.Size());
2226  }
2227  values.emplace_back(RelLogicalValues::RowValues{});
2228  for (const auto& value : values_json) {
2229  CHECK(value.IsObject());
2230  CHECK(value.HasMember("literal"));
2231  values.back().emplace_back(parse_literal(value));
2232  }
2233  }
2234  }
2235 
2236  return std::make_shared<RelLogicalValues>(tuple_type, values);
2237  }
SQLTypeInfo parse_type(const rapidjson::Value &type_obj)
#define CHECK_EQ(x, y)
Definition: Logger.h:205
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
std::unique_ptr< RexLiteral > parse_literal(const rapidjson::Value &expr)
std::vector< std::unique_ptr< const RexScalar >> RowValues

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelModify> details::RelAlgDispatcher::dispatchModify ( const rapidjson::Value &  logical_modify_ra)
inlineprivate

Definition at line 2072 of file RelAlgDagBuilder.cpp.

References cat_, CHECK(), CHECK_EQ, RelModify::Delete, field(), getRelAlgInputs(), anonymous_namespace{RelAlgDagBuilder.cpp}::getTableFromScanNode(), json_bool(), anonymous_namespace{RelAlgDagBuilder.cpp}::json_node_to_string(), json_str(), and RelModify::Update.

Referenced by run().

2072  {
2073  const auto inputs = getRelAlgInputs(logical_modify_ra);
2074  CHECK_EQ(size_t(1), inputs.size());
2075 
2076  const auto table_descriptor = getTableFromScanNode(cat_, logical_modify_ra);
2077  if (table_descriptor->isView) {
2078  throw std::runtime_error("UPDATE of a view is unsupported.");
2079  }
2080 
2081  bool flattened = json_bool(field(logical_modify_ra, "flattened"));
2082  std::string op = json_str(field(logical_modify_ra, "operation"));
2083  RelModify::TargetColumnList target_column_list;
2084 
2085  if (op == "UPDATE") {
2086  const auto& update_columns = field(logical_modify_ra, "updateColumnList");
2087  CHECK(update_columns.IsArray());
2088 
2089  for (auto column_arr_it = update_columns.Begin();
2090  column_arr_it != update_columns.End();
2091  ++column_arr_it) {
2092  target_column_list.push_back(column_arr_it->GetString());
2093  }
2094  }
2095 
2096  auto modify_node = std::make_shared<RelModify>(
2097  cat_, table_descriptor, flattened, op, target_column_list, inputs[0]);
2098  switch (modify_node->getOperation()) {
2100  modify_node->applyDeleteModificationsToInputNode();
2101  break;
2102  }
2104  modify_node->applyUpdateModificationsToInputNode();
2105  break;
2106  }
2107  default:
2108  throw std::runtime_error("Unsupported RelModify operation: " +
2109  json_node_to_string(logical_modify_ra));
2110  }
2111 
2112  return modify_node;
2113  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
const Catalog_Namespace::Catalog & cat_
std::vector< std::string > TargetColumnList
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:49
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
const TableDescriptor * getTableFromScanNode(const Catalog_Namespace::Catalog &cat, const rapidjson::Value &scan_ra)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::string json_node_to_string(const rapidjson::Value &node) noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelProject> details::RelAlgDispatcher::dispatchProject ( const rapidjson::Value &  proj_ra,
RelAlgDagBuilder root_dag_builder 
)
inlineprivate

Definition at line 1991 of file RelAlgDagBuilder.cpp.

References cat_, CHECK(), CHECK_EQ, field(), getRelAlgInputs(), anonymous_namespace{RelAlgDagBuilder.cpp}::parse_scalar_expr(), and anonymous_namespace{RelAlgDagBuilder.cpp}::strings_from_json_array().

Referenced by run().

1992  {
1993  const auto inputs = getRelAlgInputs(proj_ra);
1994  CHECK_EQ(size_t(1), inputs.size());
1995  const auto& exprs_json = field(proj_ra, "exprs");
1996  CHECK(exprs_json.IsArray());
1997  std::vector<std::unique_ptr<const RexScalar>> exprs;
1998  for (auto exprs_json_it = exprs_json.Begin(); exprs_json_it != exprs_json.End();
1999  ++exprs_json_it) {
2000  exprs.emplace_back(parse_scalar_expr(*exprs_json_it, cat_, root_dag_builder));
2001  }
2002  const auto& fields = field(proj_ra, "fields");
2003  return std::make_shared<RelProject>(
2004  exprs, strings_from_json_array(fields), inputs.front());
2005  }
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
#define CHECK_EQ(x, y)
Definition: Logger.h:205
const Catalog_Namespace::Catalog & cat_
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::unique_ptr< const RexScalar > parse_scalar_expr(const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelSort> details::RelAlgDispatcher::dispatchSort ( const rapidjson::Value &  sort_ra)
inlineprivate

Definition at line 2050 of file RelAlgDagBuilder.cpp.

References CHECK(), CHECK_EQ, field(), anonymous_namespace{RelAlgDagBuilder.cpp}::get_int_literal_field(), getRelAlgInputs(), json_i64(), anonymous_namespace{RelAlgDagBuilder.cpp}::parse_nulls_position(), and anonymous_namespace{RelAlgDagBuilder.cpp}::parse_sort_direction().

Referenced by run().

2050  {
2051  const auto inputs = getRelAlgInputs(sort_ra);
2052  CHECK_EQ(size_t(1), inputs.size());
2053  std::vector<SortField> collation;
2054  const auto& collation_arr = field(sort_ra, "collation");
2055  CHECK(collation_arr.IsArray());
2056  for (auto collation_arr_it = collation_arr.Begin();
2057  collation_arr_it != collation_arr.End();
2058  ++collation_arr_it) {
2059  const size_t field_idx = json_i64(field(*collation_arr_it, "field"));
2060  const auto sort_dir = parse_sort_direction(*collation_arr_it);
2061  const auto null_pos = parse_nulls_position(*collation_arr_it);
2062  collation.emplace_back(field_idx, sort_dir, null_pos);
2063  }
2064  auto limit = get_int_literal_field(sort_ra, "fetch", -1);
2065  const auto offset = get_int_literal_field(sort_ra, "offset", 0);
2066  auto ret = std::make_shared<RelSort>(
2067  collation, limit > 0 ? limit : 0, offset, inputs.front());
2068  ret->setEmptyResult(limit == 0);
2069  return ret;
2070  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
int64_t get_int_literal_field(const rapidjson::Value &obj, const char field[], const int64_t default_val) noexcept
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
SortDirection parse_sort_direction(const rapidjson::Value &collation)
const int64_t json_i64(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:39
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
NullSortedPosition parse_nulls_position(const rapidjson::Value &collation)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelTableFunction> details::RelAlgDispatcher::dispatchTableFunction ( const rapidjson::Value &  table_func_ra,
RelAlgDagBuilder root_dag_builder 
)
inlineprivate

Definition at line 2115 of file RelAlgDagBuilder.cpp.

References cat_, CHECK(), CHECK_EQ, CHECK_GE, field(), getRelAlgInputs(), json_str(), anonymous_namespace{RelAlgDagBuilder.cpp}::parse_scalar_expr(), and prev().

Referenced by run().

2117  {
2118  const auto inputs = getRelAlgInputs(table_func_ra);
2119  CHECK_EQ(size_t(1), inputs.size());
2120 
2121  const auto& invocation = field(table_func_ra, "invocation");
2122  CHECK(invocation.IsObject());
2123 
2124  const auto& operands = field(invocation, "operands");
2125  CHECK(operands.IsArray());
2126  CHECK_GE(operands.Size(), unsigned(0));
2127 
2128  std::vector<const Rex*> col_inputs;
2129  std::vector<std::unique_ptr<const RexScalar>> table_func_inputs;
2130  std::vector<std::string> fields;
2131 
2132  for (auto exprs_json_it = operands.Begin(); exprs_json_it != operands.End();
2133  ++exprs_json_it) {
2134  const auto& expr_json = *exprs_json_it;
2135  CHECK(expr_json.IsObject());
2136 
2137  if (expr_json.HasMember("op")) {
2138  const auto op_str = json_str(field(expr_json, "op"));
2139  if (op_str == "CAST" && expr_json.HasMember("type")) {
2140  const auto& expr_type = field(expr_json, "type");
2141  CHECK(expr_type.IsObject());
2142  CHECK(expr_type.HasMember("type"));
2143  const auto& expr_type_name = json_str(field(expr_type, "type"));
2144  if (expr_type_name == "CURSOR") {
2145  CHECK(expr_json.HasMember("operands"));
2146  const auto& expr_operands = field(expr_json, "operands");
2147  CHECK(expr_operands.IsArray());
2148  if (expr_operands.Size() != 1) {
2149  throw std::runtime_error(
2150  "Table functions currently only support one ResultSet input");
2151  }
2152 
2153  CHECK(expr_json.HasMember("type"));
2154  const auto& expr_types = field(invocation, "type");
2155  CHECK(expr_types.IsArray());
2156 
2157  const auto prior_node = prev(table_func_ra);
2158  CHECK(prior_node);
2159  CHECK_EQ(prior_node->size(), expr_types.Size());
2160 
2161  // Forward the values from the prior node as RexInputs
2162  for (size_t i = 0; i < prior_node->size(); i++) {
2163  table_func_inputs.emplace_back(std::make_unique<RexAbstractInput>(i));
2164  col_inputs.emplace_back(table_func_inputs.back().get());
2165  }
2166  continue;
2167  }
2168  }
2169  }
2170  table_func_inputs.emplace_back(
2171  parse_scalar_expr(*exprs_json_it, cat_, root_dag_builder));
2172  }
2173 
2174  const auto& op_name = field(invocation, "op");
2175  CHECK(op_name.IsString());
2176 
2177  std::vector<std::unique_ptr<const RexScalar>> table_function_projected_outputs;
2178  const auto& row_types = field(table_func_ra, "rowType");
2179  CHECK(row_types.IsArray());
2180  CHECK_GE(row_types.Size(), unsigned(0));
2181  const auto& row_types_array = row_types.GetArray();
2182 
2183  for (size_t i = 0; i < row_types_array.Size(); i++) {
2184  // We don't care about the type information in rowType -- replace each output with
2185  // a reference to be resolved later in the translator
2186  table_function_projected_outputs.emplace_back(std::make_unique<RexRef>(i));
2187  fields.emplace_back("");
2188  }
2189 
2190  return std::make_shared<RelTableFunction>(op_name.GetString(),
2191  inputs[0],
2192  fields,
2193  col_inputs,
2194  table_func_inputs,
2195  table_function_projected_outputs);
2196  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
const Catalog_Namespace::Catalog & cat_
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
#define CHECK_GE(x, y)
Definition: Logger.h:210
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
std::vector< std::shared_ptr< const RelAlgNode > > getRelAlgInputs(const rapidjson::Value &node)
std::unique_ptr< const RexScalar > parse_scalar_expr(const rapidjson::Value &expr, const Catalog_Namespace::Catalog &cat, RelAlgDagBuilder &root_dag_builder)
std::shared_ptr< const RelAlgNode > prev(const rapidjson::Value &crt_node)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<RelScan> details::RelAlgDispatcher::dispatchTableScan ( const rapidjson::Value &  scan_ra)
inlineprivate

Definition at line 1983 of file RelAlgDagBuilder.cpp.

References cat_, CHECK(), anonymous_namespace{RelAlgDagBuilder.cpp}::check_empty_inputs_field(), anonymous_namespace{RelAlgDagBuilder.cpp}::getFieldNamesFromScanNode(), and anonymous_namespace{RelAlgDagBuilder.cpp}::getTableFromScanNode().

Referenced by run().

1983  {
1984  check_empty_inputs_field(scan_ra);
1985  CHECK(scan_ra.IsObject());
1986  const auto td = getTableFromScanNode(cat_, scan_ra);
1987  const auto field_names = getFieldNamesFromScanNode(scan_ra);
1988  return std::make_shared<RelScan>(td, field_names);
1989  }
const Catalog_Namespace::Catalog & cat_
CHECK(cgen_state)
const TableDescriptor * getTableFromScanNode(const Catalog_Namespace::Catalog &cat, const rapidjson::Value &scan_ra)
std::vector< std::string > getFieldNamesFromScanNode(const rapidjson::Value &scan_ra)
void check_empty_inputs_field(const rapidjson::Value &node) noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<std::shared_ptr<const RelAlgNode> > details::RelAlgDispatcher::getRelAlgInputs ( const rapidjson::Value &  node)
inlineprivate

Definition at line 2239 of file RelAlgDagBuilder.cpp.

References field(), nodes_, prev(), and anonymous_namespace{RelAlgDagBuilder.cpp}::strings_from_json_array().

Referenced by dispatchAggregate(), dispatchFilter(), dispatchJoin(), dispatchModify(), dispatchProject(), dispatchSort(), and dispatchTableFunction().

2240  {
2241  if (node.HasMember("inputs")) {
2242  const auto str_input_ids = strings_from_json_array(field(node, "inputs"));
2243  std::vector<std::shared_ptr<const RelAlgNode>> ra_inputs;
2244  for (const auto str_id : str_input_ids) {
2245  ra_inputs.push_back(nodes_[std::stoi(str_id)]);
2246  }
2247  return ra_inputs;
2248  }
2249  return {prev(node)};
2250  }
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
std::vector< std::shared_ptr< RelAlgNode > > nodes_
std::shared_ptr< const RelAlgNode > prev(const rapidjson::Value &crt_node)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<const RelAlgNode> details::RelAlgDispatcher::prev ( const rapidjson::Value &  crt_node)
inlineprivate

Definition at line 2252 of file RelAlgDagBuilder.cpp.

References CHECK(), CHECK_EQ, anonymous_namespace{RelAlgDagBuilder.cpp}::node_id(), and nodes_.

Referenced by dispatchTableFunction(), and getRelAlgInputs().

2252  {
2253  const auto id = node_id(crt_node);
2254  CHECK(id);
2255  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
2256  return nodes_.back();
2257  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
CHECK(cgen_state)
std::vector< std::shared_ptr< RelAlgNode > > nodes_
unsigned node_id(const rapidjson::Value &ra_node) noexcept

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<std::shared_ptr<RelAlgNode> > details::RelAlgDispatcher::run ( const rapidjson::Value &  rels,
RelAlgDagBuilder root_dag_builder 
)
inline

Definition at line 1946 of file RelAlgDagBuilder.cpp.

References CHECK(), CHECK_EQ, dispatchAggregate(), dispatchFilter(), dispatchJoin(), dispatchLogicalValues(), dispatchModify(), dispatchProject(), dispatchSort(), dispatchTableFunction(), dispatchTableScan(), field(), json_str(), anonymous_namespace{RelAlgDagBuilder.cpp}::node_id(), and nodes_.

Referenced by RelAlgDagBuilder::build().

1947  {
1948  for (auto rels_it = rels.Begin(); rels_it != rels.End(); ++rels_it) {
1949  const auto& crt_node = *rels_it;
1950  const auto id = node_id(crt_node);
1951  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
1952  CHECK(crt_node.IsObject());
1953  std::shared_ptr<RelAlgNode> ra_node = nullptr;
1954  const auto rel_op = json_str(field(crt_node, "relOp"));
1955  if (rel_op == std::string("EnumerableTableScan")) {
1956  ra_node = dispatchTableScan(crt_node);
1957  } else if (rel_op == std::string("LogicalProject")) {
1958  ra_node = dispatchProject(crt_node, root_dag_builder);
1959  } else if (rel_op == std::string("LogicalFilter")) {
1960  ra_node = dispatchFilter(crt_node, root_dag_builder);
1961  } else if (rel_op == std::string("LogicalAggregate")) {
1962  ra_node = dispatchAggregate(crt_node);
1963  } else if (rel_op == std::string("LogicalJoin")) {
1964  ra_node = dispatchJoin(crt_node, root_dag_builder);
1965  } else if (rel_op == std::string("LogicalSort")) {
1966  ra_node = dispatchSort(crt_node);
1967  } else if (rel_op == std::string("LogicalValues")) {
1968  ra_node = dispatchLogicalValues(crt_node);
1969  } else if (rel_op == std::string("LogicalTableModify")) {
1970  ra_node = dispatchModify(crt_node);
1971  } else if (rel_op == std::string("LogicalTableFunctionScan")) {
1972  ra_node = dispatchTableFunction(crt_node, root_dag_builder);
1973  } else {
1974  throw QueryNotSupported(std::string("Node ") + rel_op + " not supported yet");
1975  }
1976  nodes_.push_back(ra_node);
1977  }
1978 
1979  return std::move(nodes_);
1980  }
std::shared_ptr< RelAggregate > dispatchAggregate(const rapidjson::Value &agg_ra)
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::shared_ptr< RelProject > dispatchProject(const rapidjson::Value &proj_ra, RelAlgDagBuilder &root_dag_builder)
std::shared_ptr< RelScan > dispatchTableScan(const rapidjson::Value &scan_ra)
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
CHECK(cgen_state)
std::vector< std::shared_ptr< RelAlgNode > > nodes_
std::shared_ptr< RelFilter > dispatchFilter(const rapidjson::Value &filter_ra, RelAlgDagBuilder &root_dag_builder)
std::shared_ptr< RelJoin > dispatchJoin(const rapidjson::Value &join_ra, RelAlgDagBuilder &root_dag_builder)
std::shared_ptr< RelModify > dispatchModify(const rapidjson::Value &logical_modify_ra)
std::shared_ptr< RelSort > dispatchSort(const rapidjson::Value &sort_ra)
unsigned node_id(const rapidjson::Value &ra_node) noexcept
std::shared_ptr< RelLogicalValues > dispatchLogicalValues(const rapidjson::Value &logical_values_ra)
std::shared_ptr< RelTableFunction > dispatchTableFunction(const rapidjson::Value &table_func_ra, RelAlgDagBuilder &root_dag_builder)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

const Catalog_Namespace::Catalog& details::RelAlgDispatcher::cat_
private
std::vector<std::shared_ptr<RelAlgNode> > details::RelAlgDispatcher::nodes_
private

Definition at line 2260 of file RelAlgDagBuilder.cpp.

Referenced by getRelAlgInputs(), prev(), and run().


The documentation for this class was generated from the following file: