code: func (c *Chunk) SwapColumn(colIdx int, other *Chunk, otherIdx int) {
  	// Find the leftmost column of the reference which is the actual column to
  	// be swapped.
  	for i := 0; i < colIdx; i++ {
  		if c.columns[i] == c.columns[colIdx] {
  			colIdx = i
  		}
  	}
  	for i := 0; i < otherIdx; i++ {
  		if other.columns[i] == other.columns[otherIdx] {
  			otherIdx = i
  		}
  	}
  
  	// Find the columns which refer to the actual column to be swapped.
  	refColsIdx := make([]int, 0, len(c.columns)-colIdx)
  	for i := colIdx; i < len(c.columns); i++ {
  		if c.columns[i] == c.columns[colIdx] {
  			refColsIdx = append(refColsIdx, i)
  		}
  	}
  	refColsIdx4Other := make([]int, 0, len(other.columns)-otherIdx)
  	for i := otherIdx; i < len(other.columns); i++ {
  		if other.columns[i] == other.columns[otherIdx] {
  			refColsIdx4Other = append(refColsIdx4Other, i)
  		}
  	}
  
  	// Swap columns from two chunks.
  	c.columns[colIdx], other.columns[otherIdx] = other.columns[otherIdx], c.columns[colIdx]
  
  	// Rebuild the reference.
  	for _, i := range refColsIdx {
  		c.MakeRef(colIdx, i)
  	}
  	for _, i := range refColsIdx4Other {
  		other.MakeRef(otherIdx, i)
  	}
  }
docs: // SwapColumn swaps column "c.columns[colIdx]" with column
  // "other.columns[otherIdx]". If there exists columns refer to the column to be
  // swapped, we need to re-build the reference.