-
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.
- Loading branch information
Showing
15 changed files
with
266 additions
and
53 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
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
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,34 @@ | ||
#pragma once | ||
|
||
#include "processor/operator/copy_to/file_writer.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
class CSVFileWriter : public FileWriter { | ||
public: | ||
CSVFileWriter(const std::vector<std::string>& columnNames) : FileWriter(columnNames) {}; | ||
void openForWriting(const std::string& filePath); | ||
|
||
void add(const int64_t value); | ||
void add(const int32_t value); | ||
void add(const int16_t value); | ||
void add(const float value); | ||
void add(const double value); | ||
void add(const common::ku_string_t& value); | ||
void addEndl(); | ||
|
||
private: | ||
static constexpr int flushAfterLines = 10000; | ||
std::ofstream file; | ||
int64_t unflushedLines = 0; | ||
std::string line = ""; | ||
|
||
void add(std::string value); | ||
void addHeader(); | ||
void flush(); | ||
void addSeparator(char separator = ','); | ||
}; | ||
|
||
} // namespace processor | ||
} // namespace kuzu |
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,30 @@ | ||
#pragma once | ||
|
||
#include "common/copier_config/copier_config.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
class FileWriter { | ||
public: | ||
FileWriter(const std::vector<std::string>& columnNames) : columnNames{columnNames} {}; | ||
|
||
virtual void openForWriting(const std::string& filePath) = 0; | ||
|
||
virtual void add(const int64_t value) = 0; | ||
virtual void add(const int32_t value) = 0; | ||
virtual void add(const int16_t value) = 0; | ||
virtual void add(const float value) = 0; | ||
virtual void add(const double value) = 0; | ||
virtual void add(const common::ku_string_t& value) = 0; | ||
|
||
virtual void addEndl() = 0; | ||
|
||
inline const std::vector<std::string>& getColumnNames() const { return columnNames; } | ||
|
||
private: | ||
const std::vector<std::string>& columnNames; | ||
}; | ||
|
||
} // namespace processor | ||
} // namespace kuzu |
15 changes: 15 additions & 0 deletions
15
src/include/processor/operator/copy_to/file_writer_creator.h
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,15 @@ | ||
#pragma once | ||
|
||
#include "processor/operator/copy_to/file_writer.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
// Factory to return the instance of the file writer according to the required type | ||
class FileWriterCreator { | ||
public: | ||
static std::unique_ptr<FileWriter> create(common::CopyDescription::FileType fileType, const std::vector<std::string>& columnNames); | ||
}; | ||
|
||
} // namespace processor | ||
} // namespace kuzu |
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
Oops, something went wrong.