emsort

package module
v0.0.0-...-e467347 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2016 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package emsort provides a facility for performing disk-based external merge sorts.

see https://en.wikipedia.org/wiki/External_sorting#External_merge_sort see http://faculty.simpson.edu/lydia.sinapova/www/cmsc250/LN250_Weiss/L17-ExternalSortEX2.htm

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk func(io.Reader) ([]byte, error)

Chunk is a function that chunks data read from the given io.Reader into items for sorting.

type Less

type Less func(a []byte, b []byte) bool

Less is a function that compares two byte arrays and determines whether a is less than b.

type SortedWriter

type SortedWriter interface {
	Write(b []byte) (int, error)

	// Close implements the method from io.Closer. It's important to call this
	// because this is where the final sorting happens.
	Close() error
}

SortedWriter is an io.WriteCloser that sorts its output on writing. Each []byte passed to the Write method is treated as a single item to sort. Since these []byte are kept in memory, they must not be pooled/shared!

func New

func New(out io.Writer, chunk Chunk, less Less, memLimit int) (SortedWriter, error)

New constructs a new SortedWriter that wraps out, chunks data into sortable items using the given Chunk, compares them using the given Less and limits the amount of RAM used to approximately memLimit.

Jump to

Keyboard shortcuts

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