OmniSciDB  0fdbebe030
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
org.apache.calcite.prepare.MapDPlanner Class Reference
+ Inheritance diagram for org.apache.calcite.prepare.MapDPlanner:
+ Collaboration diagram for org.apache.calcite.prepare.MapDPlanner:

Classes

class  CompletionResult
 

Public Member Functions

 MapDPlanner (FrameworkConfig config)
 
void ready ()
 
CompletionResult getCompletionHints (final String sql, final int cursor, final List< String > visibleTables)
 
RelRoot rel (SqlNode sql) throws RelConversionException
 
void setFilterPushDownInfo (final List< MapDParserOptions.FilterPushDownInfo > filterPushDownInfo)
 

Package Attributes

FrameworkConfig config
 

Private Member Functions

CalciteCatalogReader createCatalogReader ()
 
RelRoot applyFilterPushdown (RelRoot root)
 
RelRoot applyQueryOptimizationRules (RelRoot root)
 

Static Private Member Functions

static SchemaPlus rootSchema (SchemaPlus schema)
 

Private Attributes

List
< MapDParserOptions.FilterPushDownInfo > 
filterPushDownInfo
 

Detailed Description

Customised version of the PlannerImpl for MapD. Used to be a copy of PlannerImpl, refactored now to use inheritance to minimize maintenance efforts. Implementation of org.apache.calcite.tools.Planner.

Definition at line 57 of file MapDPlanner.java.

Constructor & Destructor Documentation

org.apache.calcite.prepare.MapDPlanner.MapDPlanner ( FrameworkConfig  config)
inline

Definition at line 62 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.config.

62  {
63  super(config);
64  this.config = config;
65  }

Member Function Documentation

RelRoot org.apache.calcite.prepare.MapDPlanner.applyFilterPushdown ( RelRoot  root)
inlineprivate

Definition at line 148 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.filterPushDownInfo.

Referenced by org.apache.calcite.prepare.MapDPlanner.rel().

148  {
149  if (filterPushDownInfo.isEmpty()) {
150  return root;
151  }
152  final DynamicFilterJoinRule dynamicFilterJoinRule = new DynamicFilterJoinRule(true,
153  RelFactories.LOGICAL_BUILDER,
154  FilterJoinRule.TRUE_PREDICATE,
156  final HepProgram program =
157  HepProgram.builder().addRuleInstance(dynamicFilterJoinRule).build();
158  HepPlanner prePlanner = new HepPlanner(program);
159  prePlanner.setRoot(root.rel);
160  final RelNode rootRelNode = prePlanner.findBestExp();
161  filterPushDownInfo.clear();
162  return root.withRel(rootRelNode);
163  }
List< MapDParserOptions.FilterPushDownInfo > filterPushDownInfo

+ Here is the caller graph for this function:

RelRoot org.apache.calcite.prepare.MapDPlanner.applyQueryOptimizationRules ( RelRoot  root)
inlineprivate

Definition at line 165 of file MapDPlanner.java.

Referenced by org.apache.calcite.prepare.MapDPlanner.rel().

165  {
166  QueryOptimizationRules outerJoinOptRule =
167  new OuterJoinOptViaNullRejectionRule(RelFactories.LOGICAL_BUILDER);
168 
169  HepProgram opt_program =
170  HepProgram.builder().addRuleInstance(outerJoinOptRule).build();
171  HepPlanner prePlanner = new HepPlanner(
172  opt_program, null, true, Functions.ignore2(), RelOptCostImpl.FACTORY);
173  prePlanner.setRoot(root.rel);
174  final RelNode rootRelNode = prePlanner.findBestExp();
175  return root.withRel(rootRelNode);
176  }

+ Here is the caller graph for this function:

CalciteCatalogReader org.apache.calcite.prepare.MapDPlanner.createCatalogReader ( )
inlineprivate

Definition at line 86 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.config, and org.apache.calcite.prepare.MapDPlanner.rootSchema().

Referenced by org.apache.calcite.prepare.MapDPlanner.getCompletionHints().

86  {
87  final SchemaPlus rootSchema = rootSchema(config.getDefaultSchema());
88  final Context context = config.getContext();
89  final CalciteConnectionConfig connectionConfig;
90 
91  if (context != null) {
92  connectionConfig = context.unwrap(CalciteConnectionConfig.class);
93  } else {
94  Properties properties = new Properties();
95  properties.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(),
96  String.valueOf(config.getParserConfig().caseSensitive()));
97  connectionConfig = new CalciteConnectionConfigImpl(properties);
98  }
99 
100  return new CalciteCatalogReader(CalciteSchema.from(rootSchema),
101  CalciteSchema.from(config.getDefaultSchema()).path(null),
102  getTypeFactory(),
103  connectionConfig);
104  }
static SchemaPlus rootSchema(SchemaPlus schema)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CompletionResult org.apache.calcite.prepare.MapDPlanner.getCompletionHints ( final String  sql,
final int  cursor,
final List< String >  visibleTables 
)
inline

