tfrecord

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

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package tfrecord is an obvious tfrecord IO implementation

Format spec: https://www.tensorflow.org/tutorials/load_data/tfrecord, assume all numbers are little-endian although not actually defined in spec.

Index

Constants

This section is empty.

Variables

View Source
var ErrChecksum = errors.New("checksum error in TFRecord")

ErrChecksum is error returned when TFRecord content doesn't pass checksum. It indicates data corruption or wrong file format.

Functions

This section is empty.

Types

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator iterates TFRecords through an io.Reader

func NewIterator

func NewIterator(r io.Reader, bufSize int64, checkDataCRC bool) *Iterator

NewIterator creates a Iterator. Iterator pre-allocates and reuse buffer to avoid frequent buffer allocation, bufSize should be set to upper-bound of expected common record size. when checkDataCRC is true, check CRC of data content, this is the recommend setup because checking CRC of data won't be performance bottleneck in most cases.

func (*Iterator) Err

func (it *Iterator) Err() error

Err returns any error stopping Next(), io.EOF is not considered error

func (*Iterator) Next

func (it *Iterator) Next() bool

Next reads in next record from underlying reader

func (*Iterator) Value

func (it *Iterator) Value() []byte

Value returns the current value, returns nil when iterator not in valid state

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer implements io.Writer that writes TFRecord

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter creates a TFRecord writer on top of w

func (*Writer) Write

func (w *Writer) Write(record []byte) (n int, err error)

Write implements io.Write

Jump to

Keyboard shortcuts

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