Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
write-stream.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_EXEC_WRITE_STREAM_H
17 #define IMPALA_EXEC_WRITE_STREAM_H
18 
19 #include <boost/cstdint.hpp>
20 
21 #include "common/status.h"
22 
23 namespace impala {
24 
29 class WriteStream {
30  public:
31 
32  WriteStream() : len_(0) { };
33 
35  inline int WriteBytes(int length, const uint8_t* buf);
36  inline int WriteBytes(int length, const char* buf);
37 
38  inline int WriteVInt(int32_t val);
39  inline int WriteInt(uint32_t val);
40  inline int WriteByte(uint8_t val);
41  inline int WriteByte(char val);
42  inline int WriteVLong(int64_t val);
43  inline int WriteBoolean(bool val);
45  inline int WriteZInt(int32_t val);
46  inline int WriteZLong(int64_t val);
48  inline int WriteText(int32_t len, const uint8_t* buf);
50  inline int WriteEmptyText();
51 
52  inline void Clear();
53  inline size_t Size();
54 
56  inline std::string String();
57 
58  private:
60  std::stringstream buffer_;
62 };
63 
64 } // namespace impala
65 #endif
int WriteZLong(int64_t val)
int WriteBytes(int length, const uint8_t *buf)
Writes bytes to the buffer, returns the number of bytes written.
std::stringstream buffer_
TODO consider making this like the parquet writer to avoid extra copy.
Definition: write-stream.h:60
int WriteEmptyText()
Writes an empty string to the buffer (encoded as 1 byte)
int WriteInt(uint32_t val)
int WriteVInt(int32_t val)
int WriteZInt(int32_t val)
Writes a zig-zag encoded integer.
int WriteBoolean(bool val)
int WriteByte(uint8_t val)
int WriteText(int32_t len, const uint8_t *buf)
Writes the length as a VLong follows by the byte string.
std::string String()
returns the contents of this stream as a string
int WriteVLong(int64_t val)