Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aziz-mu committed Jun 21, 2023
1 parent 66edb07 commit dc8745b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/include/storage/copier/npy_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class NpyReader {
size_t dataOffset;
std::vector<size_t> shape;
common::LogicalTypeID type;
static inline const std::string defaultFieldName = "NPY_FIELD";
};

} // namespace storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class InMemColumnChunk {
inline uint64_t getNumBytesPerValue() const { return numBytesPerValue; }
inline uint64_t getNumBytes() const { return numBytes; }
inline InMemColumnChunk* getNullChunk() { return nullChunk.get(); }
void copyChunk(std::shared_ptr<arrow::RecordBatch> batch);
void copyArrowBatch(std::shared_ptr<arrow::RecordBatch> batch);
virtual void copyArrowArray(arrow::Array& arrowArray, arrow::Array* nodeOffsets = nullptr);
virtual void flush(common::FileInfo* walFileInfo);

Expand Down
4 changes: 2 additions & 2 deletions src/storage/copier/node_copier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ void NPYNodeCopier::executeInternal(std::unique_ptr<CopyMorsel> morsel) {
std::vector<std::unique_ptr<InMemColumnChunk>> columnChunks(1);
columnChunks[0] =
columns[columnToCopy]->getInMemColumnChunk(morsel->tupleIdx, endNodeOffset, &copyDesc);
auto chunk = reader->readBlock(morsel->blockIdx);
columnChunks[0]->copyChunk(chunk);
auto batch = reader->readBlock(morsel->blockIdx);
columnChunks[0]->copyArrowBatch(batch);
for (auto i = 0u; i < morsel->numTuples; i++) {
columnChunks[0]->setValueAtPos(reader->getPointerToRow(morsel->tupleIdx + i), i);
}
Expand Down
6 changes: 2 additions & 4 deletions src/storage/copier/npy_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,9 @@ std::shared_ptr<arrow::RecordBatch> NpyReader::readBlock(common::block_idx_t blo
auto buffer =
std::make_shared<arrow::Buffer>(rowPointer, CopyConstants::NUM_ROWS_PER_BLOCK_FOR_NPY);
auto arrowType = getArrowType();
int64_t length = CopyConstants::NUM_ROWS_PER_BLOCK_FOR_NPY < getNumRows() - rowNumber ?
CopyConstants::NUM_ROWS_PER_BLOCK_FOR_NPY :
getNumRows() - rowNumber;
int64_t length = std::min(CopyConstants::NUM_ROWS_PER_BLOCK_FOR_NPY, getNumRows() - rowNumber);
auto arr = std::make_shared<arrow::PrimitiveArray>(arrowType, length, buffer);
auto field = std::make_shared<arrow::Field>("name", arrowType);
auto field = std::make_shared<arrow::Field>(defaultFieldName, arrowType);
auto schema =
std::make_shared<arrow::Schema>(std::vector<std::shared_ptr<arrow::Field>>{field});
std::shared_ptr<arrow::RecordBatch> result;
Expand Down
5 changes: 3 additions & 2 deletions src/storage/in_mem_storage_structure/in_mem_column_chunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ uint32_t InMemColumnChunk::getDataTypeSizeInColumn(common::LogicalType& dataType
}
}

void InMemColumnChunk::copyChunk(std::shared_ptr<arrow::RecordBatch> batch) {
copyArrowArray(*batch->column(0), nullptr);
void InMemColumnChunk::copyArrowBatch(std::shared_ptr<arrow::RecordBatch> batch) {
assert(batch->num_columns() == 1);
copyArrowArray(*batch->column(0), nullptr /* nodeOffsets */);
}

void InMemColumnChunk::copyArrowArray(arrow::Array& arrowArray, arrow::Array* nodeOffsets) {
Expand Down

0 comments on commit dc8745b

Please sign in to comment.