OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
org.apache.calcite.rel.rules.InjectFilterRule Class Reference
+ Inheritance diagram for org.apache.calcite.rel.rules.InjectFilterRule:
+ Collaboration diagram for org.apache.calcite.rel.rules.InjectFilterRule:

Classes

interface  Config
 

Public Member Functions

 InjectFilterRule (Config config, Restriction restriction)
 
void onMatch (RelOptRuleCall call)
 

Static Public Attributes

static Set< String > visitedMemo = new HashSet<>()
 

Package Functions

void clearMemo ()
 

Package Attributes

final Restriction restriction
 

Static Package Attributes

static final Logger MAPDLOGGER = LoggerFactory.getLogger(InjectFilterRule.class)
 

Detailed Description

Definition at line 38 of file InjectFilterRule.java.

Constructor & Destructor Documentation

org.apache.calcite.rel.rules.InjectFilterRule.InjectFilterRule ( Config  config,
Restriction  restriction 
)
inline

Definition at line 45 of file InjectFilterRule.java.

References org.apache.calcite.rel.rules.InjectFilterRule.clearMemo(), and org.apache.calcite.rel.rules.InjectFilterRule.restriction.

Referenced by org.apache.calcite.rel.rules.InjectFilterRule.Config.toRule().

45  {
46  super(config);
47  this.restriction = restriction;
48  clearMemo();
49  }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Function Documentation

void org.apache.calcite.rel.rules.InjectFilterRule.clearMemo ( )
inlinepackage

Definition at line 51 of file InjectFilterRule.java.

Referenced by org.apache.calcite.rel.rules.InjectFilterRule.InjectFilterRule().

51  {
52  visitedMemo.clear();
53  }

+ Here is the caller graph for this function:

void org.apache.calcite.rel.rules.InjectFilterRule.onMatch ( RelOptRuleCall  call)
inline

Definition at line 56 of file InjectFilterRule.java.

References field(), org.apache.calcite.rel.rules.Restriction.getRestrictionColumn(), org.apache.calcite.rel.rules.Restriction.getRestrictionValues(), OR, org.apache.calcite.rel.rules.InjectFilterRule.restriction, and org.apache.calcite.rel.rules.InjectFilterRule.visitedMemo.

56  {
57  LogicalTableScan parentNode = call.rel(0);
58  if (visitedMemo.contains(parentNode.toString())) {
59  return;
60  } else {
61  visitedMemo.add(parentNode.toString());
62  }
63  RelOptTable table = parentNode.getTable();
64 
65  RelDataTypeField field =
66  table.getRowType().getField(restriction.getRestrictionColumn(), false, false);
67  if (field != null) {
68  MAPDLOGGER.debug(
69  " Scan is " + parentNode.toString() + " TABLE is " + table.toString());
70  MAPDLOGGER.debug("Column " + restriction.getRestrictionColumn()
71  + " exists in table " + table.getQualifiedName());
72  RelBuilder builder = call.builder();
73  RexBuilder rBuilder = builder.getRexBuilder();
74  builder = builder.push(parentNode);
75 
76  ArrayList<RexNode> orList = new ArrayList<RexNode>();
77  for (String val : restriction.getRestrictionValues()) {
78  MAPDLOGGER.debug(" Column is " + restriction.getRestrictionColumn()
79  + " literal is '" + val + "'");
80  RexNode lit;
81  if (SqlTypeName.NUMERIC_TYPES.indexOf(field.getType().getSqlTypeName()) == -1) {
82  lit = rBuilder.makeLiteral(val, field.getType(), false);
83  } else {
84  lit = rBuilder.makeLiteral(Integer.parseInt(val), field.getType(), false);
85  }
86  RexNode rn = builder.call(SqlStdOperatorTable.EQUALS,
87  builder.field(restriction.getRestrictionColumn()),
88  lit);
89  orList.add(rn);
90  }
91 
92  RexNode relOr = builder.call(SqlStdOperatorTable.OR, orList);
93 
94  final RelNode newNode = builder.filter(relOr).build();
95  call.transformTo(newNode);
96  }
97  };
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
#define OR

+ Here is the call graph for this function:

Member Data Documentation

final Logger org.apache.calcite.rel.rules.InjectFilterRule.MAPDLOGGER = LoggerFactory.getLogger(InjectFilterRule.class)
staticpackage

Definition at line 42 of file InjectFilterRule.java.

final Restriction org.apache.calcite.rel.rules.InjectFilterRule.restriction
package
Set<String> org.apache.calcite.rel.rules.InjectFilterRule.visitedMemo = new HashSet<>()
static

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