]>
Commit | Line | Data |
---|---|---|
1d09f67e TL |
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 | #pragma once | |
19 | ||
20 | #include <cstdint> | |
21 | #include <memory> | |
22 | #include <utility> | |
23 | ||
24 | #include "arrow/result.h" | |
25 | #include "arrow/type_fwd.h" | |
26 | #include "arrow/util/type_fwd.h" | |
27 | #include "arrow/util/visibility.h" | |
28 | ||
29 | namespace arrow { | |
30 | namespace csv { | |
31 | ||
32 | class BlockParser; | |
33 | struct ConvertOptions; | |
34 | ||
35 | class ARROW_EXPORT ColumnDecoder { | |
36 | public: | |
37 | virtual ~ColumnDecoder() = default; | |
38 | ||
39 | /// Spawn a task that will try to convert and insert the given CSV block | |
40 | virtual Future<std::shared_ptr<Array>> Decode( | |
41 | const std::shared_ptr<BlockParser>& parser) = 0; | |
42 | ||
43 | /// Construct a strictly-typed ColumnDecoder. | |
44 | static Result<std::shared_ptr<ColumnDecoder>> Make(MemoryPool* pool, | |
45 | std::shared_ptr<DataType> type, | |
46 | int32_t col_index, | |
47 | const ConvertOptions& options); | |
48 | ||
49 | /// Construct a type-inferring ColumnDecoder. | |
50 | /// Inference will run only on the first block, the type will be frozen afterwards. | |
51 | static Result<std::shared_ptr<ColumnDecoder>> Make(MemoryPool* pool, int32_t col_index, | |
52 | const ConvertOptions& options); | |
53 | ||
54 | /// Construct a ColumnDecoder for a column of nulls | |
55 | /// (i.e. not present in the CSV file). | |
56 | static Result<std::shared_ptr<ColumnDecoder>> MakeNull(MemoryPool* pool, | |
57 | std::shared_ptr<DataType> type); | |
58 | ||
59 | protected: | |
60 | ColumnDecoder() = default; | |
61 | }; | |
62 | ||
63 | } // namespace csv | |
64 | } // namespace arrow |