source: proiecte/HadoopJUnit/hadoop-0.20.1/src/c++/librecordio/recordio.cc @ 141

Last change on this file since 141 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 1.8 KB
Line 
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#include "recordio.hh"
20#include "binarchive.hh"
21#include "csvarchive.hh"
22#include "xmlarchive.hh"
23
24using namespace hadoop;
25
26hadoop::RecordReader::RecordReader(InStream& stream, RecFormat f)
27{
28  switch (f) {
29    case kBinary:
30      mpArchive = new IBinArchive(stream);
31      break;
32    case kCSV:
33      mpArchive = new ICsvArchive(stream);
34      break;
35    case kXML:
36      mpArchive = new IXmlArchive(stream);
37      break;
38  }
39}
40
41hadoop::RecordReader::~RecordReader()
42{
43  delete mpArchive;
44}
45
46void hadoop::RecordReader::read(Record& record)
47{
48  record.deserialize(*mpArchive, (const char*) NULL);
49}
50
51hadoop::RecordWriter::RecordWriter(OutStream& stream, RecFormat f)
52{
53  switch (f) {
54    case kBinary:
55      mpArchive = new OBinArchive(stream);
56      break;
57    case kCSV:
58      mpArchive = new OCsvArchive(stream);
59      break;
60    case kXML:
61      mpArchive = new OXmlArchive(stream);
62      break;
63  }
64}
65
66hadoop::RecordWriter::~RecordWriter()
67{
68  delete mpArchive;
69}
70
71void hadoop::RecordWriter::write(const Record& record)
72{
73  record.serialize(*mpArchive, (const char*) NULL);
74}
75
Note: See TracBrowser for help on using the repository browser.