Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PlannerContext.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.planner;
16 
20 import com.cloudera.impala.common.IdGenerator;
21 import com.cloudera.impala.thrift.TQueryCtx;
22 import com.cloudera.impala.thrift.TQueryOptions;
23 
28 public class PlannerContext {
29  // Estimate of the overhead imposed by storing data in a hash tbl;
30  // used for determining whether a broadcast join is feasible.
31  public final static double HASH_TBL_SPACE_OVERHEAD = 1.1;
32 
33  // The maximum fraction of remaining memory that a sort node can use during execution.
34  public final static double SORT_MEM_MAX_FRACTION = 0.80;
35 
36  private final IdGenerator<PlanNodeId> nodeIdGenerator_ = PlanNodeId.createGenerator();
37  private final IdGenerator<PlanFragmentId> fragmentIdGenerator_ =
38  PlanFragmentId.createGenerator();
39 
40  private final TQueryCtx queryCtx_;
41  private final AnalysisContext.AnalysisResult analysisResult_;
42  private final QueryStmt queryStmt_;
43 
44  public PlannerContext (AnalysisContext.AnalysisResult analysisResult,
45  TQueryCtx queryCtx) {
46  analysisResult_ = analysisResult;
47  queryCtx_ = queryCtx;
48  if (isInsertOrCtas()) {
49  queryStmt_ = analysisResult.getInsertStmt().getQueryStmt();
50  } else {
51  queryStmt_ = analysisResult.getQueryStmt();
52  }
53  }
54 
55  public QueryStmt getQueryStmt() { return queryStmt_; }
56  public TQueryCtx getQueryCtx() { return queryCtx_; }
57  public TQueryOptions getQueryOptions() {
58  return queryCtx_.getRequest().getQuery_options();
59  }
60  public AnalysisContext.AnalysisResult getAnalysisResult() { return analysisResult_; }
61  public Analyzer getRootAnalyzer() { return analysisResult_.getAnalyzer(); }
62  public boolean isSingleNodeExec() { return getQueryOptions().num_nodes == 1; }
63  public PlanNodeId getNextNodeId() { return nodeIdGenerator_.getNextId(); }
64  public PlanFragmentId getNextFragmentId() { return fragmentIdGenerator_.getNextId(); }
65  public boolean isInsertOrCtas() {
66  return analysisResult_.isInsertStmt() || analysisResult_.isCreateTableAsSelectStmt();
67  }
68 }
final AnalysisContext.AnalysisResult analysisResult_
final IdGenerator< PlanFragmentId > fragmentIdGenerator_
PlannerContext(AnalysisContext.AnalysisResult analysisResult, TQueryCtx queryCtx)
AnalysisContext.AnalysisResult getAnalysisResult()
final IdGenerator< PlanNodeId > nodeIdGenerator_