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.
Seperate prefix-sort encoder testing methods into test utils (faceboo…
…kincubator#8494) Summary: Seperate testing method into test utils, changes: 1. Added a separate 'utils' directory in prefixsort/tests to put some methods commonly used by ut and benchmark. 2. Move test methods from PrefixSortEncoder.h to prefixsort/tests/utils. Pull Request resolved: facebookincubator#8494 Reviewed By: xiaoxmeng Differential Revision: D53207878 Pulled By: mbasmanova fbshipit-source-id: 2f2d2011a5042a9694debb707ede59e6e504a06b
- Loading branch information
1 parent
5b8b4bd
commit e68d502
Showing
9 changed files
with
109 additions
and
34 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
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,17 @@ | ||
# 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. | ||
|
||
add_library(velox_exec_prefixsort_test_lib EncoderTestUtils.cpp) | ||
|
||
target_link_libraries(velox_exec_prefixsort_test_lib velox_vector_test_lib) |
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,45 @@ | ||
/* | ||
* 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/prefixsort/tests/utils/EncoderTestUtils.h" | ||
|
||
namespace facebook::velox::exec::prefixsort::test { | ||
|
||
namespace { | ||
|
||
/// The decode method will only be used in testing scenarios. In production | ||
/// code, we have no scenarios that require decoding a normalized key. | ||
void decodeNoNulls(char* encoded, int64_t& value) { | ||
value = *reinterpret_cast<uint64_t*>(encoded); | ||
value = __builtin_bswap64(value ^ 128); | ||
} | ||
|
||
} // namespace | ||
|
||
void encodeInPlace(std::vector<int64_t>& data) { | ||
for (auto i = 0; i < data.size(); i++) { | ||
PrefixSortEncoder::encode( | ||
data[i], (char*)data.data() + i * sizeof(int64_t)); | ||
} | ||
} | ||
|
||
void decodeInPlace(std::vector<int64_t>& data) { | ||
for (auto i = 0; i < data.size(); i++) { | ||
decodeNoNulls((char*)data.data() + i * sizeof(int64_t), data[i]); | ||
} | ||
} | ||
|
||
} // namespace facebook::velox::exec::prefixsort::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/prefixsort/PrefixSortEncoder.h" | ||
|
||
namespace facebook::velox::exec::prefixsort::test { | ||
|
||
/// Replace the elements in data with encoded ones(compatible with sorting in | ||
/// ascending order), assuming that the elements in data are all non-null. | ||
void encodeInPlace(std::vector<int64_t>& data); | ||
|
||
/// Replace the elements in data with decoded ones, assuming that the elements | ||
/// in data are all non-null and encoded(compatible with sorting in ascending | ||
/// order). | ||
void decodeInPlace(std::vector<int64_t>& data); | ||
|
||
} // namespace facebook::velox::exec::prefixsort::test |