Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:25:44

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 
0018 #pragma once
0019 
0020 #include <cstdint>
0021 #include <type_traits>
0022 #include <utility>
0023 
0024 #include "arrow/util/macros.h"
0025 #include "parquet/exception.h"
0026 #include "parquet/types.h"
0027 
0028 namespace parquet {
0029 
0030 #define TYPE_VISIT_INLINE(TYPE_VALUE)                                                 \
0031   case Type::TYPE_VALUE: {                                                            \
0032     const PhysicalType<Type::TYPE_VALUE>* concrete_ptr = NULLPTR;                     \
0033     return std::forward<VISITOR>(visitor)(concrete_ptr, std::forward<ARGS>(args)...); \
0034   }
0035 
0036 /// \brief Call `visitor` with a nullptr of the corresponding concrete type class
0037 /// \tparam ARGS Additional arguments, if any, will be passed to the visitor after
0038 /// the type argument
0039 ///
0040 /// The intent is for this to be called on a generic lambda
0041 /// that may internally use `if constexpr` or similar constructs.
0042 template <typename VISITOR, typename... ARGS>
0043 auto VisitType(Type::type type, VISITOR&& visitor, ARGS&&... args)
0044     -> decltype(std::forward<VISITOR>(visitor)(std::declval<PhysicalType<Type::INT32>*>(),
0045                                                args...)) {
0046   switch (type) {
0047     TYPE_VISIT_INLINE(INT32)
0048     TYPE_VISIT_INLINE(INT64)
0049     TYPE_VISIT_INLINE(INT96)
0050     TYPE_VISIT_INLINE(FLOAT)
0051     TYPE_VISIT_INLINE(DOUBLE)
0052     TYPE_VISIT_INLINE(FIXED_LEN_BYTE_ARRAY)
0053     TYPE_VISIT_INLINE(BYTE_ARRAY)
0054     TYPE_VISIT_INLINE(BOOLEAN)
0055     default:
0056       throw ParquetException("Invalid Type::type");
0057   }
0058 }
0059 
0060 #undef TYPE_VISIT_INLINE
0061 
0062 }  // namespace parquet