PageRenderTime 36ms CodeModel.GetById 22ms app.highlight 8ms RepoModel.GetById 2ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/ql/src/java/org/apache/hadoop/hive/ql/udf/UDAFWrongArgLengthForTestCase.java

#
Java | 72 lines | 34 code | 13 blank | 25 comment | 3 complexity | 191430facbbc0802222577da0f257f1a MD5 | raw file
 1/**
 2 * Licensed to the Apache Software Foundation (ASF) under one
 3 * or more contributor license agreements.  See the NOTICE file
 4 * distributed with this work for additional information
 5 * regarding copyright ownership.  The ASF licenses this file
 6 * to you under the Apache License, Version 2.0 (the
 7 * "License"); you may not use this file except in compliance
 8 * with the License.  You may obtain a copy of the License at
 9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package org.apache.hadoop.hive.ql.udf;
20
21import org.apache.hadoop.hive.ql.exec.UDAF;
22import org.apache.hadoop.hive.ql.exec.UDAFEvaluator;
23import org.apache.hadoop.io.LongWritable;
24import org.apache.hadoop.io.Text;
25
26/**
27 * UDAFWrongArgLengthForTestCase.
28 *
29 */
30public class UDAFWrongArgLengthForTestCase extends UDAF {
31
32  /**
33   * UDAFWrongArgLengthForTestCaseEvaluator.
34   *
35   */
36  public static class UDAFWrongArgLengthForTestCaseEvaluator implements
37      UDAFEvaluator {
38
39    private long mCount;
40
41    public UDAFWrongArgLengthForTestCaseEvaluator() {
42      super();
43      init();
44    }
45
46    public void init() {
47      mCount = 0;
48    }
49
50    Text emptyText = new Text();
51
52    public boolean iterate(Object o) {
53      if (o != null && !emptyText.equals(o)) {
54        mCount++;
55      }
56      return true;
57    }
58
59    public LongWritable terminatePartial() {
60      return new LongWritable(mCount);
61    }
62
63    public boolean merge() {
64      return true;
65    }
66
67    public LongWritable terminate() {
68      return new LongWritable(mCount);
69    }
70  }
71
72}