code: func ReadIndex(r io.Reader, n int32, typ string) (Index, error) {
  	var (
  		idx Index
  		err error
  	)
  	idx.Refs, err = readIndices(r, n, typ)
  	if err != nil {
  		return idx, err
  	}
  	var nUnmapped uint64
  	err = binary.Read(r, binary.LittleEndian, &nUnmapped)
  	if err == nil {
  		idx.Unmapped = &nUnmapped
  	} else if err != io.EOF {
  		return idx, err
  	}
  	idx.IsSorted = true
  
  	// Set the index of the last record to max int to
  	// prevent addition of records out of order. This
  	// means that the only way to append to an index is
  	// to re-index and add to that created index.
  	// TODO(kortschak) See if index appending is feasible
  	// and needed.
  	idx.LastRecord = int(^uint(0) >> 1)
  
  	return idx, nil
  }
docs: // ReadIndex reads the Index from the given io.Reader.