Review Board 1.7.22


HIVE-4597: Move Vector Expression and Vector Expression Evaluation Test Generation

Review Request #11349 - Created May 23, 2013 and updated

tony murphy
vectorization
HIVE-4597
Reviewers
hive
hanson5b, jitendra, rusanu, sarvesh.sn
hive-git
Move Vector Expression and Vector Expression Evaluation Test Generation to \ql\src\gen\vectorization and update CodeGen to place generated files correctly into source tree. See lines 218 to 249 for changes.
validated generated code goes to correct locations with default execution:
\ql\src\gen\vectorization> javac .\org\apache\hadoop\hive\ql\exec\vector\expressions\gen\*.java
\ql\src\gen\vectorization> java org.apache.hadoop.hive.ql.exec.vector.expressions.gen.CodeGen

Diff revision 1 (Latest)

  1. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/CodeGen.java: Loading...
  2. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnArithmeticColumn.txt: Loading...
  3. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnArithmeticScalar.txt: Loading...
  4. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnCompareScalar.txt: Loading...
  5. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnUnaryMinus.txt: Loading...
  6. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterColumnCompareColumn.txt: Loading...
  7. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterColumnCompareScalar.txt: Loading...
  8. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterStringColumnCompareColumn.txt: Loading...
  9. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterStringColumnCompareScalar.txt: Loading...
  10. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ScalarArithmeticColumn.txt: Loading...
  11. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestClass.txt: Loading...
  12. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestCodeGen.java: Loading...
  13. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnColumnFilterVectorExpressionEvaluation.txt: Loading...
  14. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnColumnOperationVectorExpressionEvaluation.txt: Loading...
  15. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnScalarFilterVectorExpressionEvaluation.txt: Loading...
  16. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnScalarOperationVectorExpressionEvaluation.txt: Loading...
  17. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFAvg.txt: Loading...
  18. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFCount.txt: Loading...
  19. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFMinMax.txt: Loading...
  20. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFSum.txt: Loading...
This diff has been split across 2 pages: 1 2 >
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/CodeGen.java
New File

    
   
1
package org.apache.hadoop.hive.ql.exec.vector.expressions.gen;

    
   
2

   

    
   
3
import java.io.BufferedReader;

    
   
4
import java.io.BufferedWriter;

    
   
5
import java.io.File;

    
   
6
import java.io.FileReader;

    
   
7
import java.io.FileWriter;

    
   
8
import java.io.IOException;

    
   
9

   

    
   
