code: func (s *session) pickCompaction() *compaction {
  	v := s.version()
  
  	var sourceLevel int
  	var t0 tFiles
  	if v.cScore >= 1 {
  		sourceLevel = v.cLevel
  		cptr := s.getCompPtr(sourceLevel)
  		tables := v.levels[sourceLevel]
  		for _, t := range tables {
  			if cptr == nil || s.icmp.Compare(t.imax, cptr) > 0 {
  				t0 = append(t0, t)
  				break
  			}
  		}
  		if len(t0) == 0 {
  			t0 = append(t0, tables[0])
  		}
  	} else {
  		if p := atomic.LoadPointer(&v.cSeek); p != nil {
  			ts := (*tSet)(p)
  			sourceLevel = ts.level
  			t0 = append(t0, ts.table)
  		} else {
  			v.release()
  			return nil
  		}
  	}
  
  	return newCompaction(s, v, sourceLevel, t0)
  }
docs: // Pick a compaction based on current state; need external synchronization.