PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Java | 83 lines | 42 code | 12 blank | 29 comment | 0 complexity | 73a3fade8cdd2184bccf0e4972f19ab0 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 org.apache.hadoop.hive.common.io.NonSyncByteArrayInputStream;
22import org.apache.hadoop.hive.common.io.NonSyncByteArrayOutputStream;
23
24/**
25 * Extensions to bytearrayinput/output streams.
26 * 
27 */
28public class ByteStream {
29  /**
30   * Input.
31   *
32   */
33  public static class Input extends NonSyncByteArrayInputStream {
34    public byte[] getData() {
35      return buf;
36    }
37
38    public int getCount() {
39      return count;
40    }
41
42    public void reset(byte[] argBuf, int argCount) {
43      buf = argBuf;
44      mark = pos = 0;
45      count = argCount;
46    }
47
48    public Input() {
49      super(new byte[1]);
50    }
51
52    public Input(byte[] buf) {
53      super(buf);
54    }
55
56    public Input(byte[] buf, int offset, int length) {
57      super(buf, offset, length);
58    }
59  }
60
61  /**
62   * Output.
63   *
64   */
65  public static class Output extends NonSyncByteArrayOutputStream {
66    @Override
67    public byte[] getData() {
68      return buf;
69    }
70
71    public int getCount() {
72      return count;
73    }
74
75    public Output() {
76      super();
77    }
78
79    public Output(int size) {
80      super(size);
81    }
82  }
83}