PageRenderTime 45ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/serde/src/java/org/apache/hadoop/hive/serde2/lazybinary/LazyBinaryObject.java

#
Java | 71 lines | 13 code | 7 blank | 51 comment | 0 complexity | 39c2e2b7110b7b75e7939c5023eccaa3 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.serde2.lazybinary;
  19. import org.apache.hadoop.hive.serde2.lazy.ByteArrayRef;
  20. import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
  21. /**
  22. * LazyBinaryObject stores an object in a binary format in a byte[]. For
  23. * example, a double takes four bytes.
  24. *
  25. * A LazyBinaryObject can represent any primitive object or hierarchical object
  26. * like string, list, map or struct.
  27. */
  28. public abstract class LazyBinaryObject<OI extends ObjectInspector> {
  29. OI oi;
  30. /**
  31. * Create a LazyBinaryObject.
  32. *
  33. * @param oi
  34. * Derived classes can access meta information about this Lazy Binary
  35. * Object (e.g, length, null-bits) from it.
  36. */
  37. protected LazyBinaryObject(OI oi) {
  38. this.oi = oi;
  39. }
  40. /**
  41. * Set the data for this LazyBinaryObject. We take ByteArrayRef instead of
  42. * byte[] so that we will be able to drop the reference to byte[] by a single
  43. * assignment. The ByteArrayRef object can be reused across multiple rows.
  44. *
  45. * Never call this function if the object represent a null!!!
  46. *
  47. * @param bytes
  48. * The wrapper of the byte[].
  49. * @param start
  50. * The start position inside the bytes.
  51. * @param length
  52. * The length of the data, starting from "start"
  53. * @see ByteArrayRef
  54. */
  55. public abstract void init(ByteArrayRef bytes, int start, int length);
  56. /**
  57. * If the LazyBinaryObject is a primitive Object, then deserialize it and
  58. * return the actual primitive Object. Otherwise (string, list, map, struct),
  59. * return this.
  60. */
  61. public abstract Object getObject();
  62. @Override
  63. public abstract int hashCode();
  64. }