code: func (c *LeveledCompactor) selectDirs(ds []dirMeta) []dirMeta {
  	if len(c.ranges) < 2 || len(ds) < 1 {
  		return nil
  	}
  
  	highTime := ds[len(ds)-1].meta.MinTime
  
  	for _, iv := range c.ranges[1:] {
  		parts := splitByRange(ds, iv)
  		if len(parts) == 0 {
  			continue
  		}
  
  	Outer:
  		for _, p := range parts {
  			// Do not select the range if it has a block whose compaction failed.
  			for _, dm := range p {
  				if dm.meta.Compaction.Failed {
  					continue Outer
  				}
  			}
  
  			mint := p[0].meta.MinTime
  			maxt := p[len(p)-1].meta.MaxTime
  			// Pick the range of blocks if it spans the full range (potentially with gaps)
  			// or is before the most recent block.
  			// This ensures we don't compact blocks prematurely when another one of the same
  			// size still fits in the range.
  			if (maxt-mint == iv || maxt <= highTime) && len(p) > 1 {
  				return p
  			}
  		}
  	}
  
  	return nil
  }
docs: // selectDirs returns the dir metas that should be compacted into a single new block.
  // If only a single block range is configured, the result is always nil.