OmniSciDB  0bd2ec9cf4
 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 1814 of file RelAlgDagBuilder.cpp.

Constructor & Destructor Documentation

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

Definition at line 1816 of file RelAlgDagBuilder.cpp.

1816 : 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 1890 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().

1890  {
1891  const auto inputs = getRelAlgInputs(agg_ra);
1892  CHECK_EQ(size_t(1), inputs.size());
1893  const auto fields = strings_from_json_array(field(agg_ra, "fields"));
1894  const auto group = indices_from_json_array(field(agg_ra, "group"));
1895  for (size_t i = 0; i < group.size(); ++i) {
1896  CHECK_EQ(i, group[i]);
1897  }
1898  if (agg_ra.HasMember("groups") || agg_ra.HasMember("indicator")) {
1899  throw QueryNotSupported("GROUP BY extensions not supported");
1900  }
1901  const auto& aggs_json_arr = field(agg_ra, "aggs");
1902  CHECK(aggs_json_arr.IsArray());
1903  std::vector<std::unique_ptr<const RexAgg>> aggs;
1904  for (auto aggs_json_arr_it = aggs_json_arr.Begin();
1905  aggs_json_arr_it != aggs_json_arr.End();
1906  ++aggs_json_arr_it) {
1907  aggs.emplace_back(parse_aggregate_expr(*aggs_json_arr_it));
1908  }
1909  return std::make_shared<RelAggregate>(group.size(), aggs, fields, inputs.front());
1910  }
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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 1879 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().

1880  {
1881  const auto inputs = getRelAlgInputs(filter_ra);
1882  CHECK_EQ(size_t(1), inputs.size());
1883  const auto id = node_id(filter_ra);
1884  CHECK(id);
1885  auto condition =
1886  parse_scalar_expr(field(filter_ra, "condition"), cat_, root_dag_builder);
1887  return std::make_shared<RelFilter>(condition, inputs.front());
1888  }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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 1912 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().

1913  {
1914  const auto inputs = getRelAlgInputs(join_ra);
1915  CHECK_EQ(size_t(2), inputs.size());
1916  const auto join_type = to_join_type(json_str(field(join_ra, "joinType")));
1917  auto filter_rex =
1918  parse_scalar_expr(field(join_ra, "condition"), cat_, root_dag_builder);
1919  return std::make_shared<RelJoin>(inputs[0], inputs[1], filter_rex, join_type);
1920  }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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 2068 of file RelAlgDagBuilder.cpp.

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

Referenced by run().

2069  {
2070  const auto& tuple_type_arr = field(logical_values_ra, "type");
2071  CHECK(tuple_type_arr.IsArray());
2072  std::vector<TargetMetaInfo> tuple_type;
2073  for (auto tuple_type_arr_it = tuple_type_arr.Begin();
2074  tuple_type_arr_it != tuple_type_arr.End();
2075  ++tuple_type_arr_it) {
2076  const auto component_type = parse_type(*tuple_type_arr_it);
2077  const auto component_name = json_str(field(*tuple_type_arr_it, "name"));
2078  tuple_type.emplace_back(component_name, component_type);
2079  }
2080  const auto& inputs_arr = field(logical_values_ra, "inputs");
2081  CHECK(inputs_arr.IsArray());
2082  const auto& tuples_arr = field(logical_values_ra, "tuples");
2083  CHECK(tuples_arr.IsArray());
2084 
2085  if (inputs_arr.Size() || tuples_arr.Size()) {
2086  throw QueryNotSupported("Non-empty LogicalValues not supported yet");
2087  }
2088  return std::make_shared<RelLogicalValues>(tuple_type);
2089  }
SQLTypeInfo parse_type(const rapidjson::Value &type_obj)
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)

+ 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 1944 of file RelAlgDagBuilder.cpp.

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

Referenced by run().

1944  {
1945  const auto inputs = getRelAlgInputs(logical_modify_ra);
1946  CHECK_EQ(size_t(1), inputs.size());
1947 
1948  const auto table_descriptor = getTableFromScanNode(cat_, logical_modify_ra);
1949  if (table_descriptor->isView) {
1950  throw std::runtime_error("UPDATE of a view is unsupported.");
1951  }
1952 
1953  bool flattened = json_bool(field(logical_modify_ra, "flattened"));
1954  std::string op = json_str(field(logical_modify_ra, "operation"));
1955  RelModify::TargetColumnList target_column_list;
1956 
1957  if (op == "UPDATE") {
1958  const auto& update_columns = field(logical_modify_ra, "updateColumnList");
1959  CHECK(update_columns.IsArray());
1960 
1961  for (auto column_arr_it = update_columns.Begin();
1962  column_arr_it != update_columns.End();
1963  ++column_arr_it) {
1964  target_column_list.push_back(column_arr_it->GetString());
1965  }
1966  }
1967 
1968  auto modify_node = std::make_shared<RelModify>(
1969  cat_, table_descriptor, flattened, op, target_column_list, inputs[0]);
1970  switch (modify_node->getOperation()) {
1972  modify_node->applyDeleteModificationsToInputNode();
1973  break;
1974  }
1976  modify_node->applyUpdateModificationsToInputNode();
1977  }
1978  default:
1979  break;
1980  }
1981 
1982  return modify_node;
1983  }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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)

