PageRenderTime 19ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/serde/src/java/org/apache/hadoop/hive/serde2/Deserializer.java

#
Java | 67 lines | 10 code | 7 blank | 50 comment | 0 complexity | a0d58f21662e11ab885da8a8c8bbb951 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.serde2;
20
21import java.util.Properties;
22
23import org.apache.hadoop.conf.Configuration;
24import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
25import org.apache.hadoop.io.Writable;
26
27/**
28 * HiveDeserializer is used to deserialize the data from hadoop Writable to a
29 * custom java object that can be of any type that the developer wants.
30 * 
31 * HiveDeserializer also provides the ObjectInspector which can be used to
32 * inspect the internal structure of the object (that is returned by deserialize
33 * function).
34 * 
35 */
36public interface Deserializer {
37
38  /**
39   * Initialize the HiveDeserializer.
40   * 
41   * @param conf
42   *          System properties
43   * @param tbl
44   *          table properties
45   * @throws SerDeException
46   */
47  void initialize(Configuration conf, Properties tbl) throws SerDeException;
48
49  /**
50   * Deserialize an object out of a Writable blob. In most cases, the return
51   * value of this function will be constant since the function will reuse the
52   * returned object. If the client wants to keep a copy of the object, the
53   * client needs to clone the returned value by calling
54   * ObjectInspectorUtils.getStandardObject().
55   * 
56   * @param blob
57   *          The Writable object containing a serialized object
58   * @return A Java object representing the contents in the blob.
59   */
60  Object deserialize(Writable blob) throws SerDeException;
61
62  /**
63   * Get the object inspector that can be used to navigate through the internal
64   * structure of the Object returned from deserialize(...).
65   */
66  ObjectInspector getObjectInspector() throws SerDeException;
67}