Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Predicate.java
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.analysis;
16 
17 import java.util.ArrayList;
18 import java.util.List;
19 
22 import com.cloudera.impala.common.Pair;
23 import com.cloudera.impala.common.Reference;
24 
25 import com.google.common.base.Preconditions;
26 import com.google.common.base.Predicates;
27 import com.google.common.collect.Lists;
28 
29 public abstract class Predicate extends Expr {
30  protected boolean isEqJoinConjunct_;
31 
32  public Predicate() {
33  super();
34  this.isEqJoinConjunct_ = false;
35  }
36 
40  protected Predicate(Predicate other) {
41  super(other);
42  isEqJoinConjunct_ = other.isEqJoinConjunct_;
43  }
44 
45  public boolean isEqJoinConjunct() { return isEqJoinConjunct_; }
46  public void setIsEqJoinConjunct(boolean v) { isEqJoinConjunct_ = v; }
47 
48  @Override
49  public void analyze(Analyzer analyzer) throws AnalysisException {
50  if (isAnalyzed_) return;
51  super.analyze(analyzer);
53  // values: true/false/null
55  }
56 
64  public boolean isSingleColumnPredicate(
65  Reference<SlotRef> slotRefRef, Reference<Integer> idxRef) {
66  // find slotref
67  SlotRef slotRef = null;
68  int i = 0;
69  for (; i < children_.size(); ++i) {
70  slotRef = getChild(i).unwrapSlotRef(false);
71  if (slotRef != null) break;
72  }
73  if (slotRef == null) return false;
74 
75  // make sure everything else is constant
76  for (int j = 0; j < children_.size(); ++j) {
77  if (i == j) continue;
78  if (!getChild(j).isConstant()) return false;
79  }
80 
81  if (slotRefRef != null) slotRefRef.setRef(slotRef);
82  if (idxRef != null) idxRef.setRef(Integer.valueOf(i));
83  return true;
84  }
85 
90  public Pair<SlotId, SlotId> getEqSlots() { return null; }
91 
95  public SlotRef getBoundSlot() { return null; }
96 }
void analyze(Analyzer analyzer)
Definition: Predicate.java:49
static final ScalarType BOOLEAN
Definition: Type.java:46
Pair< SlotId, SlotId > getEqSlots()
Definition: Predicate.java:90
boolean isSingleColumnPredicate(Reference< SlotRef > slotRefRef, Reference< Integer > idxRef)
Definition: Predicate.java:64