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 | #ifndef RECORDIO_HH_ |
---|
20 | #define RECORDIO_HH_ |
---|
21 | |
---|
22 | #include <stdio.h> |
---|
23 | #include <stdint.h> |
---|
24 | #include <iostream> |
---|
25 | #include <cstring> |
---|
26 | #include <string> |
---|
27 | #include <vector> |
---|
28 | #include <map> |
---|
29 | #include <bitset> |
---|
30 | |
---|
31 | namespace hadoop { |
---|
32 | |
---|
33 | class InStream { |
---|
34 | public: |
---|
35 | virtual ssize_t read(void *buf, size_t buflen) = 0; |
---|
36 | virtual ~InStream() {} |
---|
37 | }; |
---|
38 | |
---|
39 | class OutStream { |
---|
40 | public: |
---|
41 | virtual ssize_t write(const void *buf, size_t len) = 0; |
---|
42 | virtual ~OutStream() {} |
---|
43 | }; |
---|
44 | |
---|
45 | class IArchive; |
---|
46 | class OArchive; |
---|
47 | |
---|
48 | class Record { |
---|
49 | public: |
---|
50 | virtual void serialize(OArchive& archive, const char* tag) const = 0; |
---|
51 | virtual void deserialize(IArchive& archive, const char* tag) = 0; |
---|
52 | virtual const std::string& type() const = 0; |
---|
53 | virtual const std::string& signature() const = 0; |
---|
54 | virtual ~Record() {} |
---|
55 | }; |
---|
56 | |
---|
57 | enum RecFormat { kBinary, kXML, kCSV }; |
---|
58 | |
---|
59 | class RecordReader { |
---|
60 | private: |
---|
61 | IArchive* mpArchive; |
---|
62 | public: |
---|
63 | RecordReader(InStream& stream, RecFormat f); |
---|
64 | virtual void read(hadoop::Record& record); |
---|
65 | virtual ~RecordReader(); |
---|
66 | }; |
---|
67 | |
---|
68 | class RecordWriter { |
---|
69 | private: |
---|
70 | OArchive* mpArchive; |
---|
71 | public: |
---|
72 | RecordWriter(OutStream& stream, RecFormat f); |
---|
73 | virtual void write(const hadoop::Record& record); |
---|
74 | virtual ~RecordWriter(); |
---|
75 | }; |
---|
76 | }; // end namspace hadoop |
---|
77 | |
---|
78 | #include "archive.hh" |
---|
79 | #include "exception.hh" |
---|
80 | |
---|
81 | #endif /*RECORDIO_HH_*/ |
---|
82 | |
---|