-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1341 from kuzudb/remove-csv-reader
Remove csv reader
- Loading branch information
Showing
14 changed files
with
169 additions
and
530 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
add_library(kuzu_common_copier_config | ||
OBJECT | ||
copier_config.cpp) | ||
|
||
set(ALL_OBJECT_FILES | ||
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_common_copier_config> | ||
PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include "common/copier_config/copier_config.h" | ||
|
||
#include "common/constants.h" | ||
#include "common/type_utils.h" | ||
#include "common/utils.h" | ||
#include "spdlog/spdlog.h" | ||
#include "utf8proc_wrapper.h" | ||
|
||
using namespace kuzu::utf8proc; | ||
|
||
namespace kuzu { | ||
namespace common { | ||
CopyDescription::CopyDescription(const std::string& filePath, CSVReaderConfig csvReaderConfig) | ||
: filePath{filePath}, csvReaderConfig{nullptr}, fileType{FileType::CSV} { | ||
setFileType(filePath); | ||
if (fileType == FileType::CSV) { | ||
this->csvReaderConfig = std::make_unique<CSVReaderConfig>(csvReaderConfig); | ||
} | ||
} | ||
|
||
CopyDescription::CopyDescription(const CopyDescription& copyDescription) | ||
: filePath{copyDescription.filePath}, csvReaderConfig{nullptr}, fileType{ | ||
copyDescription.fileType} { | ||
if (fileType == FileType::CSV) { | ||
this->csvReaderConfig = std::make_unique<CSVReaderConfig>(*copyDescription.csvReaderConfig); | ||
} | ||
} | ||
|
||
std::string CopyDescription::getFileTypeName(FileType fileType) { | ||
switch (fileType) { | ||
case FileType::CSV: | ||
return "csv"; | ||
|
||
case FileType::ARROW: | ||
return "arrow"; | ||
|
||
case FileType::PARQUET: | ||
return "parquet"; | ||
} | ||
} | ||
|
||
std::string CopyDescription::getFileTypeSuffix(FileType fileType) { | ||
return "." + getFileTypeName(fileType); | ||
} | ||
|
||
void CopyDescription::setFileType(std::string const& fileName) { | ||
auto csvSuffix = getFileTypeSuffix(FileType::CSV); | ||
auto arrowSuffix = getFileTypeSuffix(FileType::ARROW); | ||
auto parquetSuffix = getFileTypeSuffix(FileType::PARQUET); | ||
|
||
if (fileName.length() >= csvSuffix.length()) { | ||
if (!fileName.compare( | ||
fileName.length() - csvSuffix.length(), csvSuffix.length(), csvSuffix)) { | ||
fileType = FileType::CSV; | ||
return; | ||
} | ||
} | ||
|
||
if (fileName.length() >= arrowSuffix.length()) { | ||
if (!fileName.compare( | ||
fileName.length() - arrowSuffix.length(), arrowSuffix.length(), arrowSuffix)) { | ||
fileType = FileType::ARROW; | ||
return; | ||
} | ||
} | ||
|
||
if (fileName.length() >= parquetSuffix.length()) { | ||
if (!fileName.compare(fileName.length() - parquetSuffix.length(), parquetSuffix.length(), | ||
parquetSuffix)) { | ||
fileType = FileType::PARQUET; | ||
return; | ||
} | ||
} | ||
|
||
throw CopyException("Unsupported file type: " + fileName); | ||
} | ||
|
||
} // namespace common | ||
} // namespace kuzu |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.