1 // Licensed to the Apache Software Foundation (ASF) under one 2 // or more contributor license agreements. See the NOTICE file 3 // distributed with this work for additional information 4 // regarding copyright ownership. The ASF licenses this file 5 // to you under the Apache License, Version 2.0 (the 6 // "License"); you may not use this file except in compliance 7 // with the License. You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, 12 // software distributed under the License is distributed on an 13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 // KIND, either express or implied. See the License for the 15 // specific language governing permissions and limitations 16 // under the License. 17 18 #include "arrow/visitor.h" 19 20 #include <memory> 21 22 #include "arrow/array.h" 23 #include "arrow/extension_type.h" 24 #include "arrow/scalar.h" 25 #include "arrow/status.h" 26 #include "arrow/type.h" 27 28 namespace arrow { 29 30 #define ARRAY_VISITOR_DEFAULT(ARRAY_CLASS) \ 31 Status ArrayVisitor::Visit(const ARRAY_CLASS& array) { \ 32 return Status::NotImplemented(array.type()->ToString()); \ 33 } 34 35 ARRAY_VISITOR_DEFAULT(NullArray) 36 ARRAY_VISITOR_DEFAULT(BooleanArray) 37 ARRAY_VISITOR_DEFAULT(Int8Array) 38 ARRAY_VISITOR_DEFAULT(Int16Array) 39 ARRAY_VISITOR_DEFAULT(Int32Array) 40 ARRAY_VISITOR_DEFAULT(Int64Array) 41 ARRAY_VISITOR_DEFAULT(UInt8Array) 42 ARRAY_VISITOR_DEFAULT(UInt16Array) 43 ARRAY_VISITOR_DEFAULT(UInt32Array) 44 ARRAY_VISITOR_DEFAULT(UInt64Array) 45 ARRAY_VISITOR_DEFAULT(HalfFloatArray) 46 ARRAY_VISITOR_DEFAULT(FloatArray) 47 ARRAY_VISITOR_DEFAULT(DoubleArray) 48 ARRAY_VISITOR_DEFAULT(BinaryArray) 49 ARRAY_VISITOR_DEFAULT(StringArray) 50 ARRAY_VISITOR_DEFAULT(LargeBinaryArray) 51 ARRAY_VISITOR_DEFAULT(LargeStringArray) 52 ARRAY_VISITOR_DEFAULT(FixedSizeBinaryArray) 53 ARRAY_VISITOR_DEFAULT(Date32Array) 54 ARRAY_VISITOR_DEFAULT(Date64Array) 55 ARRAY_VISITOR_DEFAULT(Time32Array) 56 ARRAY_VISITOR_DEFAULT(Time64Array) 57 ARRAY_VISITOR_DEFAULT(TimestampArray) 58 ARRAY_VISITOR_DEFAULT(DayTimeIntervalArray) 59 ARRAY_VISITOR_DEFAULT(MonthIntervalArray) 60 ARRAY_VISITOR_DEFAULT(DurationArray) 61 ARRAY_VISITOR_DEFAULT(ListArray) 62 ARRAY_VISITOR_DEFAULT(LargeListArray) 63 ARRAY_VISITOR_DEFAULT(MapArray) 64 ARRAY_VISITOR_DEFAULT(FixedSizeListArray) 65 ARRAY_VISITOR_DEFAULT(StructArray) 66 ARRAY_VISITOR_DEFAULT(UnionArray) 67 ARRAY_VISITOR_DEFAULT(DictionaryArray) 68 ARRAY_VISITOR_DEFAULT(Decimal128Array) 69 ARRAY_VISITOR_DEFAULT(ExtensionArray) 70 71 #undef ARRAY_VISITOR_DEFAULT 72 73 // ---------------------------------------------------------------------- 74 // Default implementations of TypeVisitor methods 75 76 #define TYPE_VISITOR_DEFAULT(TYPE_CLASS) \ 77 Status TypeVisitor::Visit(const TYPE_CLASS& type) { \ 78 return Status::NotImplemented(type.ToString()); \ 79 } 80 81 TYPE_VISITOR_DEFAULT(NullType) 82 TYPE_VISITOR_DEFAULT(BooleanType) 83 TYPE_VISITOR_DEFAULT(Int8Type) 84 TYPE_VISITOR_DEFAULT(Int16Type) 85 TYPE_VISITOR_DEFAULT(Int32Type) 86 TYPE_VISITOR_DEFAULT(Int64Type) 87 TYPE_VISITOR_DEFAULT(UInt8Type) 88 TYPE_VISITOR_DEFAULT(UInt16Type) 89 TYPE_VISITOR_DEFAULT(UInt32Type) 90 TYPE_VISITOR_DEFAULT(UInt64Type) 91 TYPE_VISITOR_DEFAULT(HalfFloatType) 92 TYPE_VISITOR_DEFAULT(FloatType) 93 TYPE_VISITOR_DEFAULT(DoubleType) 94 TYPE_VISITOR_DEFAULT(StringType) 95 TYPE_VISITOR_DEFAULT(BinaryType) 96 TYPE_VISITOR_DEFAULT(LargeStringType) 97 TYPE_VISITOR_DEFAULT(LargeBinaryType) 98 TYPE_VISITOR_DEFAULT(FixedSizeBinaryType) 99 TYPE_VISITOR_DEFAULT(Date64Type) 100 TYPE_VISITOR_DEFAULT(Date32Type) 101 TYPE_VISITOR_DEFAULT(Time32Type) 102 TYPE_VISITOR_DEFAULT(Time64Type) 103 TYPE_VISITOR_DEFAULT(TimestampType) 104 TYPE_VISITOR_DEFAULT(DayTimeIntervalType) 105 TYPE_VISITOR_DEFAULT(MonthIntervalType) 106 TYPE_VISITOR_DEFAULT(DurationType) 107 TYPE_VISITOR_DEFAULT(Decimal128Type) 108 TYPE_VISITOR_DEFAULT(ListType) 109 TYPE_VISITOR_DEFAULT(LargeListType) 110 TYPE_VISITOR_DEFAULT(MapType) 111 TYPE_VISITOR_DEFAULT(FixedSizeListType) 112 TYPE_VISITOR_DEFAULT(StructType) 113 TYPE_VISITOR_DEFAULT(UnionType) 114 TYPE_VISITOR_DEFAULT(DictionaryType) 115 TYPE_VISITOR_DEFAULT(ExtensionType) 116 117 #undef TYPE_VISITOR_DEFAULT 118 119 // ---------------------------------------------------------------------- 120 // Default implementations of ScalarVisitor methods 121 122 #define SCALAR_VISITOR_DEFAULT(SCALAR_CLASS) \ 123 Status ScalarVisitor::Visit(const SCALAR_CLASS& scalar) { \ 124 return Status::NotImplemented( \ 125 "ScalarVisitor not implemented for " ARROW_STRINGIFY(SCALAR_CLASS)); \ 126 } 127 128 SCALAR_VISITOR_DEFAULT(NullScalar) 129 SCALAR_VISITOR_DEFAULT(BooleanScalar) 130 SCALAR_VISITOR_DEFAULT(Int8Scalar) 131 SCALAR_VISITOR_DEFAULT(Int16Scalar) 132 SCALAR_VISITOR_DEFAULT(Int32Scalar) 133 SCALAR_VISITOR_DEFAULT(Int64Scalar) 134 SCALAR_VISITOR_DEFAULT(UInt8Scalar) 135 SCALAR_VISITOR_DEFAULT(UInt16Scalar) 136 SCALAR_VISITOR_DEFAULT(UInt32Scalar) 137 SCALAR_VISITOR_DEFAULT(UInt64Scalar) 138 SCALAR_VISITOR_DEFAULT(HalfFloatScalar) 139 SCALAR_VISITOR_DEFAULT(FloatScalar) 140 SCALAR_VISITOR_DEFAULT(DoubleScalar) 141 SCALAR_VISITOR_DEFAULT(StringScalar) 142 SCALAR_VISITOR_DEFAULT(BinaryScalar) 143 SCALAR_VISITOR_DEFAULT(LargeStringScalar) 144 SCALAR_VISITOR_DEFAULT(LargeBinaryScalar) 145 SCALAR_VISITOR_DEFAULT(FixedSizeBinaryScalar) 146 SCALAR_VISITOR_DEFAULT(Date64Scalar) 147 SCALAR_VISITOR_DEFAULT(Date32Scalar) 148 SCALAR_VISITOR_DEFAULT(Time32Scalar) 149 SCALAR_VISITOR_DEFAULT(Time64Scalar) 150 SCALAR_VISITOR_DEFAULT(TimestampScalar) 151 SCALAR_VISITOR_DEFAULT(DayTimeIntervalScalar) 152 SCALAR_VISITOR_DEFAULT(MonthIntervalScalar) 153 SCALAR_VISITOR_DEFAULT(DurationScalar) 154 SCALAR_VISITOR_DEFAULT(Decimal128Scalar) 155 SCALAR_VISITOR_DEFAULT(ListScalar) 156 SCALAR_VISITOR_DEFAULT(LargeListScalar) 157 SCALAR_VISITOR_DEFAULT(MapScalar) 158 SCALAR_VISITOR_DEFAULT(FixedSizeListScalar) 159 SCALAR_VISITOR_DEFAULT(StructScalar) 160 SCALAR_VISITOR_DEFAULT(DictionaryScalar) 161 162 #undef SCALAR_VISITOR_DEFAULT 163 164 } // namespace arrow 165