MCPcopy Create free account
hub / github.com/apache/impala / InitTupleBuffer

Method InitTupleBuffer

be/src/exec/hdfs-scanner.h:637–664  ·  view source on GitHub ↗

Initialize a dense array of 'num_tuples' tuples. TODO: we could do better here if we inlined the tuple and null indicator byte widths with codegen to eliminate all the branches in memcpy()/memset().

Source from the content-addressed store, hash-verified

635 /// TODO: we could do better here if we inlined the tuple and null indicator byte
636 /// widths with codegen to eliminate all the branches in memcpy()/memset().
637 void InitTupleBuffer(
638 Tuple* template_tuple, uint8_t* __restrict__ tuple_mem, int64_t num_tuples) {
639 const TupleDescriptor* desc = scan_node_->tuple_desc();
640 const int tuple_byte_size = desc->byte_size();
641 // Handle the different template/non-template cases with different loops to avoid
642 // unnecessary branches inside the loop.
643 if (template_tuple != nullptr) {
644 for (int64_t i = 0; i < num_tuples; ++i) {
645 InitTupleFromTemplate(
646 template_tuple, reinterpret_cast<Tuple*>(tuple_mem), tuple_byte_size);
647 tuple_mem += tuple_byte_size;
648 }
649 } else if (tuple_byte_size <= CACHELINE_SIZE) {
650 // If each tuple fits in a cache line, it is quicker to zero the whole memory buffer
651 // instead of just the null indicators. This is because we are fetching the cache
652 // line anyway and zeroing a cache line is cheap (a couple of AVX2 instructions)
653 // compared with the overhead of calling memset() row-by-row.
654 memset(tuple_mem, 0, num_tuples * tuple_byte_size);
655 } else {
656 const int null_bytes_offset = desc->null_bytes_offset();
657 const int num_null_bytes = desc->num_null_bytes();
658 for (int64_t i = 0; i < num_tuples; ++i) {
659 reinterpret_cast<Tuple*>(tuple_mem)->ClearNullBits(
660 null_bytes_offset, num_null_bytes);
661 tuple_mem += tuple_byte_size;
662 }
663 }
664 }
665
666 /// Returns true iff 'template_tuple' is non-NULL.
667 /// Not inlined in IR so it can be replaced with a constant.

Callers

nothing calls this directly

Calls 5

null_bytes_offsetMethod · 0.80
num_null_bytesMethod · 0.80
ClearNullBitsMethod · 0.80
tuple_descMethod · 0.45
byte_sizeMethod · 0.45

Tested by

no test coverage detected