in pq/reader.go [163:196]
func (r *Reader) readInto(to []byte) ([]byte, reason) {
tx := r.tx
n := r.state.eventBytes
if L := len(to); L < n {
n = L
}
cursor := makeTxCursor(tx, r.accessor, &r.state.cursor)
for n > 0 {
consumed, err := cursor.Read(to[:n])
to = to[consumed:]
n -= consumed
r.state.eventBytes -= consumed
if err != nil {
return to, err
}
}
// end of event -> advance to next event
var err reason
if r.state.eventBytes == 0 {
r.state.eventBytes = -1
r.state.id++
// As page is already in memory, use current transaction to try to skip to
// next page if no more new event fits into current page.
if cursor.PageBytes() < szEventHeader {
_, err = cursor.AdvancePage()
}
}
return to, err
}