morass

package
v0.0.0-...-25502c3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2012 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

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 {
	Less(i interface{}) bool
}

Is the receiver less than the parameterised interface

type Morass

type Morass struct {
	AutoClear bool
	AutoClean bool
	// contains filtered or unexported fields
}

Type to manage sorting very large data sets. Setting AutoClean to true causes the Morass to delete temporary sort files when they are depleted.

func New

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

Create 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

Delete the file system components of the Morass. After this call the Morass is not usable. Returns any error that occurs.

func (*Morass) Clear

func (m *Morass) Clear() error

Reset the Morass to an empty state. Returns any error that occurs.

func (*Morass) Finalise

func (m *Morass) Finalise() error

Indicate that the last element has been pushed on to the Morass and write out final data. Returns any error that occurs.

func (*Morass) Len

func (m *Morass) Len() int64

Return the corrent length of the Morass.

func (*Morass) Pos

func (m *Morass) Pos() int64

Return the corrent position of the cursor in the Morass.

func (*Morass) Pull

func (m *Morass) Pull(e LessInterface) error

Set the settable value e to the lowest value in the Morass. io.EOF indicate 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