Introduce unified Series trait
This commit introduces the `Series` trait to provide a unified interface for accessing indexed data across different series types (RecordSeries, SeriesView, and future SharedSeries). This simplifies the VM's indexer logic and lays the groundwork for the dual series architecture.
This commit is contained in:
@@ -285,6 +285,15 @@ impl Object for RecordSeries {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
fn as_series(&self) -> Option<&dyn crate::ast::types::Series> {
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::ast::types::Series for RecordSeries {
|
||||
fn get_item(&self, index: usize) -> Option<Value> {
|
||||
self.get_record(index)
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -328,6 +337,16 @@ impl Object for SeriesView {
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn as_series(&self) -> Option<&dyn crate::ast::types::Series> {
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::ast::types::Series for SeriesView {
|
||||
fn get_item(&self, index: usize) -> Option<Value> {
|
||||
self.inner.borrow().get_value(index)
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
Reference in New Issue
Block a user