Skip to content

Commit

Permalink
partial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell Liu committed Dec 18, 2023
1 parent 9ff0be3 commit 5915cb6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/common/arrow/arrow_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ std::unique_ptr<ArrowSchema> ArrowConverter::toArrowSchema(

void ArrowConverter::toArrowArray(
main::QueryResult& queryResult, ArrowArray* outArray, std::int64_t chunkSize) {
auto types = queryResult.getColumnDataTypes();
common::logical_types_t types;
for (auto type : queryResult.getColumnDataTypes()) {
types.push_back(std::make_unique<LogicalType>(type));
}
auto rowBatch = make_unique<ArrowRowBatch>(std::move(types), chunkSize);
*outArray = rowBatch->append(queryResult, chunkSize);
}
Expand Down
8 changes: 4 additions & 4 deletions src/common/arrow/arrow_row_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
namespace kuzu {
namespace common {

ArrowRowBatch::ArrowRowBatch(std::vector<LogicalType> types, std::int64_t capacity)
ArrowRowBatch::ArrowRowBatch(common::logical_types_t types, std::int64_t capacity)
: types{std::move(types)}, numTuples{0} {
auto numVectors = this->types.size();
vectors.resize(numVectors);
for (auto i = 0u; i < numVectors; i++) {
vectors[i] = createVector(this->types[i], capacity);
vectors[i] = createVector(*this->types[i], capacity);
}
}

Expand Down Expand Up @@ -762,7 +762,7 @@ ArrowArray ArrowRowBatch::toArray() {
result.dictionary = nullptr;
rootHolder->childData = std::move(vectors);
for (auto i = 0u; i < rootHolder->childData.size(); i++) {
rootHolder->childPointers[i] = convertVectorToArray(*rootHolder->childData[i], types[i]);
rootHolder->childPointers[i] = convertVectorToArray(*rootHolder->childData[i], *types[i]);
}
result.private_data = rootHolder.release();
result.release = releaseArrowVector;
Expand All @@ -778,7 +778,7 @@ ArrowArray ArrowRowBatch::append(main::QueryResult& queryResult, std::int64_t ch
}
auto tuple = queryResult.getNext();
for (auto i = 0u; i < numColumns; i++) {
appendValue(vectors[i].get(), types[i], tuple->getValue(i));
appendValue(vectors[i].get(), *types[i], tuple->getValue(i));
}
numTuplesInBatch++;
}
Expand Down
4 changes: 2 additions & 2 deletions src/include/common/arrow/arrow_row_batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ArrowVector {
// An arrow data chunk consisting of N rows in columnar format.
class ArrowRowBatch {
public:
ArrowRowBatch(std::vector<LogicalType> types, std::int64_t capacity);
ArrowRowBatch(common::logical_types_t types, std::int64_t capacity);

//! Append a data chunk to the underlying arrow array
ArrowArray append(main::QueryResult& queryResult, std::int64_t chunkSize);
Expand Down Expand Up @@ -80,7 +80,7 @@ class ArrowRowBatch {
ArrowArray toArray();

private:
std::vector<LogicalType> types;
common::logical_types_t types;
std::vector<std::unique_ptr<ArrowVector>> vectors;
std::int64_t numTuples;
};
Expand Down

0 comments on commit 5915cb6

Please sign in to comment.