1 | // Licensed to the Apache Software Foundation (ASF) under one |
2 | // or more contributor license agreements. See the NOTICE file |
3 | // distributed with this work for additional information |
4 | // regarding copyright ownership. The ASF licenses this file |
5 | // to you under the Apache License, Version 2.0 (the |
6 | // "License"); you may not use this file except in compliance |
7 | // with the License. You may obtain a copy of the License at |
8 | // |
9 | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | // |
11 | // Unless required by applicable law or agreed to in writing, |
12 | // software distributed under the License is distributed on an |
13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | // KIND, either express or implied. See the License for the |
15 | // specific language governing permissions and limitations |
16 | // under the License. |
17 | |
18 | #ifndef ARROW_CSV_CONVERTER_H |
19 | #define ARROW_CSV_CONVERTER_H |
20 | |
21 | #include <cstdint> |
22 | #include <memory> |
23 | |
24 | #include "arrow/csv/options.h" |
25 | #include "arrow/util/macros.h" |
26 | #include "arrow/util/visibility.h" |
27 | |
28 | namespace arrow { |
29 | |
30 | class Array; |
31 | class DataType; |
32 | class MemoryPool; |
33 | class Status; |
34 | |
35 | namespace csv { |
36 | |
37 | class BlockParser; |
38 | |
39 | class ARROW_EXPORT Converter { |
40 | public: |
41 | Converter(const std::shared_ptr<DataType>& type, const ConvertOptions& options, |
42 | MemoryPool* pool); |
43 | virtual ~Converter() = default; |
44 | |
45 | virtual Status Convert(const BlockParser& parser, int32_t col_index, |
46 | std::shared_ptr<Array>* out) = 0; |
47 | |
48 | std::shared_ptr<DataType> type() const { return type_; } |
49 | |
50 | static Status Make(const std::shared_ptr<DataType>& type, const ConvertOptions& options, |
51 | std::shared_ptr<Converter>* out); |
52 | static Status Make(const std::shared_ptr<DataType>& type, const ConvertOptions& options, |
53 | MemoryPool* pool, std::shared_ptr<Converter>* out); |
54 | |
55 | protected: |
56 | ARROW_DISALLOW_COPY_AND_ASSIGN(Converter); |
57 | |
58 | virtual Status Initialize() = 0; |
59 | |
60 | const ConvertOptions options_; |
61 | MemoryPool* pool_; |
62 | std::shared_ptr<DataType> type_; |
63 | }; |
64 | |
65 | } // namespace csv |
66 | } // namespace arrow |
67 | |
68 | #endif // ARROW_CSV_CONVERTER_H |
69 | |