|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once |
|
|
|
#include <cstdint> |
|
#include <memory> |
|
|
|
#include "arrow/csv/options.h" |
|
#include "arrow/result.h" |
|
#include "arrow/type_fwd.h" |
|
#include "arrow/util/macros.h" |
|
#include "arrow/util/visibility.h" |
|
|
|
namespace arrow { |
|
namespace csv { |
|
|
|
class BlockParser; |
|
|
|
class ARROW_EXPORT Converter { |
|
public: |
|
Converter(const std::shared_ptr<DataType>& type, const ConvertOptions& options, |
|
MemoryPool* pool); |
|
virtual ~Converter() = default; |
|
|
|
virtual Result<std::shared_ptr<Array>> Convert(const BlockParser& parser, |
|
int32_t col_index) = 0; |
|
|
|
std::shared_ptr<DataType> type() const { return type_; } |
|
|
|
|
|
static Result<std::shared_ptr<Converter>> Make( |
|
const std::shared_ptr<DataType>& type, const ConvertOptions& options, |
|
MemoryPool* pool = default_memory_pool()); |
|
|
|
protected: |
|
ARROW_DISALLOW_COPY_AND_ASSIGN(Converter); |
|
|
|
virtual Status Initialize() = 0; |
|
|
|
|
|
|
|
const ConvertOptions& options_; |
|
MemoryPool* pool_; |
|
std::shared_ptr<DataType> type_; |
|
}; |
|
|
|
class ARROW_EXPORT DictionaryConverter : public Converter { |
|
public: |
|
DictionaryConverter(const std::shared_ptr<DataType>& value_type, |
|
const ConvertOptions& options, MemoryPool* pool); |
|
|
|
|
|
|
|
virtual void SetMaxCardinality(int32_t max_length) = 0; |
|
|
|
|
|
|
|
static Result<std::shared_ptr<DictionaryConverter>> Make( |
|
const std::shared_ptr<DataType>& value_type, const ConvertOptions& options, |
|
MemoryPool* pool = default_memory_pool()); |
|
|
|
protected: |
|
std::shared_ptr<DataType> value_type_; |
|
}; |
|
|
|
} |
|
} |
|
|