morass

package
v0.0.0-...-7b6cf24 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 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 (self *Morass) CleanUp() (err 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 (self *Morass) Clear() (err error)

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

func (*Morass) Finalise

func (self *Morass) Finalise() (err 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 (self *Morass) Len() int64

Return the corrent length of the Morass.

func (*Morass) Pos

func (self *Morass) Pos() int64

Return the corrent position of the cursor in the Morass.

func (*Morass) Pull

func (self *Morass) Pull(e LessInterface) (err 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 (self *Morass) Push(e LessInterface) (err 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