use super::ReadContext;
use crate::error::Result;
use crate::metadata::{DataType, KvFormat, RowType};
use crate::row::{RowDecoder, RowDecoderFactory};
use std::sync::Arc;
pub(crate) struct TestReadContext {
kv_format: KvFormat,
data_types: Vec<DataType>,
}
impl TestReadContext {
pub(crate) fn compacted(data_types: Vec<DataType>) -> Self {
Self {
kv_format: KvFormat::COMPACTED,
data_types,
}
}
}
impl ReadContext for TestReadContext {
fn get_row_decoder(&self, _schema_id: i16) -> Result<Arc<dyn RowDecoder>> {
let row_type = RowType::with_data_types(self.data_types.clone());
RowDecoderFactory::create(self.kv_format.clone(), row_type)
}
}