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 | |
---|
19 | package org.apache.hadoop.record; |
---|
20 | |
---|
21 | import java.io.IOException; |
---|
22 | |
---|
23 | /** |
---|
24 | * Interface that all the Deserializers have to implement. |
---|
25 | */ |
---|
26 | public interface RecordInput { |
---|
27 | /** |
---|
28 | * Read a byte from serialized record. |
---|
29 | * @param tag Used by tagged serialization formats (such as XML) |
---|
30 | * @return value read from serialized record. |
---|
31 | */ |
---|
32 | byte readByte(String tag) throws IOException; |
---|
33 | |
---|
34 | /** |
---|
35 | * Read a boolean from serialized record. |
---|
36 | * @param tag Used by tagged serialization formats (such as XML) |
---|
37 | * @return value read from serialized record. |
---|
38 | */ |
---|
39 | boolean readBool(String tag) throws IOException; |
---|
40 | |
---|
41 | /** |
---|
42 | * Read an integer from serialized record. |
---|
43 | * @param tag Used by tagged serialization formats (such as XML) |
---|
44 | * @return value read from serialized record. |
---|
45 | */ |
---|
46 | int readInt(String tag) throws IOException; |
---|
47 | |
---|
48 | /** |
---|
49 | * Read a long integer from serialized record. |
---|
50 | * @param tag Used by tagged serialization formats (such as XML) |
---|
51 | * @return value read from serialized record. |
---|
52 | */ |
---|
53 | long readLong(String tag) throws IOException; |
---|
54 | |
---|
55 | /** |
---|
56 | * Read a single-precision float from serialized record. |
---|
57 | * @param tag Used by tagged serialization formats (such as XML) |
---|
58 | * @return value read from serialized record. |
---|
59 | */ |
---|
60 | float readFloat(String tag) throws IOException; |
---|
61 | |
---|
62 | /** |
---|
63 | * Read a double-precision number from serialized record. |
---|
64 | * @param tag Used by tagged serialization formats (such as XML) |
---|
65 | * @return value read from serialized record. |
---|
66 | */ |
---|
67 | double readDouble(String tag) throws IOException; |
---|
68 | |
---|
69 | /** |
---|
70 | * Read a UTF-8 encoded string from serialized record. |
---|
71 | * @param tag Used by tagged serialization formats (such as XML) |
---|
72 | * @return value read from serialized record. |
---|
73 | */ |
---|
74 | String readString(String tag) throws IOException; |
---|
75 | |
---|
76 | /** |
---|
77 | * Read byte array from serialized record. |
---|
78 | * @param tag Used by tagged serialization formats (such as XML) |
---|
79 | * @return value read from serialized record. |
---|
80 | */ |
---|
81 | Buffer readBuffer(String tag) throws IOException; |
---|
82 | |
---|
83 | /** |
---|
84 | * Check the mark for start of the serialized record. |
---|
85 | * @param tag Used by tagged serialization formats (such as XML) |
---|
86 | */ |
---|
87 | void startRecord(String tag) throws IOException; |
---|
88 | |
---|
89 | /** |
---|
90 | * Check the mark for end of the serialized record. |
---|
91 | * @param tag Used by tagged serialization formats (such as XML) |
---|
92 | */ |
---|
93 | void endRecord(String tag) throws IOException; |
---|
94 | |
---|
95 | /** |
---|
96 | * Check the mark for start of the serialized vector. |
---|
97 | * @param tag Used by tagged serialization formats (such as XML) |
---|
98 | * @return Index that is used to count the number of elements. |
---|
99 | */ |
---|
100 | Index startVector(String tag) throws IOException; |
---|
101 | |
---|
102 | /** |
---|
103 | * Check the mark for end of the serialized vector. |
---|
104 | * @param tag Used by tagged serialization formats (such as XML) |
---|
105 | */ |
---|
106 | void endVector(String tag) throws IOException; |
---|
107 | |
---|
108 | /** |
---|
109 | * Check the mark for start of the serialized map. |
---|
110 | * @param tag Used by tagged serialization formats (such as XML) |
---|
111 | * @return Index that is used to count the number of map entries. |
---|
112 | */ |
---|
113 | Index startMap(String tag) throws IOException; |
---|
114 | |
---|
115 | /** |
---|
116 | * Check the mark for end of the serialized map. |
---|
117 | * @param tag Used by tagged serialization formats (such as XML) |
---|
118 | */ |
---|
119 | void endMap(String tag) throws IOException; |
---|
120 | } |
---|