-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSort.h
43 lines (40 loc) · 1.28 KB
/
Sort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "Iterator.h"
#include "TournamentTree.h"
#include "SortedRecordRenderer.h"
#include <fstream>
#include <vector>
#include <map>
using std::vector;
using std::map;
using std::tuple;
class SortPlan : public Plan
{
friend class SortIterator;
public:
SortPlan (Plan * const input, RowSize const size, RowCount const count, bool removeDuplicates = false, std::function<void ()> forceFlushBufferHandler = nullptr);
~SortPlan ();
Iterator * init () const;
private:
Plan * const _input;
RowSize const _size;
RowCount const _count;
bool _removeDuplicates;
}; // class SortPlan
class SortIterator : public Iterator
{
public:
SortIterator (SortPlan const * const plan);
~SortIterator ();
byte * next ();
private:
SortPlan const * const _plan;
Iterator * const _input;
RowCount _consumed, _produced;
SortedRecordRenderer * _renderer;
SortedRecordRenderer * _formInMemoryRenderer (RowCount base = 0, u_int16_t runNumber = 0,
u_int32_t memory_limit = 0,
bool materialize = true); // Returns the tree where the top node is the smallest
vector<string> _createInitialRuns (); // Returns the names of the files created
SortedRecordRenderer * gracefulDegradation ();
SortedRecordRenderer * _externalSort (); // Returns the renderer that is ready to render the next row
}; // class SortIterator