quiver-sort-0.2.0.1: Sort the values in a quiver

Control.Quiver.Sort

Description

Synopsis

# In-memory sorting

These Quivers require reading all the values from the quiver before being able to sort them. As such, it is highly recommended you only use them for short streams.

spsort :: (Ord a, Monad m) => SP a a m () Source #

spsortBy :: Monad m => (a -> a -> Ordering) -> SP a a m () Source #

Use the specified comparison function to sort the values.

spsortOn :: (Ord b, Monad m) => (a -> b) -> SP a a m () Source #

Use the provided function to be able to compare values.

# File-based sorting

For large Quivers it may not be possible to sort the entire stream in memory. As such, these functions work by sorting chunks of the stream and storing them in temporary files before merging them all together.

spfilesort :: (Binary a, Ord a, MonadResource m, MonadMask m) => SPFileConfig -> P () a a () m (SPResult IOException) Source #

Use external files to temporarily store partially sorted results (splitting into chunks of the specified size if one is provided).

These files are stored inside the specified directory if provided; if no such directory is provided then the system temporary directory is used.

spfilesortBy :: (Binary a, MonadResource m, MonadMask m) => (a -> a -> Ordering) -> SPFileConfig -> P () a a () m (SPResult IOException) Source #

Use external files to temporarily store partially sorted (using the comparison function) results (splitting into chunks of the specified size if one is provided).

These files are stored inside the specified directory if provided; if no such directory is provided then the system temporary directory is used.

## Configuration

Configuration settings for spfilesort and spfilesortBy. Use defaultConfig and the various set* functions to configure it.

Default settings for sorting using external files:

• Have a chunk size of 1000.
• Use the system temporary directory.
• No more than 100 temporary files to be open at a time.

Specify the size of chunks to be individually sorted: the larger the value the fewer temporary files need to be created but the more memory needed to accumulate the values and sort them.

Specify where temporary files should be stored.

Typically you would only set this if the system temporary directory isn't large or fast enough.

NOTE: this directory must exist and be writable!

The maximum number of files that should be open at any one time.

Larger values will be faster, but run the risk of exhausting the operating system's supply of file descriptors (and thus being killed).