Checks if specified type is supported and returns an index of the corresponding TypePool cache in VectorPool::vectors_ array. Return -1 if type is not supported, i.e. not a built-in singleton type.
| 37 | /// corresponding TypePool cache in VectorPool::vectors_ array. Return -1 if |
| 38 | /// type is not supported, i.e. not a built-in singleton type. |
| 39 | FOLLY_ALWAYS_INLINE int32_t toCacheIndex(const TypePtr& type) { |
| 40 | static constexpr int32_t kNumCachedVectorTypes = |
| 41 | static_cast<int32_t>(TypeKind::HUGEINT) + 1; |
| 42 | |
| 43 | static std::array<const Type*, kNumCachedVectorTypes> kSupportedTypes = { |
| 44 | BOOLEAN().get(), |
| 45 | TINYINT().get(), |
| 46 | SMALLINT().get(), |
| 47 | INTEGER().get(), |
| 48 | BIGINT().get(), |
| 49 | REAL().get(), |
| 50 | DOUBLE().get(), |
| 51 | VARCHAR().get(), |
| 52 | VARBINARY().get(), |
| 53 | TIMESTAMP().get(), |
| 54 | DATE().get(), |
| 55 | }; |
| 56 | |
| 57 | auto index = static_cast<int32_t>(type->kind()); |
| 58 | if (index < kNumCachedVectorTypes && kSupportedTypes[index] == type.get()) { |
| 59 | return index; |
| 60 | } |
| 61 | |
| 62 | return -1; |
| 63 | } |
| 64 | } // namespace |
| 65 | |
| 66 | VectorPtr VectorPool::get(const TypePtr& type, vector_size_t size) { |