Menu

Sorting_filter

silex6

This filter should read records from the input connector, and if needed should add these records to a temporary index in order to push records to the output connector in the specified sort order. This filter should have 1 input connector and be used for the ORDER BY statement.

Algorithms

The filter should have two algorithms: one pass-through algorithm that transmits records from input connector to the output as is, and one sorting algorithm that first read all records from the input connector, build an index, and read again records using the index. The pass-through algorithm should be used only if records are already sorted by filters connected to the input.

the sorting algorithm should do the following: - filter should first read all records received from the input connector, and build a temporary index. - filter should then read index in ascending order and send seek messages to the input connector for every records that are present in the temporary index. Filter should read records one-by-one and transmit every record to the output connector.

note this (necessary) two steps algorithm does break streaming.

Cost calculation

during cost calculation, the filter should check sort order of records on calculation results sent from the input connector.

If cost calculation results indicate the records are already sorted, then the filter should enable "pass-through" algorithm, and add a zero unit cost to the total. The pass-through algorithm should allow streaming.

if calculation results sent from the input connectors indicate the results are not sorted according to the requested keys, then unit cost should be: number of records * 8 / 3. (Overhead due to temporary index constructs and read). This algorithm does not allow streaming and should set “streamed” flag of result records to false.

See also

[Set_engine]


Related

Wiki: Filters
Wiki: Set_engine

MongoDB Logo MongoDB