|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +#include <cstdint> // For fixed-width integer types |
| 21 | + |
| 22 | +namespace fury { |
| 23 | +enum class TypeId : int32_t { |
| 24 | + // a boolean value (true or false). |
| 25 | + BOOL = 1, |
| 26 | + // a 8-bit signed integer. |
| 27 | + INT8 = 2, |
| 28 | + // a 16-bit signed integer. |
| 29 | + INT16 = 3, |
| 30 | + // a 32-bit signed integer. |
| 31 | + INT32 = 4, |
| 32 | + // a 32-bit signed integer which use fury var_int32 encoding. |
| 33 | + VAR_INT32 = 5, |
| 34 | + // a 64-bit signed integer. |
| 35 | + INT64 = 6, |
| 36 | + // a 64-bit signed integer which use fury PVL encoding. |
| 37 | + VAR_INT64 = 7, |
| 38 | + // a 64-bit signed integer which use fury SLI encoding. |
| 39 | + SLI_INT64 = 8, |
| 40 | + // a 16-bit floating point number. |
| 41 | + FLOAT16 = 9, |
| 42 | + // a 32-bit floating point number. |
| 43 | + FLOAT32 = 10, |
| 44 | + // a 64-bit floating point number including NaN and Infinity. |
| 45 | + FLOAT64 = 11, |
| 46 | + // a text string encoded using Latin1/UTF16/UTF-8 encoding. |
| 47 | + STRING = 12, |
| 48 | + // a data type consisting of a set of named values. Rust enum with |
| 49 | + // non-predefined field values are not supported as an enum |
| 50 | + ENUM = 13, |
| 51 | + // an enum whose value will be serialized as the registered name. |
| 52 | + NAMED_ENUM = 14, |
| 53 | + // a morphic(final) type serialized by Fury Struct serializer. i.e. it doesn't |
| 54 | + // have subclasses. Suppose we're |
| 55 | + // deserializing `List<SomeClass>`, we can save dynamic serializer dispatch |
| 56 | + // since `SomeClass` is morphic(final). |
| 57 | + STRUCT = 15, |
| 58 | + // a type which is not morphic(not final). i.e. it has subclasses. Suppose |
| 59 | + // we're deserializing |
| 60 | + // `List<SomeClass>`, we must dispatch serializer dynamically since |
| 61 | + // `SomeClass` is polymorphic(non-final). |
| 62 | + POLYMORPHIC_STRUCT = 16, |
| 63 | + // a morphic(final) type serialized by Fury compatible Struct serializer. |
| 64 | + COMPATIBLE_STRUCT = 17, |
| 65 | + // a non-morphic(non-final) type serialized by Fury compatible Struct |
| 66 | + // serializer. |
| 67 | + POLYMORPHIC_COMPATIBLE_STRUCT = 18, |
| 68 | + // a `struct` whose type mapping will be encoded as a name. |
| 69 | + NAMED_STRUCT = 19, |
| 70 | + // a `polymorphic_struct` whose type mapping will be encoded as a name. |
| 71 | + NAMED_POLYMORPHIC_STRUCT = 20, |
| 72 | + // a `compatible_struct` whose type mapping will be encoded as a name. |
| 73 | + NAMED_COMPATIBLE_STRUCT = 21, |
| 74 | + // a `polymorphic_compatible_struct` whose type mapping will be encoded as a |
| 75 | + // name. |
| 76 | + NAMED_POLYMORPHIC_COMPATIBLE_STRUCT = 22, |
| 77 | + // a type which will be serialized by a customized serializer. |
| 78 | + EXT = 23, |
| 79 | + // an `ext` type which is not morphic(not final). |
| 80 | + POLYMORPHIC_EXT = 24, |
| 81 | + // an `ext` type whose type mapping will be encoded as a name. |
| 82 | + NAMED_EXT = 25, |
| 83 | + // an `polymorphic_ext` type whose type mapping will be encoded as a name. |
| 84 | + NAMED_POLYMORPHIC_EXT = 26, |
| 85 | + // a sequence of objects. |
| 86 | + LIST = 27, |
| 87 | + // an unordered set of unique elements. |
| 88 | + SET = 28, |
| 89 | + // a map of key-value pairs. Mutable types such as |
| 90 | + // `list/map/set/array/tensor/arrow` are not allowed as key of map. |
| 91 | + MAP = 29, |
| 92 | + // an absolute length of time, independent of any calendar/timezone, as a |
| 93 | + // count of nanoseconds. |
| 94 | + DURATION = 30, |
| 95 | + // a point in time, independent of any calendar/timezone, as a count of |
| 96 | + // nanoseconds. The count is relative |
| 97 | + // to an epoch at UTC midnight on January 1, 1970. |
| 98 | + TIMESTAMP = 31, |
| 99 | + // a naive date without timezone. The count is days relative to an epoch at |
| 100 | + // UTC midnight on Jan 1, 1970. |
| 101 | + LOCAL_DATE = 32, |
| 102 | + // exact decimal value represented as an integer value in two's complement. |
| 103 | + DECIMAL = 33, |
| 104 | + // an variable-length array of bytes. |
| 105 | + BINARY = 34, |
| 106 | + // a multidimensional array which every sub-array can have different sizes but |
| 107 | + // all have same type. |
| 108 | + // only allow numeric components. Other arrays will be taken as List. The |
| 109 | + // implementation should support the |
| 110 | + // interoperability between array and list. |
| 111 | + ARRAY = 35, |
| 112 | + // one dimensional bool array. |
| 113 | + BOOL_ARRAY = 36, |
| 114 | + // one dimensional int16 array. |
| 115 | + INT8_ARRAY = 37, |
| 116 | + // one dimensional int16 array. |
| 117 | + INT16_ARRAY = 38, |
| 118 | + // one dimensional int32 array. |
| 119 | + INT32_ARRAY = 39, |
| 120 | + // one dimensional int64 array. |
| 121 | + INT64_ARRAY = 40, |
| 122 | + // one dimensional half_float_16 array. |
| 123 | + FLOAT16_ARRAY = 41, |
| 124 | + // one dimensional float32 array. |
| 125 | + FLOAT32_ARRAY = 42, |
| 126 | + // one dimensional float64 array. |
| 127 | + FLOAT64_ARRAY = 43, |
| 128 | + // an arrow [record |
| 129 | + // batch](https://arrow.apache.org/docs/cpp/tables.html#record-batches) |
| 130 | + // object. |
| 131 | + ARROW_RECORD_BATCH = 44, |
| 132 | + // an arrow [table](https://arrow.apache.org/docs/cpp/tables.html#tables) |
| 133 | + // object. |
| 134 | + ARROW_TABLE = 45, |
| 135 | + BOUND = 64 |
| 136 | +}; |
| 137 | + |
| 138 | +inline bool IsNamespacedType(int32_t type_id) { |
| 139 | + switch (static_cast<TypeId>(type_id)) { |
| 140 | + case TypeId::NAMED_ENUM: |
| 141 | + case TypeId::NAMED_STRUCT: |
| 142 | + case TypeId::NAMED_POLYMORPHIC_STRUCT: |
| 143 | + case TypeId::NAMED_COMPATIBLE_STRUCT: |
| 144 | + case TypeId::NAMED_POLYMORPHIC_COMPATIBLE_STRUCT: |
| 145 | + case TypeId::NAMED_EXT: |
| 146 | + case TypeId::NAMED_POLYMORPHIC_EXT: |
| 147 | + return true; |
| 148 | + default: |
| 149 | + return false; |
| 150 | + } |
| 151 | +} |
| 152 | + |
| 153 | +} // namespace fury |
0 commit comments