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