code: func DoLocalTop(reader io.Reader, writer io.Writer, n int, orderBys []OrderBy, stats *pb.InstructionStat) error {
  
  	pq := newMinQueueOfPairs(orderBys)
  
  	err := util.ProcessRow(reader, nil, func(row *util.Row) error {
  		stats.InputCounter++
  
  		if pq.Len() >= n {
  			if lessThan(orderBys, pq.Top().(*util.Row), row) {
  				pq.Dequeue()
  				pq.Enqueue(row, 0)
  			}
  		} else {
  			pq.Enqueue(row, 0)
  
  		}
  		return nil
  	})
  	if err != nil {
  		fmt.Printf("Top>Failed to process input data:%v\n", err)
  		return err
  	}
  
  	// read data out of the priority queue
  	length := pq.Len()
  	itemsToReverse := make([]*util.Row, length)
  	for i := 0; i < length; i++ {
  		entry, _ := pq.Dequeue()
  		itemsToReverse[i] = entry.(*util.Row)
  	}
  	for i := length - 1; i >= 0; i-- {
  		itemsToReverse[i].WriteTo(writer)
  		stats.OutputCounter++
  	}
  
  	return nil
  }
docs: // DoLocalTop streamingly compare and get the top n items