| 290 | } |
| 291 | } |
| 292 | |
| 293 | VectorPtr tryReuseResult(const VectorPtr& result) { |
| 294 | if (result.use_count() != 1) { |
| 295 | return nullptr; |
| 296 | } |
| 297 | switch (result->encoding()) { |
| 298 | case VectorEncoding::Simple::ROW: |
| 299 | // Do not call prepareForReuse as it would throw away constant vectors |
| 300 | // that can be reused. Reusability of children should be checked in |
| 301 | // getValues of child readers (all readers other than struct are |
| 302 | // recreating the result vector on each batch currently, so no issue with |
| 303 | // reusability now). |
| 304 | result->reuseNulls(); |
| 305 | result->clearContainingLazyAndWrapped(); |
| 306 | return result; |
| 307 | case VectorEncoding::Simple::LAZY: { |
| 308 | auto& lazy = static_cast<const LazyVector&>(*result); |
| 309 | if (!lazy.isLoaded()) { |
| 310 | return nullptr; |
| 311 | } |
| 312 | return tryReuseResult(lazy.loadedVectorShared()); |
| 313 | } |
| 314 | case VectorEncoding::Simple::DICTIONARY: |
| 315 | return tryReuseResult(result->valueVector()); |
| 316 | default: |
| 317 | return nullptr; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | void setConstantField( |
no test coverage detected