Kùzu C++ API
Loading...
Searching...
No Matches
reader_config.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
7#include "copy_constructors.h"
8#include "value.h"
9
10namespace kuzu {
11namespace common {
12
13enum class FileType : uint8_t {
14 UNKNOWN = 0,
15 CSV = 1,
16 PARQUET = 2,
17 NPY = 3,
18};
19
24
26 static FileType getFileTypeFromExtension(std::string_view extension);
27 static std::string toString(FileType fileType);
28 static FileType fromString(std::string fileType);
29};
30
32 static constexpr const char* FILE_FORMAT_OPTION_NAME = "FILE_FORMAT";
33
35 std::vector<std::string> filePaths;
37
40 : fileTypeInfo{std::move(fileTypeInfo)}, filePaths{std::move(filePaths)} {}
42
43 uint32_t getNumFiles() const { return filePaths.size(); }
44 std::string getFilePath(idx_t fileIdx) const {
45 KU_ASSERT(fileIdx < getNumFiles());
46 return filePaths[fileIdx];
47 }
48
49 template<typename T>
50 T getOption(std::string optionName, T defaultValue) const {
51 const auto optionIt = options.find(optionName);
52 if (optionIt != options.end()) {
53 return optionIt->second.getValue<T>();
54 } else {
55 return defaultValue;
56 }
57 }
58
59private:
60 ReaderConfig(const ReaderConfig& other)
62};
63
64} // namespace common
65} // namespace kuzu
#define KU_ASSERT(condition)
Definition assert.h:19
uint32_t idx_t
Definition types.h:44
FileType
Definition reader_config.h:13
std::unordered_map< std::string, T, CaseInsensitiveStringHashFunction, CaseInsensitiveStringEquality > case_insensitive_map_t
Definition case_insensitive_map.h:22
Definition array_utils.h:7
Definition reader_config.h:20
std::string fileTypeStr
Definition reader_config.h:22
FileType fileType
Definition reader_config.h:21
Definition reader_config.h:25
static FileType getFileTypeFromExtension(std::string_view extension)
static FileType fromString(std::string fileType)
static std::string toString(FileType fileType)
Definition reader_config.h:31
ReaderConfig(FileTypeInfo fileTypeInfo, std::vector< std::string > filePaths)
Definition reader_config.h:39
uint32_t getNumFiles() const
Definition reader_config.h:43
std::vector< std::string > filePaths
Definition reader_config.h:35
EXPLICIT_COPY_DEFAULT_MOVE(ReaderConfig)
static constexpr const char * FILE_FORMAT_OPTION_NAME
Definition reader_config.h:32
T getOption(std::string optionName, T defaultValue) const
Definition reader_config.h:50
FileTypeInfo fileTypeInfo
Definition reader_config.h:34
case_insensitive_map_t< Value > options
Definition reader_config.h:36
ReaderConfig()
Definition reader_config.h:38
std::string getFilePath(idx_t fileIdx) const
Definition reader_config.h:44