code: func (h *Head) chunkRewrite(ref uint64, dranges Intervals) (err error) {
  	if len(dranges) == 0 {
  		return nil
  	}
  
  	ms := h.series.getByID(ref)
  	ms.Lock()
  	defer ms.Unlock()
  	if len(ms.chunks) == 0 {
  		return nil
  	}
  
  	metas := ms.chunksMetas()
  	mint, maxt := metas[0].MinTime, metas[len(metas)-1].MaxTime
  	it := newChunkSeriesIterator(metas, dranges, mint, maxt)
  
  	ms.reset()
  	for it.Next() {
  		t, v := it.At()
  		ok, _ := ms.append(t, v)
  		if !ok {
  			level.Warn(h.logger).Log("msg", "failed to add sample during delete")
  		}
  	}
  
  	return nil
  }
docs: // chunkRewrite re-writes the chunks which overlaps with deleted ranges
  // and removes the samples in the deleted ranges.
  // Chunks is deleted if no samples are left at the end.