Skip to content

Commit

Permalink
[OPPRO-135] ArrowStream::getOutput swallows errors, and destructor do…
Browse files Browse the repository at this point in the history
…esn't release ArrowArrayStream (facebookincubator#16)

* ArrowStream::getOutput swallows errors

* Also, call release hook after ArrowArrayStream is used
  • Loading branch information
zhztheplayer authored and zhejiangxiaomai committed Feb 22, 2023
1 parent 886cb56 commit fad8d66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions velox/exec/ArrowStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ ArrowStream::~ArrowStream() {
close();
}

ArrowStream::~ArrowStream() {
if (!isFinished0()) {
close0();
}
}

RowVectorPtr ArrowStream::getOutput() {
// Get Arrow array.
struct ArrowArray arrowArray;

if (arrowStream_->get_next(arrowStream_.get(), &arrowArray)) {
if (arrowArray.release) {
arrowArray.release(&arrowArray);
Expand All @@ -52,6 +59,7 @@ RowVectorPtr ArrowStream::getOutput() {

// Get Arrow schema.
struct ArrowSchema arrowSchema;

if (arrowStream_->get_schema(arrowStream_.get(), &arrowSchema)) {
if (arrowSchema.release) {
arrowSchema.release(&arrowSchema);
Expand Down
7 changes: 7 additions & 0 deletions velox/exec/ArrowStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class ArrowStream : public SourceOperator {

virtual ~ArrowStream();

virtual ~ArrowStream();

RowVectorPtr getOutput() override;

BlockingReason isBlocked(ContinueFuture* /* unused */) override {
Expand All @@ -37,6 +39,7 @@ class ArrowStream : public SourceOperator {

bool isFinished() override;

bool isFinished() override;
void close() override;

private:
Expand All @@ -45,6 +48,10 @@ class ArrowStream : public SourceOperator {

bool finished_ = false;
std::shared_ptr<ArrowArrayStream> arrowStream_;

// For calls from destructor
bool isFinished0();
void close0();
};

} // namespace facebook::velox::exec

0 comments on commit fad8d66

Please sign in to comment.