You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: merge.rs
    path of file: ./repos/incubator-horaedb/src/analytic_engine/src/row_iter
    
    the code of the file until where you have to start completion: // Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

use std::{
    cmp,
    cmp::Ordering,
    collections::BinaryHeap,
    mem,
    ops::{Deref, DerefMut},
    time::{Duration, Instant},
};

use async_trait::async_trait;
use common_types::{
    projected_schema::{ProjectedSchema, RowProjectorBuilder},
    record_batch::{FetchedRecordBatch, FetchedRecordBatchBuilder},
    request_id::RequestId,
    row::RowViewOnBatch,
    schema::RecordSchemaWithKey,
    S
    
    async fn reheap(&mut self, mut buffered_stream: HeapBufferedStream) -> Result<()> {
        let pulled_new_batch = buffered_stream
            .pull_next_batch_if_necessary(&mut self.metrics)
            .await?;

        if buffered_stream.is_exhausted() {
            self.refill_hot();
        } else if pulled_new_batch {
            // TODO(xikai): it seems no need to decide to which heap push the
            // `buffered_stream`. Just put the new batch into the cold heap if
            // the max bound of the hottest batch is smaller than the min bound
            // of new one.
            let cold_new_batch = if let Some(hottest) = self.hot.peek() {
                buffered_stream.is_after_boundary(&self.schema, &hottest.last_row_in_buffer())
            } else {
                false
            };

            if cold_new_batch {
                self.cold.push(buffered_stream);
            } else {
                self.hot.push(buffered_stream);
            }
            self.refill_hot();
        } else {
            // No new batch is pulled and the `buffered_stream` is not exhausted so just put
            // it back to the hot heap.
            self.hot.push(buffered_stream);
        }

        Ok(())
    }