Documentation ¶
Index ¶
- Constants
- func TempDir() (string, error)
- func TempFile() (*os.File, error)
- type File
- type MergeSort
- func (r *MergeSort) Cleanup()
- func (r *MergeSort) Len() int
- func (r *MergeSort) Less(i, j int) bool
- func (r *MergeSort) Peek() (*zed.Value, error)
- func (r *MergeSort) Pop() interface{}
- func (r *MergeSort) Push(x interface{})
- func (r *MergeSort) Read() (*zed.Value, error)
- func (r *MergeSort) Spill(ctx context.Context, vals []zed.Value) error
- func (r *MergeSort) SpillSize() int64
- func (r *MergeSort) Swap(i, j int)
Constants ¶
const TempPrefix = "zed-spill-"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
File provides a means to write a sequence of zng records to temporary storage then read them back. This is used for processing large batches of data that do not fit in memory and/or cannot be shuffled to a peer worker, but can be processed in multiple passes. File implements zio.Reader and zio.Writer.
func NewFile ¶
NewFile returns a File. Records should be written to File via the zio.Writer interface, followed by a call to the Rewind method, followed by reading records via the zio.Reader interface.
func NewTempFile ¶
func (*File) CloseAndRemove ¶
CloseAndRemove closes and removes the underlying file.
type MergeSort ¶
type MergeSort struct {
// contains filtered or unexported fields
}
MergeSort manages "runs" (files of sorted zng records) that are spilled to disk a chunk at a time, then read back and merged in sorted order, effectively implementing an external merge sort.
func NewMergeSort ¶
func NewMergeSort(comparator *expr.Comparator) (*MergeSort, error)
NewMergeSort returns a MergeSort to implement external merge sorts of a large zng record stream. It creates a temporary directory to hold the collection of spilled chunks. Call Cleanup to remove it.
func (*MergeSort) Peek ¶
Peek returns the next record without advancing the reader. The record stops being valid at the next read call.
func (*MergeSort) Read ¶
Read returns the smallest record (per the comparison function provided to MewMergeSort) from among the next records in the spilled chunks. It implements the merge operation for an external merge sort.