File indexing completed on 2025-08-28 08:26:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include <cstdint>
0021 #include <memory>
0022
0023 #include "arrow/csv/options.h"
0024 #include "arrow/result.h"
0025 #include "arrow/type_fwd.h"
0026 #include "arrow/util/macros.h"
0027 #include "arrow/util/visibility.h"
0028
0029 namespace arrow {
0030 namespace csv {
0031
0032 class BlockParser;
0033
0034 class ARROW_EXPORT Converter {
0035 public:
0036 Converter(const std::shared_ptr<DataType>& type, const ConvertOptions& options,
0037 MemoryPool* pool);
0038 virtual ~Converter() = default;
0039
0040 virtual Result<std::shared_ptr<Array>> Convert(const BlockParser& parser,
0041 int32_t col_index) = 0;
0042
0043 std::shared_ptr<DataType> type() const { return type_; }
0044
0045
0046 static Result<std::shared_ptr<Converter>> Make(
0047 const std::shared_ptr<DataType>& type, const ConvertOptions& options,
0048 MemoryPool* pool = default_memory_pool());
0049
0050 protected:
0051 ARROW_DISALLOW_COPY_AND_ASSIGN(Converter);
0052
0053 virtual Status Initialize() = 0;
0054
0055
0056
0057 const ConvertOptions& options_;
0058 MemoryPool* pool_;
0059 std::shared_ptr<DataType> type_;
0060 };
0061
0062 class ARROW_EXPORT DictionaryConverter : public Converter {
0063 public:
0064 DictionaryConverter(const std::shared_ptr<DataType>& value_type,
0065 const ConvertOptions& options, MemoryPool* pool);
0066
0067
0068
0069 virtual void SetMaxCardinality(int32_t max_length) = 0;
0070
0071
0072
0073 static Result<std::shared_ptr<DictionaryConverter>> Make(
0074 const std::shared_ptr<DataType>& value_type, const ConvertOptions& options,
0075 MemoryPool* pool = default_memory_pool());
0076
0077 protected:
0078 std::shared_ptr<DataType> value_type_;
0079 };
0080
0081 }
0082 }