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

Method TryCompact

be/src/exec/scratch-tuple-batch.h:156–176  ·  view source on GitHub ↗

Try to compact 'num_uncommitted_tuples' uncommitted tuples that were added to the end of 'dst_batch' by copying them to memory allocated from dst_batch->tuple_data_pool(). Returns true on success or false if the memory could not be allocated.

Source from the content-addressed store, hash-verified

154 /// dst_batch->tuple_data_pool(). Returns true on success or false if the memory
155 /// could not be allocated.
156 bool TryCompact(RowBatch* dst_batch, int num_uncommitted_tuples) {
157 DCHECK_LE(dst_batch->num_rows() + num_uncommitted_tuples, dst_batch->capacity());
158 // Copy rows that reference 'tuple_mem' into a new small buffer. This code handles
159 // the case where num_uncommitted_tuples == 0, since TryAllocate() returns a non-null
160 // pointer.
161 int64_t dst_bytes = num_uncommitted_tuples * static_cast<int64_t>(tuple_byte_size);
162 uint8_t* dst_buffer = dst_batch->tuple_data_pool()->TryAllocate(dst_bytes);
163 if (dst_buffer == nullptr) return false;
164 const int end_row = dst_batch->num_rows() + num_uncommitted_tuples;
165 for (int i = dst_batch->num_rows(); i < end_row; ++i) {
166 TupleRow* row = dst_batch->GetRow(i);
167 Tuple* uncompacted_tuple = row->GetTuple(0);
168 DCHECK_GE(reinterpret_cast<uint8_t*>(uncompacted_tuple), tuple_mem);
169 DCHECK_LT(reinterpret_cast<uint8_t*>(uncompacted_tuple),
170 tuple_mem + tuple_byte_size * capacity);
171 row->SetTuple(0, reinterpret_cast<Tuple*>(dst_buffer));
172 memcpy(dst_buffer, uncompacted_tuple, tuple_byte_size);
173 dst_buffer += tuple_byte_size;
174 }
175 return true;
176 }
177
178 /// Creates micro batches that needs to be scanned.
179 /// Bits set in 'selected_rows' are the rows that needs to be scanned. Consecutive

Callers

nothing calls this directly

Calls 7

tuple_data_poolMethod · 0.80
num_rowsMethod · 0.45
capacityMethod · 0.45
TryAllocateMethod · 0.45
GetRowMethod · 0.45
GetTupleMethod · 0.45
SetTupleMethod · 0.45

Tested by

no test coverage detected