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
6#include "copy_constructors.h"
7#include "value.h"
8
9namespace kuzu {
10namespace common {
11
12enum class FileType : uint8_t {
13 UNKNOWN = 0,
14 CSV = 1,
15 PARQUET = 2,
16 NPY = 3,
17 TURTLE = 4, // Terse triples http://www.w3.org/TR/turtle
18 NQUADS = 5, // Line-based quads http://www.w3.org/TR/n-quads/
19 NTRIPLES = 6, // Line-based triples http://www.w3.org/TR/n-triples/
20};
21
24 std::string fileTypeStr;
25};
26
28 static FileType getFileTypeFromExtension(std::string_view extension);
29 static std::string toString(FileType fileType);
30 static FileType fromString(std::string fileType);
31};
32
35 std::vector<std::string> filePaths;
36 std::unordered_map<std::string, Value> options;
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:41
FileType
Definition reader_config.h:12
Definition array_utils.h:7
Definition reader_config.h:22
std::string fileTypeStr
Definition reader_config.h:24
FileType fileType
Definition reader_config.h:23
Definition reader_config.h:27
static FileType getFileTypeFromExtension(std::string_view extension)
static FileType fromString(std::string fileType)
static std::string toString(FileType fileType)
Definition reader_config.h:33
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)
T getOption(std::string optionName, T defaultValue) const
Definition reader_config.h:50
std::unordered_map< std::string, Value > options
Definition reader_config.h:36
FileTypeInfo fileTypeInfo
Definition reader_config.h:34
ReaderConfig()
Definition reader_config.h:38
std::string getFilePath(idx_t fileIdx) const
Definition reader_config.h:44