table/builder.go
func (b *Builder) blockIndex() []byte {
	// Store the end offset, so we know the length of the final block.
	b.restarts = append(b.restarts, uint32(b.buf.Len()))

	// Add 4 because we want to write out number of restarts at the end.
	sz := 4*len(b.restarts) + 4
	out := make([]byte, sz)
	buf := out
	for _, r := range b.restarts {
		binary.BigEndian.PutUint32(buf[:4], r)
		buf = buf[4:]
	}
	binary.BigEndian.PutUint32(buf[:4], uint32(len(b.restarts)))
	return out
}
func (b *Builder) blockIndex() []byte {
	// Store the end offset, so we know the length of the final block.
	b.restarts = append(b.restarts, uint32(b.buf.Len()))

	// Add 4 because we want to write out number of restarts at the end.
	sz := 4*len(b.restarts) + 4
	out := make([]byte, sz)
	buf := out
	for _, r := range b.restarts {
		binary.BigEndian.PutUint32(buf[:4], r)
		buf = buf[4:]
	}
	binary.BigEndian.PutUint32(buf[:4], uint32(len(b.restarts)))
	return out
}
func ( b * Builder ) blockIndex ( ) [ ] byte { // Store the end offset, so we know the length of the final block. b . restarts = append ( b . restarts , uint32 ( b . buf . Len ( ) ) ) // Add 4 because we want to write out number of restarts at the end. sz := 4 * len ( b . restarts ) + 4 out := make ( [ ] byte , sz ) buf := out for _ , r := range b . restarts { binary . BigEndian . PutUint32 ( buf [ : 4 ] , r ) buf = buf [ 4 : ] } binary . BigEndian . PutUint32 ( buf [ : 4 ] , uint32 ( len ( b . restarts ) ) ) return out }
// blockIndex generates the block index for the table.
// It is mainly a list of all the block base offsets.
blockIndex generates the block index for the table . It is mainly a list of all the block base offsets .