Documentation ¶
Index ¶
Constants ¶
const ( // NoCompression means writing raw chunk data into files. // With other choices, chunks are compressed before written. NoCompression = iota // Snappy had been the default compressing algorithm widely // used in Google. It compromises between speech and // compression ratio. Snappy // Gzip is a well-known compression algorithm. It is // recommmended only you are looking for compression ratio. Gzip )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index consists offsets and sizes of the consequetive chunks in a RecordIO file.
func LoadIndex ¶
func LoadIndex(r io.ReadSeeker) (*Index, error)
LoadIndex scans the file and parse chunkOffsets, chunkLens, and len.
func (*Index) Locate ¶
Locate returns the index of chunk that contains the given record, and the record index within the chunk. It returns (-1, -1) if the record is out of range.
func (*Index) NumRecords ¶
NumRecords returns the total number of records in a RecordIO file.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner scans records in a specified range within [0, numRecords).
func NewScanner ¶
func NewScanner(r io.ReadSeeker, index *Index, start, len int) *Scanner
NewScanner creates a scanner that sequencially reads records in the range [start, start+len). If start < 0, it scans from the beginning. If len < 0, it scans till the end of file.
type Writer ¶
type Writer struct { io.Writer // Set to nil to mark a closed writer. // contains filtered or unexported fields }
Writer creates a RecordIO file.
func NewWriter ¶
NewWriter creates a RecordIO file writer. Each chunk is compressed using the deflate algorithm given compression level. Note that level 0 means no compression and -1 means default compression.