PageRenderTime 35ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFOPBitXor.java

#
Java | 70 lines | 40 code | 9 blank | 21 comment | 16 complexity | 5109aca40a6b4e2a7332a6a91d271dd6 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.udf;
  19. import org.apache.hadoop.hive.ql.exec.Description;
  20. import org.apache.hadoop.hive.serde2.io.ByteWritable;
  21. import org.apache.hadoop.hive.serde2.io.ShortWritable;
  22. import org.apache.hadoop.io.IntWritable;
  23. import org.apache.hadoop.io.LongWritable;
  24. /**
  25. * UDFOPBitXor.
  26. *
  27. */
  28. @Description(name = "^", value = "a _FUNC_ b - Bitwise exclusive or", extended = "Example:\n"
  29. + " > SELECT 3 _FUNC_ 5 FROM src LIMIT 1;\n" + " 2")
  30. public class UDFOPBitXor extends UDFBaseBitOP {
  31. public UDFOPBitXor() {
  32. }
  33. public ByteWritable evaluate(ByteWritable a, ByteWritable b) {
  34. if (a == null || b == null) {
  35. return null;
  36. }
  37. byteWritable.set((byte) (a.get() ^ b.get()));
  38. return byteWritable;
  39. }
  40. public ShortWritable evaluate(ShortWritable a, ShortWritable b) {
  41. if (a == null || b == null) {
  42. return null;
  43. }
  44. shortWritable.set((short) (a.get() ^ b.get()));
  45. return shortWritable;
  46. }
  47. public IntWritable evaluate(IntWritable a, IntWritable b) {
  48. if (a == null || b == null) {
  49. return null;
  50. }
  51. intWritable.set(a.get() ^ b.get());
  52. return intWritable;
  53. }
  54. public LongWritable evaluate(LongWritable a, LongWritable b) {
  55. if (a == null || b == null) {
  56. return null;
  57. }
  58. longWritable.set(a.get() ^ b.get());
  59. return longWritable;
  60. }
  61. }