+ 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 1863 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().

1864  {
1865  const auto inputs = getRelAlgInputs(proj_ra);
1866  CHECK_EQ(size_t(1), inputs.size());
1867  const auto& exprs_json = field(proj_ra, "exprs");
1868  CHECK(exprs_json.IsArray());
1869  std::vector<std::unique_ptr<const RexScalar>> exprs;
1870  for (auto exprs_json_it = exprs_json.Begin(); exprs_json_it != exprs_json.End();
1871  ++exprs_json_it) {
1872  exprs.emplace_back(parse_scalar_expr(*exprs_json_it, cat_, root_dag_builder));
1873  }
1874  const auto& fields = field(proj_ra, "fields");
1875  return std::make_shared<RelProject>(
1876  exprs, strings_from_json_array(fields), inputs.front());
1877  }
std::vector< std::string > strings_from_json_array(const rapidjson::Value &json_str_arr) noexcept
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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 1922 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().

1922  {
1923  const auto inputs = getRelAlgInputs(sort_ra);
1924  CHECK_EQ(size_t(1), inputs.size());
1925  std::vector<SortField> collation;
1926  const auto& collation_arr = field(sort_ra, "collation");
1927  CHECK(collation_arr.IsArray());
1928  for (auto collation_arr_it = collation_arr.Begin();
1929  collation_arr_it != collation_arr.End();
1930  ++collation_arr_it) {
1931  const size_t field_idx = json_i64(field(*collation_arr_it, "field"));
1932  const auto sort_dir = parse_sort_direction(*collation_arr_it);
1933  const auto null_pos = parse_nulls_position(*collation_arr_it);
1934  collation.emplace_back(field_idx, sort_dir, null_pos);
1935  }
1936  auto limit = get_int_literal_field(sort_ra, "fetch", -1);
1937  const auto offset = get_int_literal_field(sort_ra, "offset", 0);
1938  auto ret = std::make_shared<RelSort>(
1939  collation, limit > 0 ? limit : 0, offset, inputs.front());
1940  ret->setEmptyResult(limit == 0);
1941  return ret;
1942  }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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 1985 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().

1987  {
1988  const auto inputs = getRelAlgInputs(table_func_ra);
1989  CHECK_EQ(size_t(1), inputs.size());
1990 
1991  const auto& invocation = field(table_func_ra, "invocation");
1992  CHECK(invocation.IsObject());
1993 
1994  const auto& operands = field(invocation, "operands");
1995  CHECK(operands.IsArray());
1996  CHECK_GE(operands.Size(), unsigned(0));
1997 
1998  std::vector<const Rex*> col_inputs;
1999  std::vector<std::unique_ptr<const RexScalar>> table_func_inputs;
2000  std::vector<std::string> fields;
2001 
2002  for (auto exprs_json_it = operands.Begin(); exprs_json_it != operands.End();
2003  ++exprs_json_it) {
2004  const auto& expr_json = *exprs_json_it;
2005  CHECK(expr_json.IsObject());
2006 
2007  if (expr_json.HasMember("op")) {
2008  const auto op_str = json_str(field(expr_json, "op"));
2009  if (op_str == "CAST" && expr_json.HasMember("type")) {
2010  const auto& expr_type = field(expr_json, "type");
2011  CHECK(expr_type.IsObject());
2012  CHECK(expr_type.HasMember("type"));
2013  const auto& expr_type_name = json_str(field(expr_type, "type"));
2014  if (expr_type_name == "CURSOR") {
2015  CHECK(expr_json.HasMember("operands"));
2016  const auto& expr_operands = field(expr_json, "operands");
2017  CHECK(expr_operands.IsArray());
2018  if (expr_operands.Size() != 1) {
2019  throw std::runtime_error(
2020  "Table functions currently only support one ResultSet input");
2021  }
2022 
2023  CHECK(expr_json.HasMember("type"));
2024  const auto& expr_types = field(invocation, "type");
2025  CHECK(expr_types.IsArray());
2026 
2027  const auto prior_node = prev(table_func_ra);
2028  CHECK(prior_node);
2029  CHECK_EQ(prior_node->size(), expr_types.Size());
2030 
2031  // Forward the values from the prior node as RexInputs
2032  for (size_t i = 0; i < prior_node->size(); i++) {
2033  table_func_inputs.emplace_back(std::make_unique<RexAbstractInput>(i));
2034  col_inputs.emplace_back(table_func_inputs.back().get());
2035  }
2036  continue;
2037  }
2038  }
2039  }
2040  table_func_inputs.emplace_back(
2041  parse_scalar_expr(*exprs_json_it, cat_, root_dag_builder));
2042  }
2043 
2044  const auto& op_name = field(invocation, "op");
2045  CHECK(op_name.IsString());
2046 
2047  std::vector<std::unique_ptr<const RexScalar>> table_function_projected_outputs;
2048  const auto& row_types = field(table_func_ra, "rowType");
2049  CHECK(row_types.IsArray());
2050  CHECK_GE(row_types.Size(), unsigned(0));
2051  const auto& row_types_array = row_types.GetArray();
2052 
2053  for (size_t i = 0; i < row_types_array.Size(); i++) {
2054  // We don't care about the type information in rowType -- replace each output with a
2055  // reference to be resolved later in the translator
2056  table_function_projected_outputs.emplace_back(std::make_unique<RexRef>(i));
2057  fields.emplace_back("");
2058  }
2059 
2060  return std::make_shared<RelTableFunction>(op_name.GetString(),
2061  inputs[0],
2062  fields,
2063  col_inputs,
2064  table_func_inputs,
2065  table_function_projected_outputs);
2066  }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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:206
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 1855 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().

