forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ba3cd9
commit 3b3b616
Showing
7 changed files
with
184 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "velox/exec/ArrowStream.h" | ||
|
||
namespace facebook::velox::exec { | ||
|
||
ArrowStream::ArrowStream( | ||
int32_t operatorId, | ||
DriverCtx* driverCtx, | ||
std::shared_ptr<const core::ArrowStreamNode> arrowStream) | ||
: SourceOperator( | ||
driverCtx, | ||
arrowStream->outputType(), | ||
operatorId, | ||
arrowStream->id(), | ||
"Arrow Stream") { | ||
arrowStream_ = arrowStream->arrowStream(); | ||
} | ||
|
||
RowVectorPtr ArrowStream::getOutput() { | ||
struct ArrowArray arrowArray; | ||
arrowStream_->get_next(&(*arrowStream_), &arrowArray); | ||
if (arrowArray.release == NULL) { | ||
// End of Stream. | ||
closed_ = true; | ||
return nullptr; | ||
} | ||
struct ArrowSchema arrowSchema; | ||
arrowStream_->get_schema(&(*arrowStream_), &arrowSchema); | ||
// Convert Arrow data into RowVector. | ||
rowVector_ = std::dynamic_pointer_cast<RowVector>( | ||
facebook::velox::importFromArrowAsViewer(arrowSchema, arrowArray)); | ||
return rowVector_; | ||
} | ||
|
||
void ArrowStream::close() { | ||
closed_ = true; | ||
} | ||
|
||
bool ArrowStream::isFinished() { | ||
return closed_; | ||
} | ||
|
||
} // namespace facebook::velox::exec |
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,51 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "velox/core/PlanNode.h" | ||
#include "velox/exec/Operator.h" | ||
|
||
#include "velox/vector/arrow/Abi.h" | ||
|
||
namespace facebook::velox::exec { | ||
|
||
class ArrowStream : public SourceOperator { | ||
public: | ||
ArrowStream( | ||
int32_t operatorId, | ||
DriverCtx* driverCtx, | ||
std::shared_ptr<const core::ArrowStreamNode> arrowStream); | ||
|
||
RowVectorPtr getOutput() override; | ||
|
||
BlockingReason isBlocked(ContinueFuture* /* unused */) override { | ||
return BlockingReason::kNotBlocked; | ||
} | ||
|
||
void noMoreInput() override { | ||
Operator::noMoreInput(); | ||
close(); | ||
} | ||
|
||
bool isFinished() override; | ||
|
||
void close() override; | ||
|
||
private: | ||
bool closed_ = false; | ||
RowVectorPtr rowVector_; | ||
std::shared_ptr<ArrowArrayStream> arrowStream_; | ||
}; | ||
|
||
} // namespace facebook::velox::exec |
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