Definition at line 124 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.config, org.apache.calcite.prepare.MapDPlanner.createCatalogReader(), and org.apache.calcite.prepare.MapDPlanner.ready().

125  {
126  ready();
127  MapDSqlAdvisorValidator advisor_validator = new MapDSqlAdvisorValidator(visibleTables,
128  config.getOperatorTable(),
130  getTypeFactory(),
131  SqlConformanceEnum.LENIENT);
132  SqlAdvisor advisor = new MapDSqlAdvisor(advisor_validator);
133  String[] replaced = new String[1];
134  int adjusted_cursor = cursor < 0 ? sql.length() : cursor;
135  java.util.List<SqlMoniker> hints =
136  advisor.getCompletionHints(sql, adjusted_cursor, replaced);
137  return new CompletionResult(hints, replaced[0]);
138  }
CalciteCatalogReader createCatalogReader()

+ Here is the call graph for this function:

void org.apache.calcite.prepare.MapDPlanner.ready ( )
inline

Definition at line 106 of file MapDPlanner.java.

Referenced by org.apache.calcite.prepare.MapDPlanner.getCompletionHints().

106  {
107  // need to call ready on the super class, but that method is marked private
108  // circumventing via reflection for now
109  try {
110  Method readyMethod = getClass().getSuperclass().getDeclaredMethod("ready");
111  readyMethod.setAccessible(true);
112  readyMethod.invoke(this);
113  } catch (InvocationTargetException e) {
114  if (e.getCause() instanceof RuntimeException) {
115  throw(RuntimeException) e.getCause();
116  } else {
117  throw new RuntimeException(e.getCause());
118  }
119  } catch (Exception e) {
120  throw new RuntimeException(e);
121  }
122  }

+ Here is the caller graph for this function:

RelRoot org.apache.calcite.prepare.MapDPlanner.rel ( SqlNode  sql) throws RelConversionException
inline

Definition at line 141 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.applyFilterPushdown(), and org.apache.calcite.prepare.MapDPlanner.applyQueryOptimizationRules().

141  {
142  RelRoot root = super.rel(sql);
143  root = applyQueryOptimizationRules(root);
144  root = applyFilterPushdown(root);
145  return root;
146  }
RelRoot applyQueryOptimizationRules(RelRoot root)
RelRoot applyFilterPushdown(RelRoot root)

+ Here is the call graph for this function:

static SchemaPlus org.apache.calcite.prepare.MapDPlanner.rootSchema ( SchemaPlus  schema)
inlinestaticprivate

Definition at line 67 of file MapDPlanner.java.

Referenced by org.apache.calcite.prepare.MapDPlanner.createCatalogReader().

67  {
68  for (;;) {
69  if (schema.getParentSchema() == null) {
70  return schema;
71  }
72  schema = schema.getParentSchema();
73  }
74  }

+ Here is the caller graph for this function:

void org.apache.calcite.prepare.MapDPlanner.setFilterPushDownInfo ( final List< MapDParserOptions.FilterPushDownInfo >  filterPushDownInfo)
inline

Definition at line 178 of file MapDPlanner.java.

References org.apache.calcite.prepare.MapDPlanner.filterPushDownInfo.

179  {
180  this.filterPushDownInfo = filterPushDownInfo;
181  }
List< MapDParserOptions.FilterPushDownInfo > filterPushDownInfo

Member Data Documentation

List<MapDParserOptions.FilterPushDownInfo> org.apache.calcite.prepare.MapDPlanner.filterPushDownInfo
private

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