MySQL 8.0.40
Source Code Documentation
|
A helper RAII wrapper for otherwise difficult to use sequence of: More...
#include <rem0rec.h>
Public Member Functions | |
Rec_offsets () | |
Prepares offsets to initially point to the fixed-size buffer, and marks the memory as allocated, but uninitialized. More... | |
const ulint * | compute (const rec_t *rec, const dict_index_t *index, const ulint n_fields=ULINT_UNDEFINED) |
Computes offsets for given record. More... | |
~Rec_offsets () | |
Deallocated dynamically allocated memory, if any. More... | |
Private Attributes | |
mem_heap_t * | m_heap {nullptr} |
Pointer to heap used by rec_get_offsets(). More... | |
ulint | m_preallocated_buffer [REC_OFFS_NORMAL_SIZE] |
Buffer with size large enough to handle common cases without having to use heap. More... | |
ulint * | m_offsets {m_preallocated_buffer} |
Additional Inherited Members | |
Private Member Functions inherited from ut::Non_copyable | |
Non_copyable (const Non_copyable &)=delete | |
Non_copyable & | operator= (const Non_copyable &)=delete |
Non_copyable ()=default | |
~Non_copyable ()=default | |
A helper RAII wrapper for otherwise difficult to use sequence of:
ulint offsets_[REC_OFFS_NORMAL_SIZE]; rec_offs_init(offsets_); mem_heap_t *heap = nullptr;
const ulint *offsets = rec_get_offsets(rec, index, offsets_, ULINT_UNDEFINED, &heap);
DO_SOMETHING(offsets);
if (heap != nullptr) { mem_heap_free(heap); }
With this helper you can simply do:
DO_SOMETHING(Rec_offsets().compute(rec,index));
And if you need to reuse the memory allocated offsets several times you can: Rec_offsets offsets; for(rec: recs) DO_SOMTHING(offsets.compute(rec,index))
|
inline |
Prepares offsets to initially point to the fixed-size buffer, and marks the memory as allocated, but uninitialized.
You first need to call compute() to use it
|
inline |
Deallocated dynamically allocated memory, if any.
|
inline |
Computes offsets for given record.
Returned array is owned by this instance. You can use its value as long as this object does not go out of scope (which can free the buffer), and you don't call compute() again (which can overwrite the offsets).
[in] | rec | The record for which you want to compute the offsets |
[in] | index | The index which contains the record |
[in] | n_fields | Number of columns to scan |
|
private |
Pointer to heap used by rec_get_offsets().
Initially nullptr. If row is really big, rec_get_offsets() may need to allocate new buffer for offsets. At, first, when heap is null, rec_get_offsets() will create new heap, and pass it back via reference. On subsequent calls, we will pass this heap, so it is reused if needed. Therefore all allocated buffers are in this heap, if it is not nullptr
|
private |
|
private |
Buffer with size large enough to handle common cases without having to use heap.
This is the initial value of m_offsets.