morass

package
v0.0.0-...-6fbfe6d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2015 License: BSD-3-Clause Imports: 11 Imported by: 0

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

func New(e interface{}, prefix, dir string, chunkSize int, concurrent bool) (*Morass, error)

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

func (m *Morass) CleanUp() error

CleanUp deletes the file system components of the Morass. After this call the Morass is not usable.

func (*Morass) Clear

func (m *Morass) Clear() error

Clear resets the Morass to an empty state.

func (*Morass) Finalise

func (m *Morass) Finalise() error

Finalise is called to indicate that the last element has been pushed on to the Morass and write out final data.

func (*Morass) Len

func (m *Morass) Len() int64

Len returns the current length of the Morass.

func (*Morass) Pos

func (m *Morass) Pos() int64

Pos returns the current position of the cursor in the Morass.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL