PageRenderTime 50ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 66 lines | 35 code | 9 blank | 22 comment | 5 complexity | 45b544fc83e39f0fdf279d3d2bbcd657 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.objectinspector;
  19. import java.util.List;
  20. import org.apache.hadoop.hive.serde2.lazybinary.LazyBinaryStruct;
  21. import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
  22. import org.apache.hadoop.hive.serde2.objectinspector.StandardStructObjectInspector;
  23. import org.apache.hadoop.hive.serde2.objectinspector.StructField;
  24. /**
  25. * ObjectInspector for LazyBinaryStruct.
  26. *
  27. * @see LazyBinaryStruct
  28. */
  29. public class LazyBinaryStructObjectInspector extends
  30. StandardStructObjectInspector {
  31. protected LazyBinaryStructObjectInspector(List<String> structFieldNames,
  32. List<ObjectInspector> structFieldObjectInspectors) {
  33. super(structFieldNames, structFieldObjectInspectors);
  34. }
  35. protected LazyBinaryStructObjectInspector(List<StructField> fields) {
  36. super(fields);
  37. }
  38. @Override
  39. public Object getStructFieldData(Object data, StructField fieldRef) {
  40. if (data == null) {
  41. return null;
  42. }
  43. LazyBinaryStruct struct = (LazyBinaryStruct) data;
  44. MyField f = (MyField) fieldRef;
  45. int fieldID = f.getFieldID();
  46. assert (fieldID >= 0 && fieldID < fields.size());
  47. return struct.getField(fieldID);
  48. }
  49. @Override
  50. public List<Object> getStructFieldsDataAsList(Object data) {
  51. if (data == null) {
  52. return null;
  53. }
  54. LazyBinaryStruct struct = (LazyBinaryStruct) data;
  55. return struct.getFieldsAsList();
  56. }
  57. }