10
public class CodeGen {

    
   
11

   

    
   
12
  static String [][] templateExpansions =

    
   
13
    {

    
   
14
      {"ColumnArithmeticScalar", "Add", "long", "long", "+"},

    
   
15
      {"ColumnArithmeticScalar", "Subtract", "long", "long", "-"},

    
   
16
      {"ColumnArithmeticScalar", "Multiply", "long", "long", "*"},

    
   
17
      {"ColumnArithmeticScalar", "Modulo", "long", "long", "%"},

    
   
18

   

    
   
19
      {"ColumnArithmeticScalar", "Add", "long", "double", "+"},

    
   
20
      {"ColumnArithmeticScalar", "Subtract", "long", "double", "-"},

    
   
21
      {"ColumnArithmeticScalar", "Multiply", "long", "double", "*"},

    
   
22
      {"ColumnArithmeticScalar", "Divide", "long", "double", "/"},

    
   
23
      {"ColumnArithmeticScalar", "Modulo", "long", "double", "%"},

    
   
24

   

    
   
25
      {"ColumnArithmeticScalar", "Add", "double", "long", "+"},

    
   
26
      {"ColumnArithmeticScalar", "Subtract", "double", "long", "-"},

    
   
27
      {"ColumnArithmeticScalar", "Multiply", "double", "long", "*"},

    
   
28
      {"ColumnArithmeticScalar", "Divide", "double", "long", "/"},

    
   
29
      {"ColumnArithmeticScalar", "Modulo", "double", "long", "%"},

    
   
30

   

    
   
31
      {"ColumnArithmeticScalar", "Add", "double", "double", "+"},

    
   
32
      {"ColumnArithmeticScalar", "Subtract", "double", "double", "-"},

    
   
33
      {"ColumnArithmeticScalar", "Multiply", "double", "double", "*"},

    
   
34
      {"ColumnArithmeticScalar", "Divide", "double", "double", "/"},

    
   
35
      {"ColumnArithmeticScalar", "Modulo", "double", "double", "%"},

    
   
36

   

    
   
37
      {"ScalarArithmeticColumn", "Add", "long", "long", "+"},

    
   
38
      {"ScalarArithmeticColumn", "Subtract", "long", "long", "-"},

    
   
39
      {"ScalarArithmeticColumn", "Multiply", "long", "long", "*"},

    
   
40
      {"ScalarArithmeticColumn", "Modulo", "long", "long", "%"},

    
   
41

   

    
   
42
      {"ScalarArithmeticColumn", "Add", "long", "double", "+"},

    
   
43
      {"ScalarArithmeticColumn", "Subtract", "long", "double", "-"},

    
   
44
      {"ScalarArithmeticColumn", "Multiply", "long", "double", "*"},

    
   
45
      {"ScalarArithmeticColumn", "Divide", "long", "double", "/"},

    
   
46
      {"ScalarArithmeticColumn", "Modulo", "long", "double", "%"},

    
   
47

   

    
   
48
      {"ScalarArithmeticColumn", "Add", "double", "long", "+"},

    
   
49
      {"ScalarArithmeticColumn", "Subtract", "double", "long", "-"},

    
   
50
      {"ScalarArithmeticColumn", "Multiply", "double", "long", "*"},

    
   
51
      {"ScalarArithmeticColumn", "Divide", "double", "long", "/"},

    
   
52
      {"ScalarArithmeticColumn", "Modulo", "double", "long", "%"},

    
   
53

   

    
   
54
      {"ScalarArithmeticColumn", "Add", "double", "double", "+"},

    
   
55
      {"ScalarArithmeticColumn", "Subtract", "double", "double", "-"},

    
   
56
      {"ScalarArithmeticColumn", "Multiply", "double", "double", "*"},

    
   
57
      {"ScalarArithmeticColumn", "Divide", "double", "double", "/"},

    
   
58
      {"ScalarArithmeticColumn", "Modulo", "double", "double", "%"},

    
   
59

   

    
   
60
      {"ColumnArithmeticColumn", "Add", "long", "long", "+"},

    
   
61
      {"ColumnArithmeticColumn", "Subtract", "long", "long", "-"},

    
   
62
      {"ColumnArithmeticColumn", "Multiply", "long", "long", "*"},

    
   
63
      {"ColumnArithmeticColumn", "Modulo", "long", "long", "%"},

    
   
64

   

    
   
65
      {"ColumnArithmeticColumn", "Add", "long", "double", "+"},

    
   
66
      {"ColumnArithmeticColumn", "Subtract", "long", "double", "-"},

    
   
67
      {"ColumnArithmeticColumn", "Multiply", "long", "double", "*"},

    
   
68
      {"ColumnArithmeticColumn", "Divide", "long", "double", "/"},

    
   
69
      {"ColumnArithmeticColumn", "Modulo", "long", "double", "%"},

    
   
70

   

    
   
71
      {"ColumnArithmeticColumn", "Add", "double", "long", "+"},

    
   
72
      {"ColumnArithmeticColumn", "Subtract", "double", "long", "-"},

    
   
73
      {"ColumnArithmeticColumn", "Multiply", "double", "long", "*"},

    
   
74
      {"ColumnArithmeticColumn", "Divide", "double", "long", "/"},

    
   
75
      {"ColumnArithmeticColumn", "Modulo", "double", "long", "%"},

    
   
76

   

    
   
77
      {"ColumnArithmeticColumn", "Add", "double", "double", "+"},

    
   
78
      {"ColumnArithmeticColumn", "Subtract", "double", "double", "-"},

    
   
79
      {"ColumnArithmeticColumn", "Multiply", "double", "double", "*"},

    
   
80
      {"ColumnArithmeticColumn", "Divide", "double", "double", "/"},

    
   
81
      {"ColumnArithmeticColumn", "Modulo", "double", "double", "%"},

    
   
82

   

    
   
83
      {"ColumnCompareScalar", "Equal", "long", "double", "=="},

    
   
84
      {"ColumnCompareScalar", "Equal", "double", "double", "=="},

    
   
85
      {"ColumnCompareScalar", "NotEqual", "long", "double", "!="},

    
   
86
      {"ColumnCompareScalar", "NotEqual", "double", "double", "!="},

    
   
87
      {"ColumnCompareScalar", "Less", "long", "double", "<"},

    
   
88
      {"ColumnCompareScalar", "Less", "double", "double", "<"},

    
   
89
      {"ColumnCompareScalar", "LessEqual", "long", "double", "<="},

    
   
90
      {"ColumnCompareScalar", "LessEqual", "double", "double", "<="},

    
   
91
      {"ColumnCompareScalar", "Greater", "long", "double", ">"},

    
   
92
      {"ColumnCompareScalar", "Greater", "double", "double", ">"},

    
   
93
      {"ColumnCompareScalar", "GreaterEqual", "long", "double", ">="},

    
   
94
      {"ColumnCompareScalar", "GreaterEqual", "double", "double", ">="},

    
   
95

   

    
   
96
      {"FilterColumnCompareScalar", "Equal", "long", "double", "=="},

    
   
97
      {"FilterColumnCompareScalar", "Equal", "double", "double", "=="},

    
   
98
      {"FilterColumnCompareScalar", "NotEqual", "long", "double", "!="},

    
   
99
      {"FilterColumnCompareScalar", "NotEqual", "double", "double", "!="},

    
   
100
      {"FilterColumnCompareScalar", "Less", "long", "double", "<"},

    
   
101
      {"FilterColumnCompareScalar", "Less", "double", "double", "<"},

    
   
102
      {"FilterColumnCompareScalar", "LessEqual", "long", "double", "<="},

    
   
103
      {"FilterColumnCompareScalar", "LessEqual", "double", "double", "<="},

    
   
104
      {"FilterColumnCompareScalar", "Greater", "long", "double", ">"},

    
   
105
      {"FilterColumnCompareScalar", "Greater", "double", "double", ">"},

    
   
106
      {"FilterColumnCompareScalar", "GreaterEqual", "long", "double", ">="},

    
   
107
      {"FilterColumnCompareScalar", "GreaterEqual", "double", "double", ">="},

    
   
108

   

    
   
109
      {"FilterColumnCompareScalar", "Equal", "long", "long", "=="},

    
   
110
      {"FilterColumnCompareScalar", "Equal", "double", "long", "=="},

    
   
111
      {"FilterColumnCompareScalar", "NotEqual", "long", "long", "!="},

    
   
112
      {"FilterColumnCompareScalar", "NotEqual", "double", "long", "!="},

    
   
113
      {"FilterColumnCompareScalar", "Less", "long", "long", "<"},

    
   
114
      {"FilterColumnCompareScalar", "Less", "double", "long", "<"},

    
   
115
      {"FilterColumnCompareScalar", "LessEqual", "long", "long", "<="},

    
   
116
      {"FilterColumnCompareScalar", "LessEqual", "double", "long", "<="},

    
   
117
      {"FilterColumnCompareScalar", "Greater", "long", "long", ">"},

    
   
118
      {"FilterColumnCompareScalar", "Greater", "double", "long", ">"},

    
   
119
      {"FilterColumnCompareScalar", "GreaterEqual", "long", "long", ">="},

    
   
120
      {"FilterColumnCompareScalar", "GreaterEqual", "double", "long", ">="},

    
   
121

   

    
   
122
      {"FilterScalarCompareColumn", "Equal", "long", "double", "=="},

    
   
123
      {"FilterScalarCompareColumn", "Equal", "double", "double", "=="},

    
   
124
      {"FilterScalarCompareColumn", "NotEqual", "long", "double", "!="},

    
   
125
      {"FilterScalarCompareColumn", "NotEqual", "double", "double", "!="},

    
   
126
      {"FilterScalarCompareColumn", "Less", "long", "double", "<"},

    
   
127
      {"FilterScalarCompareColumn", "Less", "double", "double", "<"},

    
   
128
      {"FilterScalarCompareColumn", "LessEqual", "long", "double", "<="},

    
   
129
      {"FilterScalarCompareColumn", "LessEqual", "double", "double", "<="},

    
   
130
      {"FilterScalarCompareColumn", "Greater", "long", "double", ">"},

    
   
131
      {"FilterScalarCompareColumn", "Greater", "double", "double", ">"},

    
   
132
      {"FilterScalarCompareColumn", "GreaterEqual", "long", "double", ">="},

    
   
133
      {"FilterScalarCompareColumn", "GreaterEqual", "double", "double", ">="},

    
   
134

   

    
   
135
      {"FilterScalarCompareColumn", "Equal", "long", "long", "=="},

    
   
136
      {"FilterScalarCompareColumn", "Equal", "double", "long", "=="},

    
   
137
      {"FilterScalarCompareColumn", "NotEqual", "long", "long", "!="},

    
   
138
      {"FilterScalarCompareColumn", "NotEqual", "double", "long", "!="},

    
   
139
      {"FilterScalarCompareColumn", "Less", "long", "long", "<"},

    
   
140
      {"FilterScalarCompareColumn", "Less", "double", "long", "<"},

    
   
141
      {"FilterScalarCompareColumn", "LessEqual", "long", "long", "<="},

    
   
142
      {"FilterScalarCompareColumn", "LessEqual", "double", "long", "<="},

    
   
143
      {"FilterScalarCompareColumn", "Greater", "long", "long", ">"},

    
   
144
      {"FilterScalarCompareColumn", "Greater", "double", "long", ">"},

    
   
145
      {"FilterScalarCompareColumn", "GreaterEqual", "long", "long", ">="},

    
   
146
      {"FilterScalarCompareColumn", "GreaterEqual", "double", "long", ">="},

    
   
147

   

    
   
148
      {"FilterStringColumnCompareScalar", "Equal", "=="},

    
   
149
      {"FilterStringColumnCompareScalar", "NotEqual", "!="},

    
   
150
      {"FilterStringColumnCompareScalar", "Less", "<"},

    
   
151
      {"FilterStringColumnCompareScalar", "LessEqual", "<="},

    
   
152
      {"FilterStringColumnCompareScalar", "Greater", ">"},

    
   
153
      {"FilterStringColumnCompareScalar", "GreaterEqual", ">="},

    
   
154

   

    
   
155
      {"FilterStringColumnCompareColumn", "Equal", "=="},

    
   
156
      {"FilterStringColumnCompareColumn", "NotEqual", "!="},

    
   
157
      {"FilterStringColumnCompareColumn", "Less", "<"},

    
   
158
      {"FilterStringColumnCompareColumn", "LessEqual", "<="},

    
   
159
      {"FilterStringColumnCompareColumn", "Greater", ">"},

    
   
160
      {"FilterStringColumnCompareColumn", "GreaterEqual", ">="},

    
   
161

   

    
   
162
      {"FilterColumnCompareColumn", "Equal", "long", "double", "=="},

    
   
163
      {"FilterColumnCompareColumn", "Equal", "double", "double", "=="},

    
   
164
      {"FilterColumnCompareColumn", "NotEqual", "long", "double", "!="},

    
   
165
      {"FilterColumnCompareColumn", "NotEqual", "double", "double", "!="},

    
   
166
      {"FilterColumnCompareColumn", "Less", "long", "double", "<"},

    
   
167
      {"FilterColumnCompareColumn", "Less", "double", "double", "<"},

    
   
168
      {"FilterColumnCompareColumn", "LessEqual", "long", "double", "<="},

    
   
169
      {"FilterColumnCompareColumn", "LessEqual", "double", "double", "<="},

    
   
170
      {"FilterColumnCompareColumn", "Greater", "long", "double", ">"},

    
   
171
      {"FilterColumnCompareColumn", "Greater", "double", "double", ">"},

    
   
172
      {"FilterColumnCompareColumn", "GreaterEqual", "long", "double", ">="},

    
   
173
      {"FilterColumnCompareColumn", "GreaterEqual", "double", "double", ">="},

    
   
174

   

    
   
175
        {"FilterColumnCompareColumn", "Equal", "long", "long", "=="},

    
   
176
        {"FilterColumnCompareColumn", "Equal", "double", "long", "=="},

    
   
177
        {"FilterColumnCompareColumn", "NotEqual", "long", "long", "!="},

    
   
178
        {"FilterColumnCompareColumn", "NotEqual", "double", "long", "!="},

    
   
179
        {"FilterColumnCompareColumn", "Less", "long", "long", "<"},

    
   
180
        {"FilterColumnCompareColumn", "Less", "double", "long", "<"},

    
   
181
        {"FilterColumnCompareColumn", "LessEqual", "long", "long", "<="},

    
   
182
        {"FilterColumnCompareColumn", "LessEqual", "double", "long", "<="},

    
   
183
        {"FilterColumnCompareColumn", "Greater", "long", "long", ">"},

    
   
184
        {"FilterColumnCompareColumn", "Greater", "double", "long", ">"},

    
   
185
        {"FilterColumnCompareColumn", "GreaterEqual", "long", "long", ">="},

    
   
186
        {"FilterColumnCompareColumn", "GreaterEqual", "double", "long", ">="},

    
   
187

   

    
   
188
        {"ColumnUnaryMinus", "long"},

    
   
189
        {"ColumnUnaryMinus", "double"},

    
   
190

   

    
   
191
        //template, <ClassName>, <ValueType>, <OperatorSymbol>, <DescriptionName>, <DescriptionValue>

    
   
192
        {"VectorUDAFMinMax", "VectorUDAFMinLong", "long", "<", "min", "_FUNC_(expr) - Returns the minimum value of expr (vectorized, type: long)"},

    
   
193
        {"VectorUDAFMinMax", "VectorUDAFMinDouble", "double", "<", "min", "_FUNC_(expr) - Returns the minimum value of expr (vectorized, type: double)"},

    
   
194
        {"VectorUDAFMinMax", "VectorUDAFMaxLong", "long", ">", "max", "_FUNC_(expr) - Returns the maximum value of expr (vectorized, type: long)"},

    
   
195
        {"VectorUDAFMinMax", "VectorUDAFMaxDouble", "double", ">", "max", "_FUNC_(expr) - Returns the maximum value of expr (vectorized, type: double)"},

    
   
196

   

    
   
197
        //template, <ClassName>, <ValueType>

    
   
198
        {"VectorUDAFCount", "VectorUDAFCountLong", "long"},

    
   
199
        {"VectorUDAFCount", "VectorUDAFCountDouble", "double"},

    
   
200

   

    
   
201
        //template, <ClassName>, <ValueType>

    
   
202
        {"VectorUDAFSum", "VectorUDAFSumLong", "long"},

    
   
203
        {"VectorUDAFSum", "VectorUDAFSumDouble", "double"},

    
   
204
        {"VectorUDAFAvg", "VectorUDAFAvgLong", "long"},

    
   
205
        {"VectorUDAFAvg", "VectorUDAFAvgDouble", "double"},

    
   
206

   

    
   
207
      //template, <ClassName>, <ValueType>, <VarianceFormula>, <DescriptionName>, <DescriptionValue>

    
   
208
        {"VectorUDAFVar", "VectorUDAFVarPopLong", "long", "myagg.variance / myagg.count", "variance, var_pop", "_FUNC_(x) - Returns the variance of a set of numbers (vectorized, long)"},

    
   
209
        {"VectorUDAFVar", "VectorUDAFVarPopDouble", "double", "myagg.variance / myagg.count", "variance, var_pop", "_FUNC_(x) - Returns the variance of a set of numbers (vectorized, double)"},

    
   
210
        {"VectorUDAFVar", "VectorUDAFVarSampLong", "long", "myagg.variance / (myagg.count-1.0)", "var_samp", "_FUNC_(x) - Returns the sample variance of a set of numbers (vectorized, long)"},

    
   
211
        {"VectorUDAFVar", "VectorUDAFVarSampDouble", "double", "myagg.variance / (myagg.count-1.0)", "var_samp", "_FUNC_(x) - Returns the sample variance of a set of numbers (vectorized, double)"},

    
   
212
        {"VectorUDAFVar", "VectorUDAFStdPopLong", "long", "Math.sqrt(myagg.variance / (myagg.count))", "std,stddev,stddev_pop", "_FUNC_(x) - Returns the standard deviation of a set of numbers (vectorized, long)"},

    
   
213
        {"VectorUDAFVar", "VectorUDAFStdPopDouble", "double", "Math.sqrt(myagg.variance / (myagg.count))", "std,stddev,stddev_pop", "_FUNC_(x) - Returns the standard deviation of a set of numbers (vectorized, double)"},

    
   
214
        {"VectorUDAFVar", "VectorUDAFStdSampLong", "long", "Math.sqrt(myagg.variance / (myagg.count-1.0))", "stddev_samp", "_FUNC_(x) - Returns the sample standard deviation of a set of numbers (vectorized, long)"},

    
   
215
        {"VectorUDAFVar", "VectorUDAFStdSampDouble", "double", "Math.sqrt(myagg.variance / (myagg.count-1.0))", "stddev_samp", "_FUNC_(x) - Returns the sample standard deviation of a set of numbers (vectorized, double)"},

    
   
216

   

    
   
217
    };

    
   
218
  private static String[] relativePackagePathParts = new String[]{"org", "apache", "hadoop", "hive", "ql", "exec", "vector", "expressions", "gen"};

    
   
219
  private static String[] relativeSrcPathParts = new String[]{"..", "..", "java"};

    
   
220
  private static String[] relativeTestPathParts = new String[]{"..", "..", "test"};

    
   
221

   

    
   
222
  private final String templateDirectory;

    
   
223
  private final String outputDirectory;

    
   
224
  private final TestCodeGen testCodeGen;

    
   
225

   

    
   
226
  static String joinPath(String...parts) {

    
   
227
    String path = parts[0];

    
   
228
    for (int i=1; i < parts.length; ++i) {

    
   
229
      path += File.separatorChar + parts[i];

    
   
230
    }

    
   
231
    return path;

    
   
232
  }

    
   
233

   

    
   
234
  public CodeGen() {

    
   
235

   

    
   
236
    String relativePackagePath = joinPath(relativePackagePathParts);

    
   
237
    templateDirectory = joinPath(System.getProperty("user.dir"), relativePackagePath);

    
   
238

   

    
   
239
    String relativeSrcPath = joinPath(relativeSrcPathParts);

    
   
240
    outputDirectory = joinPath(System.getProperty("user.dir"), relativeSrcPath, relativePackagePath);

    
   
241

   

    
   
242
    String relativeTestPath = joinPath(relativeTestPathParts);

    
   
243
    String testOutputDirectory = joinPath(System.getProperty("user.dir"), relativeTestPath, relativePackagePath);

    
   
244
    testCodeGen = new TestCodeGen(testOutputDirectory, templateDirectory);

    
   
245

   

    
   
246
    System.out.println("Template Directory: " + templateDirectory);

    
   
247
    System.out.println("Output Directory: " + outputDirectory);

    
   
248
    System.out.println("Test Output Directory: " + testOutputDirectory);

    
   
249
  }

    
   
250

   

    
   
251
  public CodeGen(String templateDirectory, String outputDirectory, String testOutputDirectory) {

    
   
252
    this.templateDirectory = templateDirectory;

    
   
253
    this.outputDirectory = outputDirectory;

    
   
254
    testCodeGen =  new TestCodeGen(testOutputDirectory, templateDirectory);

    
   
255
  }

    
   
256

   

    
   
257
  /**

    
   
258
   * @param args

    
   
259
   * @throws Exception

    
   
260
   */

    
   
261
  public static void main(String[] args) throws Exception {

    
   
262
    CodeGen gen;

    
   
263
    if (args == null || args.length==0) {

    
   
264
      gen = new CodeGen();

    
   
265
    } else if (args.length==3) {

    
   
266
      gen = new CodeGen(args[0], args[1], args[2]);

    
   
267
    }else{

    
   
268
      System.out.println("args: <templateDir> <outputDir> <testOutputDir>");

    
   
269
      return;

    
   
270
    }

    
   
271

   

    
   
272
    gen.generate();

    
   
273
  }

    
   
274

   

    
   
275
  private void generate() throws Exception {

    
   
276

   

    
   
277
    for (String [] tdesc : templateExpansions) {

    
   
278
      if (tdesc[0].equals("ColumnArithmeticScalar")) {

    
   
279
        generateColumnArithmeticScalar(tdesc);

    
   
280
      } else if (tdesc[0].equals("ColumnCompareScalar")) {

    
   
281
        generateColumnCompareScalar(tdesc);

    
   
282
      } else if (tdesc[0].equals("FilterColumnCompareScalar")) {

    
   
283
        generateFilterColumnCompareScalar(tdesc);

    
   
284
      } else if (tdesc[0].equals("ScalarArithmeticColumn")) {

    
   
285
        generateScalarArithmeticColumn(tdesc);

    
   
286
      } else if (tdesc[0].equals("FilterColumnCompareColumn")) {

    
   
287
        generateFilterColumnCompareColumn(tdesc);

    
   
288
      } else if (tdesc[0].equals("ColumnArithmeticColumn")) {

    
   
289
        generateColumnArithmeticColumn(tdesc);

    
   
290
      } else if (tdesc[0].equals("ColumnUnaryMinus")) {

    
   
291
        generateColumnUnaryMinus(tdesc);

    
   
292
      } else if (tdesc[0].equals("VectorUDAFCount")) {

    
   
293
        generateVectorUDAFCount(tdesc);

    
   
294
      } else if (tdesc[0].equals("VectorUDAFMinMax")) {

    
   
295
        generateVectorUDAFMinMax(tdesc);

    
   
296
      } else if (tdesc[0].equals("VectorUDAFSum")) {

    
   
297
        generateVectorUDAFSum(tdesc);

    
   
298
      } else if (tdesc[0].equals("VectorUDAFAvg")) {

    
   
299
        generateVectorUDAFAvg(tdesc);

    
   
300
      } else if (tdesc[0].equals("VectorUDAFVar")) {

    
   
301
        generateVectorUDAFVar(tdesc);

    
   
302
      } else if (tdesc[0].equals("FilterStringColumnCompareScalar")) {

    
   
303
        generateFilterStringColumnCompareScalar(tdesc);

    
   
304
      } else if (tdesc[0].equals("FilterStringColumnCompareColumn")) {

    
   
305
        generateFilterStringColumnCompareColumn(tdesc);

    
   
306
      } else {

    
   
307
        continue;

    
   
308
      }

    
   
309
    }

    
   
310
    testCodeGen.generateTestSuites();

    
   
311
  }

    
   
312

   

    
   
313
  private void generateVectorUDAFMinMax(String[] tdesc) throws Exception {

    
   
314
    String className = tdesc[1];

    
   
315
    String valueType = tdesc[2];

    
   
316
    String operatorSymbol = tdesc[3];

    
   
317
    String descName = tdesc[4];

    
   
318
    String descValue = tdesc[5];

    
   
319
    String columnType = getColumnVectorType(valueType);

    
   
320
    String writableType = getOutputWritableType(valueType);

    
   
321
    String inspectorType = getOutputObjectInspector(valueType);

    
   
322

   

    
   
323
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
324
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
325

   

    
   
326
    String templateString = readFile(templateFile);

    
   
327
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
328
    templateString = templateString.replaceAll("<ValueType>", valueType);

    
   
329
    templateString = templateString.replaceAll("<OperatorSymbol>", operatorSymbol);

    
   
330
    templateString = templateString.replaceAll("<InputColumnVectorType>", columnType);

    
   
331
    templateString = templateString.replaceAll("<DescriptionName>", descName);

    
   
332
    templateString = templateString.replaceAll("<DescriptionValue>", descValue);

    
   
333
    templateString = templateString.replaceAll("<OutputType>", writableType);

    
   
334
    templateString = templateString.replaceAll("<OutputTypeInspector>", inspectorType);

    
   
335
    writeFile(outputFile, templateString);

    
   
336

   

    
   
337
  }

    
   
338

   

    
   
339
  private void generateVectorUDAFCount(String[] tdesc) throws IOException {

    
   
340
    String className = tdesc[1];

    
   
341
    String valueType = tdesc[2];

    
   
342
    String columnType = getColumnVectorType(valueType);

    
   
343

   

    
   
344
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
345
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
346

   

    
   
347
    String templateString = readFile(templateFile);

    
   
348
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
349
    templateString = templateString.replaceAll("<ValueType>", valueType);

    
   
350
    templateString = templateString.replaceAll("<InputColumnVectorType>", columnType);

    
   
351
    writeFile(outputFile, templateString);

    
   
352
  }

    
   
353

   

    
   
354
  private void generateVectorUDAFSum(String[] tdesc) throws Exception {

    
   
355
  //template, <ClassName>, <ValueType>, <OutputType>, <OutputTypeInspector>

    
   
356
    String className = tdesc[1];

    
   
357
    String valueType = tdesc[2];

    
   
358
    String columnType = getColumnVectorType(valueType);

    
   
359
    String writableType = getOutputWritableType(valueType);

    
   
360
    String inspectorType = getOutputObjectInspector(valueType);

    
   
361

   

    
   
362
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
363
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
364

   

    
   
365
    String templateString = readFile(templateFile);

    
   
366
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
367
    templateString = templateString.replaceAll("<ValueType>", valueType);

    
   
368
    templateString = templateString.replaceAll("<InputColumnVectorType>", columnType);

    
   
369
    templateString = templateString.replaceAll("<OutputType>", writableType);

    
   
370
    templateString = templateString.replaceAll("<OutputTypeInspector>", inspectorType);

    
   
371
    writeFile(outputFile, templateString);

    
   
372
  }

    
   
373

   

    
   
374
  private void generateVectorUDAFAvg(String[] tdesc) throws IOException {

    
   
375
    String className = tdesc[1];

    
   
376
    String valueType = tdesc[2];

    
   
377
    String columnType = getColumnVectorType(valueType);

    
   
378

   

    
   
379
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
380
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
381

   

    
   
382
    String templateString = readFile(templateFile);

    
   
383
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
384
    templateString = templateString.replaceAll("<ValueType>", valueType);

    
   
385
    templateString = templateString.replaceAll("<InputColumnVectorType>", columnType);

    
   
386
    writeFile(outputFile, templateString);

    
   
387
  }

    
   
388

   

    
   
389
  private void generateVectorUDAFVar(String[] tdesc) throws IOException {

    
   
390
    String className = tdesc[1];

    
   
391
    String valueType = tdesc[2];

    
   
392
    String varianceFormula = tdesc[3];

    
   
393
    String descriptionName = tdesc[4];

    
   
394
    String descriptionValue = tdesc[5];

    
   
395
    String columnType = getColumnVectorType(valueType);

    
   
396

   

    
   
397
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
398
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
399

   

    
   
400
    String templateString = readFile(templateFile);

    
   
401
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
402
    templateString = templateString.replaceAll("<ValueType>", valueType);

    
   
403
    templateString = templateString.replaceAll("<InputColumnVectorType>", columnType);

    
   
404
    templateString = templateString.replaceAll("<VarianceFormula>", varianceFormula);

    
   
405
    templateString = templateString.replaceAll("<DescriptionName>", descriptionName);

    
   
406
    templateString = templateString.replaceAll("<DescriptionValue>", descriptionValue);

    
   
407
    writeFile(outputFile, templateString);

    
   
408
  }

    
   
409

   

    
   
410

   

    
   
411
  private void generateFilterStringColumnCompareScalar(String[] tdesc) throws IOException {

    
   
412
    String operatorName = tdesc[1];

    
   
413
    String className = "FilterStringCol" + operatorName + "StringScalar";

    
   
414
    generateFilterStringColumnCompareScalar(tdesc,className);

    
   
415
  }

    
   
416

   

    
   
417
  private void generateFilterStringColumnCompareColumn(String[] tdesc) throws IOException {

    
   
418
    String operatorName = tdesc[1];

    
   
419
    String className = "FilterStringCol" + operatorName + "StringCol";

    
   
420
    generateFilterStringColumnCompareScalar(tdesc,className);

    
   
421
  }

    
   
422

   

    
   
423
  private void generateFilterStringColumnCompareScalar(String[] tdesc, String className) throws IOException {

    
   
424
   String operatorSymbol = tdesc[2];

    
   
425
   String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
426
   // Read the template into a string;

    
   
427
   String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
428
   String templateString = readFile(templateFile);

    
   
429
   // Expand, and write result

    
   
430
   templateString = templateString.replaceAll("<ClassName>", className);

    
   
431
   templateString = templateString.replaceAll("<OperatorSymbol>", operatorSymbol);

    
   
432
   writeFile(outputFile, templateString);

    
   
433
  }

    
   
434

   

    
   
435
  private void generateFilterColumnCompareColumn(String[] tdesc) throws IOException {

    
   
436
    //The variables are all same as ColumnCompareScalar except that

    
   
437
    //this template doesn't need a return type. Pass anything as return type.

    
   
438
    String operatorName = tdesc[1];

    
   
439
    String operandType1 = tdesc[2];

    
   
440
    String operandType2 = tdesc[3];

    
   
441
    String className = "Filter" + getCamelCaseType(operandType1)

    
   
442
        + "Col" + operatorName + getCamelCaseType(operandType2) + "Column";

    
   
443
    generateColumnBinaryOperatorColumn(tdesc, null, className);

    
   
444
  }

    
   
445

   

    
   
446
  private void generateColumnUnaryMinus(String[] tdesc) throws IOException {

    
   
447
    String operandType = tdesc[1];

    
   
448
    String inputColumnVectorType = this.getColumnVectorType(operandType);

    
   
449
    String outputColumnVectorType = inputColumnVectorType;

    
   
450
    String returnType = operandType;

    
   
451
    String className = getCamelCaseType(operandType) + "ColUnaryMinus";

    
   
452
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
453
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
454
    String templateString = readFile(templateFile);

    
   
455
    // Expand, and write result

    
   
456
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
457
    templateString = templateString.replaceAll("<InputColumnVectorType>", inputColumnVectorType);

    
   
458
    templateString = templateString.replaceAll("<OutputColumnVectorType>", outputColumnVectorType);

    
   
459
    templateString = templateString.replaceAll("<OperandType>", operandType);

    
   
460
    templateString = templateString.replaceAll("<ReturnType>", returnType);

    
   
461
    writeFile(outputFile, templateString);

    
   
462
  }

    
   
463

   

    
   
464
  private void generateColumnArithmeticColumn(String [] tdesc) throws IOException {

    
   
465
    String operatorName = tdesc[1];

    
   
466
    String operandType1 = tdesc[2];

    
   
467
    String operandType2 = tdesc[3];

    
   
468
    String className = getCamelCaseType(operandType1)

    
   
469
        + "Col" + operatorName + getCamelCaseType(operandType2) + "Column";

    
   
470
    String returnType = getArithmeticReturnType(operandType1, operandType2);

    
   
471
    generateColumnBinaryOperatorColumn(tdesc, returnType, className);

    
   
472
  }

    
   
473

   

    
   
474
  private void generateFilterColumnCompareScalar(String[] tdesc) throws IOException {

    
   
475
    //The variables are all same as ColumnCompareScalar except that

    
   
476
    //this template doesn't need a return type. Pass anything as return type.

    
   
477
    String operatorName = tdesc[1];

    
   
478
    String operandType1 = tdesc[2];

    
   
479
    String operandType2 = tdesc[3];

    
   
480
    String className = "Filter" + getCamelCaseType(operandType1)

    
   
481
        + "Col" + operatorName + getCamelCaseType(operandType2) + "Scalar";

    
   
482
    generateColumnBinaryOperatorScalar(tdesc, null, className);

    
   
483
  }

    
   
484

   

    
   
485
  private void generateFilterScalarCompareColumn(String[] tdesc) throws IOException {

    
   
486
    //this template doesn't need a return type. Pass anything as return type.

    
   
487
    String operatorName = tdesc[1];

    
   
488
    String operandType1 = tdesc[2];

    
   
489
    String operandType2 = tdesc[3];

    
   
490
    String className = "Filter" + getCamelCaseType(operandType1)

    
   
491
        + "Scalar" + operatorName + getCamelCaseType(operandType2) + "Column";

    
   
492
    generateScalarBinaryOperatorColumn(tdesc, null, className);

    
   
493
  }

    
   
494

   

    
   
495
  private void generateColumnCompareScalar(String[] tdesc) throws IOException {

    
   
496
    String operatorName = tdesc[1];

    
   
497
    String operandType1 = tdesc[2];

    
   
498
    String operandType2 = tdesc[3];

    
   
499
    String returnType = "long";

    
   
500
    String className = getCamelCaseType(operandType1)

    
   
501
        + "Col" + operatorName + getCamelCaseType(operandType2) + "Scalar";

    
   
502
    generateColumnBinaryOperatorScalar(tdesc, returnType, className);

    
   
503
  }

    
   
504

   

    
   
505
  private void generateColumnBinaryOperatorColumn(String[] tdesc, String returnType,

    
   
506
         String className) throws IOException {

    
   
507
    String operandType1 = tdesc[2];

    
   
508
    String operandType2 = tdesc[3];

    
   
509
    String outputColumnVectorType = this.getColumnVectorType(returnType);

    
   
510
    String inputColumnVectorType1 = this.getColumnVectorType(operandType1);

    
   
511
    String inputColumnVectorType2 = this.getColumnVectorType(operandType2);

    
   
512
    String operatorSymbol = tdesc[4];

    
   
513
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
514

   

    
   
515
    //Read the template into a string;

    
   
516
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
517
    String templateString = readFile(templateFile);

    
   
518
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
519
    templateString = templateString.replaceAll("<InputColumnVectorType1>", inputColumnVectorType1);

    
   
520
    templateString = templateString.replaceAll("<InputColumnVectorType2>", inputColumnVectorType2);

    
   
521
    templateString = templateString.replaceAll("<OutputColumnVectorType>", outputColumnVectorType);

    
   
522
    templateString = templateString.replaceAll("<OperatorSymbol>", operatorSymbol);

    
   
523
    templateString = templateString.replaceAll("<OperandType1>", operandType1);

    
   
524
    templateString = templateString.replaceAll("<OperandType2>", operandType2);

    
   
525
    templateString = templateString.replaceAll("<ReturnType>", returnType);

    
   
526
    writeFile(outputFile, templateString);

    
   
527

   

    
   
528
    if(returnType==null){

    
   
529
      testCodeGen.addColumnColumnFilterTestCases(

    
   
530
          className,

    
   
531
          inputColumnVectorType1,

    
   
532
          inputColumnVectorType2,

    
   
533
          operatorSymbol);

    
   
534
    }else{

    
   
535
      testCodeGen.addColumnColumnOperationTestCases(

    
   
536
          className,

    
   
537
          inputColumnVectorType1,

    
   
538
          inputColumnVectorType2,

    
   
539
          outputColumnVectorType);

    
   
540
    }

    
   
541
  }

    
   
542

   

    
   
543
  private void generateColumnBinaryOperatorScalar(String[] tdesc, String returnType,

    
   
544
     String className) throws IOException {

    
   
545
    String operandType1 = tdesc[2];

    
   
546
    String operandType2 = tdesc[3];

    
   
547
    String outputColumnVectorType = this.getColumnVectorType(returnType);

    
   
548
    String inputColumnVectorType = this.getColumnVectorType(operandType1);

    
   
549
    String operatorSymbol = tdesc[4];

    
   
550
    String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
551

   

    
   
552
    //Read the template into a string;

    
   
553
    String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
554
    String templateString = readFile(templateFile);

    
   
555
    templateString = templateString.replaceAll("<ClassName>", className);

    
   
556
    templateString = templateString.replaceAll("<InputColumnVectorType>", inputColumnVectorType);

    
   
557
    templateString = templateString.replaceAll("<OutputColumnVectorType>", outputColumnVectorType);

    
   
558
    templateString = templateString.replaceAll("<OperatorSymbol>", operatorSymbol);

    
   
559
    templateString = templateString.replaceAll("<OperandType1>", operandType1);

    
   
560
    templateString = templateString.replaceAll("<OperandType2>", operandType2);

    
   
561
    templateString = templateString.replaceAll("<ReturnType>", returnType);

    
   
562
    writeFile(outputFile, templateString);

    
   
563

   

    
   
564
    if(returnType==null)

    
   
565
    {

    
   
566
      testCodeGen.addColumnScalarFilterTestCases(

    
   
567
          true,

    
   
568
          className,

    
   
569
          inputColumnVectorType,

    
   
570
          operandType2,

    
   
571
          operatorSymbol);

    
   
572
    }else

    
   
573
    {

    
   
574
      testCodeGen.addColumnScalarOperationTestCases(

    
   
575
          true,

    
   
576
          className,

    
   
577
          inputColumnVectorType,

    
   
578
          outputColumnVectorType,

    
   
579
          operandType2);

    
   
580
    }

    
   
581

   

    
   
582
  }

    
   
583

   

    
   
584
  private void generateScalarBinaryOperatorColumn(String[] tdesc, String returnType,

    
   
585
     String className) throws IOException {

    
   
586
     String operandType1 = tdesc[2];

    
   
587
     String operandType2 = tdesc[3];

    
   
588
     String outputColumnVectorType = this.getColumnVectorType(returnType);

    
   
589
     String inputColumnVectorType = this.getColumnVectorType(operandType2);

    
   
590
     String operatorSymbol = tdesc[4];

    
   
591
     String outputFile = joinPath(this.outputDirectory, className + ".java");

    
   
592

   

    
   
593
     //Read the template into a string;

    
   
594
     String templateFile = joinPath(this.templateDirectory, tdesc[0] + ".txt");

    
   
595
     String templateString = readFile(templateFile);

    
   
596
     templateString = templateString.replaceAll("<ClassName>", className);

    
   
597
     templateString = templateString.replaceAll("<InputColumnVectorType>", inputColumnVectorType);

    
   
598
     templateString = templateString.replaceAll("<OutputColumnVectorType>", outputColumnVectorType);

    
   
599
     templateString = templateString.replaceAll("<OperatorSymbol>", operatorSymbol);

    
   
600
     templateString = templateString.replaceAll("<OperandType1>", operandType1);

    
   
601
     templateString = templateString.replaceAll("<OperandType2>", operandType2);

    
   
602
     templateString = templateString.replaceAll("<ReturnType>", returnType);

    
   
603
     writeFile(outputFile, templateString);

    
   
604

   

    
   
605
     if(returnType==null)

    
   
606
     {

    
   
607
       testCodeGen.addColumnScalarFilterTestCases(

    
   
608
           false,

    
   
609
           className,

    
   
610
           inputColumnVectorType,

    
   
611
           operandType1,

    
   
612
           operatorSymbol);

    
   
613
     }else

    
   
614
     {

    
   
615
       testCodeGen.addColumnScalarOperationTestCases(

    
   
616
           false,

    
   
617
           className,

    
   
618
           inputColumnVectorType,

    
   
619
           outputColumnVectorType,

    
   
620
           operandType1);

    
   
621
     }

    
   
622
   }

    
   
623

   

    
   
624
  //Binary arithmetic operator

    
   
625
  private void generateColumnArithmeticScalar(String[] tdesc) throws IOException {

    
   
626
    String operatorName = tdesc[1];

    
   
627
    String operandType1 = tdesc[2];

    
   
628
    String operandType2 = tdesc[3];

    
   
629
    String className = getCamelCaseType(operandType1)

    
   
630
        + "Col" + operatorName + getCamelCaseType(operandType2) + "Scalar";

    
   
631
    String returnType = getArithmeticReturnType(operandType1, operandType2);

    
   
632
    generateColumnBinaryOperatorScalar(tdesc, returnType, className);

    
   
633
  }

    
   
634

   

    
   
635
  private void generateScalarArithmeticColumn(String[] tdesc) throws IOException {

    
   
636
    String operatorName = tdesc[1];

    
   
637
    String operandType1 = tdesc[2];

    
   
638
    String operandType2 = tdesc[3];

    
   
639
    String className = getCamelCaseType(operandType1)

    
   
640
        + "Scalar" + operatorName + getCamelCaseType(operandType2) + "Column";

    
   
641
    String returnType = getArithmeticReturnType(operandType1, operandType2);

    
   
642
    generateScalarBinaryOperatorColumn(tdesc, returnType, className);

    
   
643
  }

    
   
644

   

    
   
645

   

    
   
646
   static void writeFile(String outputFile, String str) throws IOException {

    
   
647
    BufferedWriter w = new BufferedWriter(new FileWriter(outputFile));

    
   
648
    w.write(str);

    
   
649
    w.close();

    
   
650
  }

    
   
651

   

    
   
652
   static String readFile(String templateFile) throws IOException {

    
   
653
    BufferedReader r = new BufferedReader(new FileReader(templateFile));

    
   
654
    String line = r.readLine();

    
   
655
    StringBuilder b = new StringBuilder();

    
   
656
    while (line != null) {

    
   
657
      b.append(line);

    
   
658
      b.append("\n");

    
   
659
      line = r.readLine();

    
   
660
    }

    
   
661
    r.close();

    
   
662
    return b.toString();

    
   
663
  }

    
   
664

   

    
   
665
   static String getCamelCaseType(String type) {

    
   
666
    if (type.equals("long")) {

    
   
667
      return "Long";

    
   
668
    } else if (type.equals("double")) {

    
   
669
      return "Double";

    
   
670
    } else {

    
   
671
      return type;

    
   
672
    }

    
   
673
  }

    
   
674

   

    
   
675
  private String getArithmeticReturnType(String operandType1,

    
   
676
      String operandType2) {

    
   
677
    if (operandType1.equals("double") ||

    
   
678
        operandType2.equals("double")) {

    
   
679
      return "double";

    
   
680
    } else {

    
   
681
      return "long";

    
   
682
    }

    
   
683
  }

    
   
684

   

    
   
685
  private String getColumnVectorType(String primitiveType) {

    
   
686
    if(primitiveType!=null && primitiveType.equals("double")) {

    
   
687
      return "DoubleColumnVector";

    
   
688
    }

    
   
689
    return "LongColumnVector";

    
   
690
  }

    
   
691

   

    
   
692
  private String getOutputWritableType(String primitiveType) throws Exception {

    
   
693
    if (primitiveType.equals("long")) {

    
   
694
      return "LongWritable";

    
   
695
    } else if (primitiveType.equals("double")) {

    
   
696
      return "DoubleWritable";

    
   
697
    }

    
   
698
    throw new Exception("Unimplemented primitive output writable: " + primitiveType);

    
   
699
  }

    
   
700

   

    
   
701
  private String getOutputObjectInspector(String primitiveType) throws Exception {

    
   
702
    if (primitiveType.equals("long")) {

    
   
703
      return "PrimitiveObjectInspectorFactory.writableLongObjectInspector";

    
   
704
    } else if (primitiveType.equals("double")) {

    
   
705
      return "PrimitiveObjectInspectorFactory.writableDoubleObjectInspector";

    
   
706
    }

    
   
707
    throw new Exception("Unimplemented primitive output inspector: " + primitiveType);

    
   
708
  }

    
   
709
}

    
   
