59 if (input_row_batch_index_ < input_row_batch_->num_rows()) {
63 if (transfer_batch != NULL) {
96 int left_index = 2 * parent_index + 1;
97 int right_index = left_index + 1;
98 if (left_index >=
min_heap_.size())
return;
103 min_heap_[right_index]->current_row())) {
104 least_child = left_index;
106 least_child = right_index;
112 min_heap_[parent_index]->current_row())) {
120 : compare_less_than_(compare_less_than),
121 input_row_desc_(row_desc),
122 deep_copy_input_(deep_copy_input) {
134 if (!empty)
min_heap_.push_back(new_elem);
138 int last_parent = (
min_heap_.size() / 2) - 1;
139 for (
int i = last_parent; i >= 0; --i) {
155 int output_row_index = output_batch->
AddRow();
168 bool min_run_complete =
false;
173 if (min_run_complete) {
RuntimeProfile::Counter * get_next_timer_
Times calls to GetNext().
void Heapify(int parent_index)
TupleRow * current_row() const
RowBatch * input_row_batch_
std::vector< BatchedRowSupplier * > min_heap_
BatchedRowSupplier(SortedRunMerger *parent, const RunBatchSupplier &sorted_run)
int input_row_batch_index_
Status GetNext(RowBatch *output_batch, bool *eos)
Return the next batch of sorted rows from this merger.
A tuple with 0 materialised slots is represented as NULL.
#define RETURN_IF_ERROR(stmt)
some generally useful macros
TupleRow * GetRow(int row_idx)
#define ADD_TIMER(profile, name)
boost::function< Status(RowBatch **)> RunBatchSupplier
RunBatchSupplier sorted_run_
ObjectPool pool_
Pool of BatchedRowSupplier instances.
Status Prepare(const std::vector< RunBatchSupplier > &input_runs)
SortedRunMerger * parent_
void TransferResourceOwnership(RowBatch *dest)
Status Next(RowBatch *transfer_batch, bool *done)
const RowDescriptor & row_desc() const
MemPool * tuple_data_pool()
RuntimeProfile::Counter * get_next_batch_timer_
Times calls to get the next batch of rows from the input run.
const std::vector< TupleDescriptor * > & tuple_descriptors() const
Return descriptors for all tuples in this row, in order of appearance.
SortedRunMerger(const TupleRowComparator &compare_less_than, RowDescriptor *row_desc, RuntimeProfile *profile, bool deep_copy_input)
bool deep_copy_input_
True if rows must be deep copied into the output batch.
TupleRow * DeepCopy(const std::vector< TupleDescriptor * > &descs, MemPool *pool)
Create a deep copy of this TupleRow. DeepCopy will allocate from the pool.
TupleRowComparator compare_less_than_
Row comparator. Returns true if lhs < rhs.
RowDescriptor * input_row_desc_