| 114 | } |
| 115 | |
| 116 | VectorPtr VectorPool::TypePool::pop( |
| 117 | const TypePtr& type, |
| 118 | vector_size_t vectorSize, |
| 119 | memory::MemoryPool& pool) { |
| 120 | if (size) { |
| 121 | auto result = std::move(vectors[--size]); |
| 122 | if (UNLIKELY(result->rawNulls() != nullptr)) { |
| 123 | // This is a recyclable vector, no need to check uniqueness. |
| 124 | simd::memset( |
| 125 | const_cast<uint64_t*>(result->rawNulls()), |
| 126 | bits::kNotNullByte, |
| 127 | bits::roundUp(std::min<int32_t>(vectorSize, result->size()), 64) / 8); |
| 128 | } |
| 129 | if (UNLIKELY( |
| 130 | result->typeKind() == TypeKind::VARCHAR || |
| 131 | result->typeKind() == TypeKind::VARBINARY)) { |
| 132 | simd::memset( |
| 133 | const_cast<void*>(result->valuesAsVoid()), |
| 134 | 0, |
| 135 | std::min<int32_t>(vectorSize, result->size()) * sizeof(StringView)); |
| 136 | } |
| 137 | if (result->size() != vectorSize) { |
| 138 | result->resize(vectorSize); |
| 139 | } |
| 140 | return result; |
| 141 | } |
| 142 | return BaseVector::create(type, vectorSize, &pool); |
| 143 | } |
| 144 | } // namespace bytedance::bolt |