Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SelectList.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.List;
18 
19 import com.google.common.collect.Lists;
20 
24 public class SelectList {
25  private List<String> planHints_;
26  private final List<SelectListItem> items_;
27  private boolean isDistinct_;
28 
29  // Set in analyzePlanHints() based on planHints_.
30  private boolean isStraightJoin_;
31 
32  public SelectList(List<SelectListItem> items) {
33  items_ = items;
34  isDistinct_ = false;
35  isStraightJoin_ = false;
36  }
37 
38  public SelectList() {
39  items_ = Lists.newArrayList();
40  isDistinct_ = false;
41  isStraightJoin_ = false;
42  }
43 
44  public SelectList(List<SelectListItem> items, boolean isDistinct,
45  List<String> planHints) {
47  isStraightJoin_ = false;
48  items_ = items;
49  planHints_ = planHints;
50  }
51 
55  public SelectList(SelectList other) {
56  planHints_ =
57  (other.planHints_ != null) ? Lists.newArrayList(other.planHints_) : null;
58  items_ = Lists.newArrayList();
59  for (SelectListItem item: other.items_) {
60  items_.add(item.clone());
61  }
62  isDistinct_ = other.isDistinct_;
63  isStraightJoin_ = other.isStraightJoin_;
64  }
65 
66  public List<SelectListItem> getItems() { return items_; }
67  public void setPlanHints(List<String> planHints) { planHints_ = planHints; }
68  public List<String> getPlanHints() { return planHints_; }
69  public boolean isDistinct() { return isDistinct_; }
70  public void setIsDistinct(boolean value) { isDistinct_ = value; }
71  public boolean isStraightJoin() { return isStraightJoin_; }
72  public boolean hasPlanHints() { return planHints_ != null; }
73 
74  public void analyzePlanHints(Analyzer analyzer) {
75  if (planHints_ == null) return;
76  for (String hint: planHints_) {
77  if (!hint.equalsIgnoreCase("straight_join")) {
78  analyzer.addWarning("PLAN hint not recognized: " + hint);
79  }
80  isStraightJoin_ = true;
81  analyzer.setHasPlanHints();
82  }
83  }
84 
85  @Override
86  public SelectList clone() { return new SelectList(this); }
87 }
void setPlanHints(List< String > planHints)
Definition: SelectList.java:67
void analyzePlanHints(Analyzer analyzer)
Definition: SelectList.java:74
final List< SelectListItem > items_
Definition: SelectList.java:26
SelectList(List< SelectListItem > items, boolean isDistinct, List< String > planHints)
Definition: SelectList.java:44
SelectList(List< SelectListItem > items)
Definition: SelectList.java:32
List< SelectListItem > getItems()
Definition: SelectList.java:66