|
|
|||
File indexing completed on 2026-04-17 08:28:54
0001 // Licensed to the Apache Software Foundation (ASF) under one 0002 // or more contributor license agreements. See the NOTICE file 0003 // distributed with this work for additional information 0004 // regarding copyright ownership. The ASF licenses this file 0005 // to you under the Apache License, Version 2.0 (the 0006 // "License"); you may not use this file except in compliance 0007 // with the License. You may obtain a copy of the License at 0008 // 0009 // http://www.apache.org/licenses/LICENSE-2.0 0010 // 0011 // Unless required by applicable law or agreed to in writing, 0012 // software distributed under the License is distributed on an 0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 0014 // KIND, either express or implied. See the License for the 0015 // specific language governing permissions and limitations 0016 // under the License. 0017 #pragma once 0018 0019 #include "arrow/util/bit_util.h" 0020 #include "arrow/util/endian.h" 0021 #include "parquet/level_comparison.h" 0022 0023 // Used to make sure ODR rule isn't violated. 0024 #ifndef PARQUET_IMPL_NAMESPACE 0025 # error "PARQUET_IMPL_NAMESPACE must be defined" 0026 #endif 0027 namespace parquet::internal::PARQUET_IMPL_NAMESPACE { 0028 /// Builds a bitmap by applying predicate to the level vector provided. 0029 /// 0030 /// \param[in] levels Rep or def level array. 0031 /// \param[in] num_levels The number of levels to process (must be [0, 64]) 0032 /// \param[in] predicate The predicate to apply (must have the signature `bool 0033 /// predicate(int16_t)`. 0034 /// \returns The bitmap using least significant "bit" ordering. 0035 /// 0036 template <typename Predicate> 0037 inline uint64_t LevelsToBitmap(const int16_t* levels, int64_t num_levels, 0038 Predicate predicate) { 0039 // Both clang and GCC can vectorize this automatically with SSE4/AVX2. 0040 uint64_t mask = 0; 0041 for (int x = 0; x < num_levels; x++) { 0042 mask |= static_cast<uint64_t>(predicate(levels[x]) ? 1 : 0) << x; 0043 } 0044 return ::arrow::bit_util::ToLittleEndian(mask); 0045 } 0046 0047 inline MinMax FindMinMaxImpl(const int16_t* levels, int64_t num_levels) { 0048 MinMax out{std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min()}; 0049 for (int x = 0; x < num_levels; x++) { 0050 out.min = std::min(levels[x], out.min); 0051 out.max = std::max(levels[x], out.max); 0052 } 0053 return out; 0054 } 0055 0056 inline uint64_t GreaterThanBitmapImpl(const int16_t* levels, int64_t num_levels, 0057 int16_t rhs) { 0058 return LevelsToBitmap(levels, num_levels, [rhs](int16_t value) { return value > rhs; }); 0059 } 0060 0061 } // namespace parquet::internal::PARQUET_IMPL_NAMESPACE
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|