-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
49 changed files
with
3,608 additions
and
3,243 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <iostream> | ||
|
||
#include "binder/binder.h" | ||
#include "binder/copy/bound_import_database.h" | ||
#include "common/exception/binder.h" | ||
#include "parser/port_db.h" | ||
|
||
using namespace kuzu::common; | ||
using namespace kuzu::parser; | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
std::string getFilePath( | ||
common::VirtualFileSystem* vfs, const std::string boundFilePath, const std::string fileName) { | ||
auto filePath = vfs->joinPath(boundFilePath, fileName); | ||
if (!vfs->fileOrPathExists(filePath)) { | ||
throw BinderException(stringFormat("File {} does not exist.", filePath)); | ||
} | ||
auto fileInfo = vfs->openFile(filePath, O_RDONLY); | ||
auto fsize = fileInfo->getFileSize(); | ||
auto buffer = std::make_unique<char[]>(fsize); | ||
fileInfo->readFile(buffer.get(), fsize); | ||
return std::string(buffer.get(), fsize); | ||
} | ||
|
||
std::unique_ptr<BoundStatement> Binder::bindImportDatabaseClause(const Statement& statement) { | ||
auto& importDatabaseStatement = ku_dynamic_cast<const Statement&, const ImportDB&>(statement); | ||
auto boundFilePath = importDatabaseStatement.getFilePath(); | ||
if (!vfs->fileOrPathExists(boundFilePath)) { | ||
throw BinderException(stringFormat("Directory {} does not exist.", boundFilePath)); | ||
} | ||
std::string finalQueryStatements; | ||
finalQueryStatements += getFilePath(vfs, boundFilePath, ImportDBConstants::SCHEMA_NAME); | ||
finalQueryStatements += getFilePath(vfs, boundFilePath, ImportDBConstants::COPY_NAME); | ||
finalQueryStatements += getFilePath(vfs, boundFilePath, ImportDBConstants::MACRO_NAME); | ||
return std::make_unique<BoundImportDatabase>(boundFilePath, finalQueryStatements); | ||
} | ||
} // namespace binder | ||
} // 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
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,23 @@ | ||
#pragma once | ||
#include "binder/bound_statement.h" | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
class BoundImportDatabase : public BoundStatement { | ||
public: | ||
BoundImportDatabase(std::string filePath, std::string query) | ||
: BoundStatement{common::StatementType::IMPORT_DATABASE, | ||
BoundStatementResult::createEmptyResult()}, | ||
filePath{std::move(filePath)}, query{query} {} | ||
|
||
inline std::string getFilePath() const { return filePath; } | ||
inline std::string getQuery() const { return query; } | ||
|
||
private: | ||
std::string filePath; | ||
std::string query; | ||
}; | ||
|
||
} // namespace binder | ||
} // 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
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
29 changes: 29 additions & 0 deletions
29
src/include/planner/operator/persistent/logical_import_db.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,29 @@ | ||
#pragma once | ||
|
||
#include "planner/operator/logical_operator.h" | ||
|
||
namespace kuzu { | ||
namespace planner { | ||
|
||
class LogicalImportDatabase : public LogicalOperator { | ||
public: | ||
explicit LogicalImportDatabase(std::string query) | ||
: LogicalOperator{LogicalOperatorType::IMPORT_DATABASE}, query{query} {} | ||
|
||
inline std::string getExpressionsForPrinting() const override { return std::string{}; } | ||
|
||
void computeFactorizedSchema() override; | ||
void computeFlatSchema() override; | ||
|
||
inline std::string getQuery() const { return query; } | ||
|
||
inline std::unique_ptr<LogicalOperator> copy() override { | ||
return make_unique<LogicalImportDatabase>(query); | ||
} | ||
|
||
private: | ||
std::string query; | ||
}; | ||
|
||
} // namespace planner | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "common/copier_config/reader_config.h" | ||
#include "processor/operator/physical_operator.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
class ImportDB : public PhysicalOperator { | ||
public: | ||
ImportDB(std::string query, uint32_t id, const std::string& paramsString) | ||
: PhysicalOperator{PhysicalOperatorType::IMPORT_DATABASE, id, paramsString}, query{query} {} | ||
|
||
bool canParallel() const override { return false; } | ||
|
||
bool isSource() const override { return true; } | ||
|
||
bool getNextTuplesInternal(ExecutionContext* context) override; | ||
|
||
inline std::unique_ptr<PhysicalOperator> clone() override { | ||
return std::make_unique<ImportDB>(query, id, paramsString); | ||
} | ||
|
||
private: | ||
std::string query; | ||
}; | ||
} // 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.