-// encodePosition writes place into the first positionBytes bytes of record.
-func encodePosition(record []byte, place Position) {
- binary.LittleEndian.PutUint32(record[0:], place.day)
- binary.LittleEndian.PutUint32(record[4:], place.length)
- binary.LittleEndian.PutUint64(record[8:], place.offset)
-}
-
-// decodePosition reads a position from the first positionBytes bytes of record.
-func decodePosition(record []byte) Position {
- return Position{
- day: binary.LittleEndian.Uint32(record[0:]),
- length: binary.LittleEndian.Uint32(record[4:]),
- offset: binary.LittleEndian.Uint64(record[8:]),
- }
-}
-
-// Records is a file of fixed-size Records, numbered from 0. Record n starts at
-// byte n*size. A record that was never written reads as zeros. An index is data
-// that the day files can give again, so Records cuts a partial record at the
-// end of the file.
-type Records struct {
- file *os.File
- size int
- count int
-}
-