Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FunctionArgs.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 
21 import com.google.common.base.Preconditions;
22 import com.google.common.collect.Lists;
23 
24 // Wrapper class around argument types and if it has varArgs
25 public class FunctionArgs implements ParseNode {
26  private final ArrayList<TypeDef> argTypeDefs_;
27  private boolean hasVarArgs_;
28 
29  // Result of analysis.
30  private ArrayList<Type> argTypes_;
31 
32  public FunctionArgs() {
33  argTypeDefs_ = Lists.newArrayList();
34  hasVarArgs_ = false;
35  }
36 
37  public FunctionArgs(ArrayList<TypeDef> argTypeDefs, boolean varArgs) {
38  argTypeDefs_ = argTypeDefs;
39  hasVarArgs_ = varArgs;
40  if (varArgs) Preconditions.checkState(argTypeDefs.size() > 0);
41  }
42 
43  public void setHasVarArgs(boolean b) { {
44  Preconditions.checkState(argTypeDefs_.size() > 0);
45  hasVarArgs_ = b; }
46  }
47 
48  @Override
49  public void analyze(Analyzer analyzer) throws AnalysisException {
50  ArrayList<Type> argTypes = Lists.newArrayListWithCapacity(argTypeDefs_.size());
51  for (TypeDef typeDef: argTypeDefs_) {
52  typeDef.analyze(analyzer);
53  argTypes.add(typeDef.getType());
54  }
55  argTypes_ = argTypes;
56  }
57 
58  public ArrayList<TypeDef> getArgTypeDefs() { return argTypeDefs_; }
59  public ArrayList<Type> getArgTypes() { return argTypes_; }
60  public boolean hasVarArgs() { return hasVarArgs_; }
61 
62  @Override
63  public String toSql() { return null; }
64 }
FunctionArgs(ArrayList< TypeDef > argTypeDefs, boolean varArgs)
final ArrayList< TypeDef > argTypeDefs_