1
// Copyright 2016 Feather Developers
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
7
// http://www.apache.org/licenses/LICENSE-2.0
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.
15
#ifndef FEATHER_WRITER_H
16
#define FEATHER_WRITER_H
21
#include "feather/io.h"
22
#include "feather/metadata.h"
23
#include "feather/types.h"
31
Status Open(const std::shared_ptr<OutputStream>& stream);
32
static Status OpenFile(const std::string& abspath,
33
std::unique_ptr<TableWriter>* out);
35
void SetDescription(const std::string& desc);
36
void SetNumRows(int64_t num_rows);
39
Status AppendPlain(const std::string& name, const PrimitiveArray& values);
41
// Dictionary-encoded primitive data. Especially useful for strings and
43
void AppendDictEncoded(const std::string& name, const DictEncodedArray& data);
46
Status AppendCategory(const std::string& name, const PrimitiveArray& values,
47
const PrimitiveArray& levels, bool ordered = false);
49
// Other primitive data types
50
Status AppendTimestamp(const std::string& name, const PrimitiveArray& values,
51
const TimestampMetadata& meta);
53
Status AppendDate(const std::string& name, const PrimitiveArray& values);
55
Status AppendTime(const std::string& name, const PrimitiveArray& values,
56
const TimeMetadata& meta);
58
// We are done, write the file metadata and footer
64
std::shared_ptr<OutputStream> stream_;
66
bool initialized_stream_;
67
metadata::TableBuilder metadata_;
69
Status AppendPrimitive(const PrimitiveArray& values, ArrayMetadata* out);
72
} // namespace feather
74
#endif // FEATHER_WRITER_H