1855  {
1856  check_empty_inputs_field(scan_ra);
1857  CHECK(scan_ra.IsObject());
1858  const auto td = getTableFromScanNode(cat_, scan_ra);
1859  const auto field_names = getFieldNamesFromScanNode(scan_ra);
1860  return std::make_shared<RelScan>(td, field_names);
1861  }
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 2091 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().

2092  {
2093  if (node.HasMember("inputs")) {
2094  const auto str_input_ids = strings_from_json_array(field(node, "inputs"));
2095  std::vector<std::shared_ptr<const RelAlgNode>> ra_inputs;
2096  for (const auto str_id : str_input_ids) {
2097  ra_inputs.push_back(nodes_[std::stoi(str_id)]);
2098  }
2099  return ra_inputs;
2100  }
2101  return {prev(node)};
2102  }
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 2104 of file RelAlgDagBuilder.cpp.

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

Referenced by dispatchTableFunction(), and getRelAlgInputs().

2104  {
2105  const auto id = node_id(crt_node);
2106  CHECK(id);
2107  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
2108  return nodes_.back();
2109  }
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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 1818 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().

1819  {
1820  for (auto rels_it = rels.Begin(); rels_it != rels.End(); ++rels_it) {
1821  const auto& crt_node = *rels_it;
1822  const auto id = node_id(crt_node);
1823  CHECK_EQ(static_cast<size_t>(id), nodes_.size());
1824  CHECK(crt_node.IsObject());
1825  std::shared_ptr<RelAlgNode> ra_node = nullptr;
1826  const auto rel_op = json_str(field(crt_node, "relOp"));
1827  if (rel_op == std::string("EnumerableTableScan")) {
1828  ra_node = dispatchTableScan(crt_node);
1829  } else if (rel_op == std::string("LogicalProject")) {
1830  ra_node = dispatchProject(crt_node, root_dag_builder);
1831  } else if (rel_op == std::string("LogicalFilter")) {
1832  ra_node = dispatchFilter(crt_node, root_dag_builder);
1833  } else if (rel_op == std::string("LogicalAggregate")) {
1834  ra_node = dispatchAggregate(crt_node);
1835  } else if (rel_op == std::string("LogicalJoin")) {
1836  ra_node = dispatchJoin(crt_node, root_dag_builder);
1837  } else if (rel_op == std::string("LogicalSort")) {
1838  ra_node = dispatchSort(crt_node);
1839  } else if (rel_op == std::string("LogicalValues")) {
1840  ra_node = dispatchLogicalValues(crt_node);
1841  } else if (rel_op == std::string("LogicalTableModify")) {
1842  ra_node = dispatchModify(crt_node);
1843  } else if (rel_op == std::string("LogicalTableFunctionScan")) {
1844  ra_node = dispatchTableFunction(crt_node, root_dag_builder);
1845  } else {
1846  throw QueryNotSupported(std::string("Node ") + rel_op + " not supported yet");
1847  }
1848  nodes_.push_back(ra_node);
1849  }
1850 
1851  return std::move(nodes_);
1852  }
std::shared_ptr< RelAggregate > dispatchAggregate(const rapidjson::Value &agg_ra)
#define CHECK_EQ(x, y)
Definition: Logger.h:201
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 2112 of file RelAlgDagBuilder.cpp.

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


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