|< < 16 > >|

Pipelining

Pipelining isn't always possible.

Sort operator

class Sort: public Iterator { ... };
Sort::Sort(Iterator* input, SortColumns sort_columns) { this->input = input; this->sort_columns = sort_columns; } void Sort::open() { // Gather all the input rows. input->open(); Row* row; this->rows = new vector<Row*>(); while (row = input->next() { rows->emplace_back(row); } // Actually sort the rows. std::sort(rows->begin(), rows->end(), RowCompare(sort_columns)); // Prepare for output this->output = rows->begin(); }
Row* Sort::next() { Row* next = NULL; if (output != rows->end()) { next = output++; } return next; } void Sort::close() { input->close(); delete rows; }

|< < 16 > >|