Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sorted-run-merger.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 
16 #ifndef IMPALA_RUNTIME_SORTED_RUN_MERGER_H_
17 #define IMPALA_RUNTIME_SORTED_RUN_MERGER_H_
18 
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/thread/mutex.hpp>
21 
22 #include "common/object-pool.h"
23 #include "util/tuple-row-compare.h"
24 
25 namespace impala {
26 
27 class RowBatch;
28 class RowDescriptor;
29 class RuntimeProfile;
30 
35 //
43  public:
47  typedef boost::function<Status (RowBatch**)> RunBatchSupplier;
48 
49  SortedRunMerger(const TupleRowComparator& compare_less_than, RowDescriptor* row_desc,
50  RuntimeProfile* profile, bool deep_copy_input);
51 
55  Status Prepare(const std::vector<RunBatchSupplier>& input_runs);
56 
58  Status GetNext(RowBatch* output_batch, bool* eos);
59 
62  void TransferAllResources(RowBatch* transfer_resource_batch);
63 
64  private:
65  class BatchedRowSupplier;
66 
69  void Heapify(int parent_index);
70 
78  std::vector<BatchedRowSupplier*> min_heap_;
79 
82 
86 
89 
92 
95 
98 };
99 
100 }
101 
102 #endif
RuntimeProfile::Counter * get_next_timer_
Times calls to GetNext().
void Heapify(int parent_index)
std::vector< BatchedRowSupplier * > min_heap_
Status GetNext(RowBatch *output_batch, bool *eos)
Return the next batch of sorted rows from this merger.
boost::function< Status(RowBatch **)> RunBatchSupplier
ObjectPool pool_
Pool of BatchedRowSupplier instances.
Status Prepare(const std::vector< RunBatchSupplier > &input_runs)
const RowDescriptor & row_desc() const
RuntimeProfile::Counter * get_next_batch_timer_
Times calls to get the next batch of rows from the input run.
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.
TupleRowComparator compare_less_than_
Row comparator. Returns true if lhs < rhs.
RowDescriptor * input_row_desc_
void TransferAllResources(RowBatch *transfer_resource_batch)