Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-27 08:47:24

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 "arrow/array.h"
0021 #include "arrow/extension_type.h"
0022 #include "arrow/visitor_generate.h"
0023 
0024 namespace arrow {
0025 
0026 #define ARRAY_VISIT_INLINE(TYPE_CLASS)                                                   \
0027   case TYPE_CLASS##Type::type_id:                                                        \
0028     return visitor->Visit(                                                               \
0029         internal::checked_cast<const typename TypeTraits<TYPE_CLASS##Type>::ArrayType&>( \
0030             array),                                                                      \
0031         std::forward<ARGS>(args)...);
0032 
0033 /// \brief Apply the visitors Visit() method specialized to the array type
0034 ///
0035 /// \tparam VISITOR Visitor type that implements Visit() for all array types.
0036 /// \tparam ARGS Additional arguments, if any, will be passed to the Visit function after
0037 /// the `arr` argument
0038 /// \return Status
0039 ///
0040 /// A visitor is a type that implements specialized logic for each Arrow type.
0041 /// Example usage:
0042 ///
0043 /// ```
0044 /// class ExampleVisitor {
0045 ///   arrow::Status Visit(arrow::NumericArray<Int32Type> arr) { ... }
0046 ///   arrow::Status Visit(arrow::NumericArray<Int64Type> arr) { ... }
0047 ///   ...
0048 /// }
0049 /// ExampleVisitor visitor;
0050 /// VisitArrayInline(some_array, &visitor);
0051 /// ```
0052 template <typename VISITOR, typename... ARGS>
0053 inline Status VisitArrayInline(const Array& array, VISITOR* visitor, ARGS&&... args) {
0054   switch (array.type_id()) {
0055     ARROW_GENERATE_FOR_ALL_TYPES(ARRAY_VISIT_INLINE);
0056     default:
0057       break;
0058   }
0059   return Status::NotImplemented("Type not implemented");
0060 }
0061 
0062 #undef ARRAY_VISIT_INLINE
0063 
0064 }  // namespace arrow