-
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.
refactor(parquet): Move arrow levelComparison to parquet common
- Loading branch information
1 parent
ac5c15e
commit 3205afa
Showing
30 changed files
with
146 additions
and
338 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,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/LICENSE2.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. | ||
*/ | ||
|
||
// Adapted from Apache Arrow. | ||
|
||
#include "velox/dwio/parquet/common/LevelComparison.h" | ||
#include "arrow/util/endian.h" | ||
|
||
namespace facebook::velox::parquet { | ||
namespace { | ||
template <typename Predicate> | ||
inline uint64_t | ||
LevelsToBitmap(const int16_t* levels, int64_t numLevels, Predicate predicate) { | ||
// Both clang and GCC can vectorize this automatically with SSE4/AVX2. | ||
uint64_t mask = 0; | ||
for (int x = 0; x < numLevels; x++) { | ||
mask |= static_cast<uint64_t>(predicate(levels[x]) ? 1 : 0) << x; | ||
} | ||
return ::arrow::bit_util::ToLittleEndian(mask); | ||
} | ||
|
||
inline MinMax FindMinMaxImpl(const int16_t* levels, int64_t numLevels) { | ||
MinMax out{ | ||
std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min()}; | ||
for (int x = 0; x < numLevels; x++) { | ||
out.min = std::min(levels[x], out.min); | ||
out.max = std::max(levels[x], out.max); | ||
} | ||
return out; | ||
} | ||
|
||
} // namespace | ||
|
||
uint64_t | ||
GreaterThanBitmap(const int16_t* levels, int64_t numLevels, int16_t rhs) { | ||
return LevelsToBitmap( | ||
levels, numLevels, [rhs](int16_t value) { return value > rhs; }); | ||
} | ||
|
||
MinMax FindMinMax(const int16_t* levels, int64_t numLevels) { | ||
return FindMinMaxImpl(levels, numLevels); | ||
} | ||
|
||
} // namespace facebook::velox::parquet |
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
Oops, something went wrong.