Documentation ¶
Overview ¶
Package morass implements file system-backed sorting.
Use morass when you don't want your data to be a quagmire.
Sort data larger than can fit in memory.
morass məˈras/ 1. An area of muddy or boggy ground. 2. A complicated or confused situation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LessInterface ¶
type LessInterface interface { // Is the receiver less than the parameterised interface Less(i interface{}) bool }
LessInterface wraps the Less method.
type Morass ¶
type Morass struct { // AutoClear specifies that the Morass // should call Clear when emptied by // a call to Pull. AutoClear bool // AutoClean specifies that the Morass // should call delete temporary sort // files when it has been emptied by // a call to Pull. AutoClean bool // contains filtered or unexported fields }
Morass implements sorting of very large data sets.
func New ¶
New creates a new Morass. prefix and dir are passed to ioutil.TempDir. chunkSize specifies the amount of sorting to be done in memory, concurrent specifies that temporary file writing occurs concurrently with sorting. An error is returned if no temporary directory can be created. Note that the type is registered with the underlying gob encoder using the name ℳn, where n is a sequentially assigned integer string, when the type registered. This is done to avoid using too much space and will cause problems when using gob itself on this type. If you intend use gob itself with this the type, preregister with gob and morass will use the existing registration.
func (*Morass) CleanUp ¶
CleanUp deletes the file system components of the Morass. After this call the Morass is not usable.
func (*Morass) Finalise ¶
Finalise is called to indicate that the last element has been pushed on to the Morass and write out final data.
func (*Morass) Pull ¶
func (m *Morass) Pull(e LessInterface) error
Pull sets the settable value e to the lowest value in the Morass. If io.EOF is returned the Morass is empty. Any other error results in no value being set on e.
func (*Morass) Push ¶
func (m *Morass) Push(e LessInterface) error
Push a value on to the Morass. Returns any error that occurs.