isabella232 / streamsort

DEPRECATED: please use https://github.com/bsm/extsort instead

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StreamSort

Build Status GoDoc Go Report Card License

Sort arbitrarily large data sets with a predictable amount of memory using temporary files.

Example:

import(
  "fmt"

  "github.com/bsm/streamsort"
)

func main() {
	// Init a Sorter with default options
	sorter := streamsort.New(nil)
	defer sorter.Close()

	// Append data
	_ = sorter.Append([]byte("foo"))
	_ = sorter.Append([]byte("bar"))
	_ = sorter.Append([]byte("baz"))
	_ = sorter.Append([]byte("boo"))

	// Sort and iterate
	iter, err := sorter.Sort(context.Background())
	if err != nil {
		panic(err)
	}
	defer iter.Close()

	for iter.Next() {
		fmt.Println(string(iter.Bytes()))
	}
	if err := iter.Err(); err != nil {
		panic(err)
	}

}

For more complex examples, please see our Documentation

About

DEPRECATED: please use https://github.com/bsm/extsort instead

License:Other


Languages

Language:Go 96.5%Language:Ruby 1.9%Language:Makefile 1.6%