MCPcopy Create free account
hub / github.com/bytedance/bolt / toCacheIndex

Function toCacheIndex

bolt/vector/VectorPool.cpp:39–63  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

37/// corresponding TypePool cache in VectorPool::vectors_ array. Return -1 if
38/// type is not supported, i.e. not a built-in singleton type.
39FOLLY_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
66VectorPtr VectorPool::get(const TypePtr& type, vector_size_t size) {

Callers 2

getMethod · 0.85
releaseMethod · 0.85

Calls 2

getMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected