-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract common
toSerializedPage
test function (#9462)
Summary: Refactors `toSerializedPage` function to add a common helper function for serializing `RowVector` to `PrestoPage` format, in file `SerializedPageUtil.cpp`. Pull Request resolved: #9462 Reviewed By: xiaoxmeng Differential Revision: D64872524 Pulled By: kagamiori fbshipit-source-id: b306f61cde1bb21b60a97d93efe9cefef7eca6a4
- Loading branch information
1 parent
2e381e4
commit fee04b8
Showing
6 changed files
with
78 additions
and
43 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
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,38 @@ | ||
/* | ||
* 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/tests/utils/SerializedPageUtil.h" | ||
|
||
using namespace facebook::velox; | ||
|
||
namespace facebook::velox::exec::test { | ||
|
||
std::unique_ptr<SerializedPage> toSerializedPage( | ||
const RowVectorPtr& vector, | ||
const std::shared_ptr<OutputBufferManager>& bufferManager, | ||
memory::MemoryPool* pool) { | ||
auto data = std::make_unique<VectorStreamGroup>(pool); | ||
auto size = vector->size(); | ||
auto range = IndexRange{0, size}; | ||
data->createStreamTree(asRowType(vector->type()), size); | ||
data->append(vector, folly::Range(&range, 1)); | ||
auto listener = bufferManager->newListener(); | ||
IOBufOutputStream stream(*pool, listener.get(), data->size()); | ||
data->flush(&stream); | ||
return std::make_unique<SerializedPage>(stream.getIOBuf(), nullptr, size); | ||
} | ||
|
||
} // namespace facebook::velox::exec::test |
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,31 @@ | ||
/* | ||
* 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. | ||
*/ | ||
#pragma once | ||
|
||
#include "velox/exec/ExchangeQueue.h" | ||
#include "velox/exec/OutputBufferManager.h" | ||
#include "velox/vector/ComplexVector.h" | ||
#include "velox/vector/VectorStream.h" | ||
|
||
namespace facebook::velox::exec::test { | ||
|
||
/// Helper function for serializing RowVector to PrestoPage format. | ||
std::unique_ptr<SerializedPage> toSerializedPage( | ||
const RowVectorPtr& vector, | ||
const std::shared_ptr<OutputBufferManager>& bufferManager, | ||
memory::MemoryPool* pool); | ||
|
||
} // namespace facebook::velox::exec::test |