-
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.
rework copy npy to integrate with query processor pipeline
- Loading branch information
Showing
29 changed files
with
483 additions
and
323 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#pragma once | ||
|
||
#include <mutex> | ||
|
||
#include "client_context.h" | ||
#include "database.h" | ||
#include "prepared_statement.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
1 change: 1 addition & 0 deletions
1
src/include/planner/logical_plan/logical_operator/logical_create_table.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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#pragma once | ||
|
||
#include "catalog/catalog_structs.h" | ||
#include "logical_ddl.h" | ||
|
||
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 was deleted.
Oops, something went wrong.
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,57 @@ | ||
#pragma once | ||
|
||
#include "processor/operator/copy/copy_node.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
struct CopyNPYNodeLocalState : public CopyNodeLocalState { | ||
public: | ||
CopyNPYNodeLocalState(const common::CopyDescription& copyDesc, storage::NodeTable* table, | ||
storage::RelsStore* relsStore, catalog::Catalog* catalog, storage::WAL* wal, | ||
const DataPos& offsetVectorPos, const DataPos& columnIdxPos, | ||
std::vector<DataPos> arrowColumnPoses) | ||
: CopyNodeLocalState{copyDesc, table, relsStore, catalog, wal, offsetVectorPos, | ||
std::move(arrowColumnPoses)}, | ||
columnIdxPos{columnIdxPos}, columnIdxVector{nullptr} {} | ||
|
||
DataPos columnIdxPos; | ||
common::ValueVector* columnIdxVector; | ||
}; | ||
|
||
class CopyNPYNode : public CopyNode { | ||
public: | ||
CopyNPYNode(std::unique_ptr<CopyNPYNodeLocalState> localState, | ||
std::shared_ptr<CopyNodeSharedState> sharedState, | ||
std::unique_ptr<ResultSetDescriptor> resultSetDescriptor, | ||
std::unique_ptr<PhysicalOperator> child, uint32_t id, const std::string& paramsString) | ||
: CopyNode{std::move(localState), std::move(sharedState), std::move(resultSetDescriptor), | ||
std::move(child), id, paramsString} {} | ||
|
||
void executeInternal(ExecutionContext* context) final; | ||
|
||
inline void initLocalStateInternal(ResultSet* resultSet, ExecutionContext* context) final { | ||
auto npyLocalState = (CopyNPYNodeLocalState*)localState.get(); | ||
npyLocalState->offsetVector = | ||
resultSet->getValueVector(npyLocalState->offsetVectorPos).get(); | ||
npyLocalState->columnIdxVector = | ||
resultSet->getValueVector(npyLocalState->columnIdxPos).get(); | ||
for (auto& arrowColumnPos : npyLocalState->arrowColumnPoses) { | ||
npyLocalState->arrowColumnVectors.push_back( | ||
resultSet->getValueVector(arrowColumnPos).get()); | ||
} | ||
} | ||
|
||
void flushChunksAndPopulatePKIndexSingleColumn( | ||
std::vector<std::unique_ptr<storage::InMemColumnChunk>>& columnChunks, | ||
common::offset_t startNodeOffset, common::offset_t endNodeOffset, int64_t columnToCopy); | ||
|
||
inline std::unique_ptr<PhysicalOperator> clone() override { | ||
return std::make_unique<CopyNPYNode>( | ||
std::make_unique<CopyNPYNodeLocalState>((CopyNPYNodeLocalState&)*localState), | ||
sharedState, resultSetDescriptor->copy(), children[0]->clone(), id, paramsString); | ||
} | ||
}; | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#pragma once | ||
|
||
#include "processor/operator/copy/read_file.h" | ||
#include "storage/copier/npy_reader.h" | ||
#include "storage/in_mem_storage_structure/in_mem_column.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
class ReadNPYMorsel : public ReadFileMorsel { | ||
public: | ||
ReadNPYMorsel(common::offset_t nodeOffset, common::block_idx_t blockIdx, uint64_t numNodes, | ||
std::string filePath, common::vector_idx_t curFileIdx) | ||
: ReadFileMorsel{nodeOffset, blockIdx, numNodes, std::move(filePath)}, columnIdx{ | ||
curFileIdx} {} | ||
|
||
inline common::vector_idx_t getColumnIdx() const { return columnIdx; } | ||
|
||
private: | ||
common::vector_idx_t columnIdx; | ||
}; | ||
|
||
class ReadNPYSharedState : public ReadFileSharedState { | ||
public: | ||
ReadNPYSharedState(catalog::NodeTableSchema* tableSchema, std::vector<std::string> filePaths) | ||
: ReadFileSharedState{std::move(filePaths), tableSchema} {} | ||
|
||
std::unique_ptr<ReadFileMorsel> getMorsel() final; | ||
|
||
private: | ||
void countNumLines() override; | ||
}; | ||
|
||
class ReadNPY : public ReadFile { | ||
public: | ||
ReadNPY(std::vector<DataPos> arrowColumnPoses, DataPos offsetVectorPos, DataPos columnIdxPos, | ||
std::shared_ptr<ReadFileSharedState> sharedState, uint32_t id, | ||
const std::string& paramsString) | ||
: ReadFile{std::move(arrowColumnPoses), std::move(offsetVectorPos), std::move(sharedState), | ||
PhysicalOperatorType::READ_NPY, id, paramsString}, | ||
columnIdxPos{columnIdxPos} {} | ||
|
||
std::shared_ptr<arrow::RecordBatch> readTuples(std::unique_ptr<ReadFileMorsel> morsel) override; | ||
|
||
bool getNextTuplesInternal(ExecutionContext* context) final; | ||
|
||
void initLocalStateInternal(ResultSet* resultSet, ExecutionContext* context) final; | ||
|
||
inline std::unique_ptr<PhysicalOperator> clone() override { | ||
return std::make_unique<ReadNPY>( | ||
arrowColumnPoses, offsetVectorPos, columnIdxPos, sharedState, id, paramsString); | ||
} | ||
|
||
private: | ||
std::unique_ptr<storage::NpyReader> reader; | ||
DataPos columnIdxPos; | ||
common::ValueVector* columnIdxVector; | ||
}; | ||
|
||
} // 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 was deleted.
Oops, something went wrong.
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.