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: iter.rs
    path of file: ./repos/incubator-horaedb/src/analytic_engine/src/memtable/skiplist
    
    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.

//! Skiplist memtable iterator

use std::{cmp::Ordering, ops::Bound, time::Instant};

use arena::{Arena, BasicStats};
use bytes_ext::{Bytes, BytesMut};
use codec::row;
use common_types::{
    projected_schema::RowProjector,
    record_batch::{FetchedRecordBatch, FetchedRecordBatchBuilder},
    row::contiguous::{ContiguousRowReader, ProjectedContiguousRow},
    schema::Schema,
    SequenceNumber,
};
use logger::trace;
use skiplist::{ArenaSlice, BytewiseComparator, IterRef, Skiplist};
use snafu::ResultExt;

use crate::memtable::{
    key::{self, KeySequence},
    skiplist::SkiplistMemTable,
    AppendRow, BuildRecordBatch, DecodeContinuousRow, DecodeInternalKey, EncodeInternalKey,
    IterTimeout, ProjectSchema, Result, ScanContext, ScanRequest,
};

/// Iterator state
#[derive(Debug, PartialEq)]
enum State {
    /// The iterator struct is created but not initialized
    Uninitialized,
    /// The iterator is initialized (seek)
    Initialized,
    /// No more element the iterator can return
    Finished,
}

/// Columnar iterator for [SkiplistMemTable]
pub struct ColumnarIterImpl<A: Arena<Stats = BasicStats> + 
    
    fn fetch_next_record_batch(&mut self) -> Result<Option<FetchedRecordBatch>> {
        debug_assert_eq!(State::Initialized, self.state);
        assert!(self.batch_size > 0);

        let record_schema = self.row_projector.fetched_schema().clone();
        let is_empty_projection = record_schema.columns().is_empty();
        let primary_key_indexes = self
            .row_projector
            .primary_key_indexes()
            .map(|idxs| idxs.to_vec());
        let mut builder = FetchedRecordBatchBuilder::with_capacity(
            record_schema,
            primary_key_indexes,
            self.batch_size,
        );
        let mut num_rows = 0;
        while self.iter.valid() && num_rows < self.batch_size {
            if let Some(row) = self.fetch_next_row()? {
                let row_reader = ContiguousRowReader::try_new(&row, &self.memtable_schema)
                    .context(DecodeContinuousRow)?;
                let projected_row = ProjectedContiguousRow::new(row_reader, &self.row_projector);

                trace!("Column iterator fetch next row, row:{:?}", projected_row);

                builder
                    .append_projected_contiguous_row(&projected_row)
                    .context(AppendRow)?;
                num_rows += 1;
            } else {
                // There is no more row to fetch
                self.finish();
                break;
            }
        }

        if is_empty_projection {
            builder.inc_row_num(num_rows);
        }

        if num_rows > 0 {
            if let Some(deadline) = self.deadline {
                let now = Instant::now();
                if now >= deadline {
                    return IterTimeout { now, deadline }.fail();
                }
            }

            let batch = builder.build().context(BuildRecordBatch)?;
            trace!("column iterator send one batch:{:?}", batch);

            Ok(Some(batch))
        } else {
            // If iter is invalid after seek (nothing matched), then it may not be marked as
            // finished yet
            self.finish();
            Ok(None)
        }
    }