PageRenderTime 20ms CodeModel.GetById 12ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/java/org/apache/hadoop/hive/ql/exec/UDF.java

#
Java | 74 lines | 18 code | 8 blank | 48 comment | 0 complexity | 6c6910b89c7281e0014c313d6a3d6847 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.exec;
20
21import org.apache.hadoop.hive.ql.udf.UDFType;
22
23/**
24 * A User-defined function (UDF) for the use with Hive.
25 * 
26 * New UDF classes need to inherit from this UDF class.
27 * 
28 * Required for all UDF classes: 1. Implement one or more methods named
29 * "evaluate" which will be called by Hive. The following are some examples:
30 * public int evaluate(); public int evaluate(int a); public double evaluate(int
31 * a, double b); public String evaluate(String a, int b, String c);
32 * 
33 * "evaluate" should never be a void method. However it can return "null" if
34 * needed.
35 */
36@UDFType(deterministic = true)
37public class UDF {
38
39  /**
40   * The resolver to use for method resolution.
41   */
42  private UDFMethodResolver rslv;
43
44  /**
45   * The constructor.
46   */
47  public UDF() {
48    rslv = new DefaultUDFMethodResolver(this.getClass());
49  }
50
51  /**
52   * The constructor with user-provided UDFMethodResolver.
53   */
54  protected UDF(UDFMethodResolver rslv) {
55    this.rslv = rslv;
56  }
57
58  /**
59   * Sets the resolver.
60   * 
61   * @param rslv
62   *          The method resolver to use for method resolution.
63   */
64  public void setResolver(UDFMethodResolver rslv) {
65    this.rslv = rslv;
66  }
67
68  /**
69   * Get the method resolver.
70   */
71  public UDFMethodResolver getResolver() {
72    return rslv;
73  }
74}