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.
| 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 |
nothing calls this directly
no test coverage detected