code: def write_index(data, group, append):
      
      # build the index from data
      nitems = group['items'].shape[0] if 'items' in group else 0
      last_index = group['index'][-1] if nitems > 0 else -1
      index = last_index + cumindex(data._entries['features'])
  
      if append:
          nidx = group['index'].shape[0]
          # # in case we append to the end of an existing item
          # if data._entries['items']._continue_last_item(group):
          #     nidx -= 1
  
          group['index'].resize((nidx + index.shape[0],))
          group['index'][nidx:] = index
      else:
          group['index'].resize((index.shape[0],))
          group['index'][...] = index
docs: Write the data index to the given group.
  
      :param h5features.Data data: The that is being indexed.
      :param h5py.Group group: The group where to write the index.
      :param bool append: If True, append the created index to the
          existing one in the `group`. Delete any existing data in index
          if False.