710

   
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnArithmeticColumn.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnArithmeticScalar.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnCompareScalar.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnUnaryMinus.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterColumnCompareColumn.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterColumnCompareScalar.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterStringColumnCompareColumn.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterStringColumnCompareScalar.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ScalarArithmeticColumn.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestClass.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestCodeGen.java
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnColumnFilterVectorExpressionEvaluation.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnColumnOperationVectorExpressionEvaluation.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnScalarFilterVectorExpressionEvaluation.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnScalarOperationVectorExpressionEvaluation.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFAvg.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFCount.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFMinMax.txt
New File
 
ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFSum.txt
New File
 
  1. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/CodeGen.java: Loading...
  2. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnArithmeticColumn.txt: Loading...
  3. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnArithmeticScalar.txt: Loading...
  4. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnCompareScalar.txt: Loading...
  5. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ColumnUnaryMinus.txt: Loading...
  6. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterColumnCompareColumn.txt: Loading...
  7. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterColumnCompareScalar.txt: Loading...
  8. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterStringColumnCompareColumn.txt: Loading...
  9. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/FilterStringColumnCompareScalar.txt: Loading...
  10. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/ScalarArithmeticColumn.txt: Loading...
  11. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestClass.txt: Loading...
  12. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestCodeGen.java: Loading...
  13. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnColumnFilterVectorExpressionEvaluation.txt: Loading...
  14. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnColumnOperationVectorExpressionEvaluation.txt: Loading...
  15. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnScalarFilterVectorExpressionEvaluation.txt: Loading...
  16. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/TestColumnScalarOperationVectorExpressionEvaluation.txt: Loading...
  17. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFAvg.txt: Loading...
  18. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFCount.txt: Loading...
  19. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFMinMax.txt: Loading...
  20. ql/src/gen/vectorization/org/apache/hadoop/hive/ql/exec/vector/expressions/gen/VectorUDAFSum.txt: Loading...
This diff has been split across 2 pages: 1 2 >