perf: index factor lookups by symbol

This commit is contained in:
boris
2026-08-31 14:27:30 +08:00
parent ce46e42ff7
commit dff791b51f
+4 -2
View File
@@ -2501,12 +2501,14 @@ impl DataSet {
if start > end {
return Vec::new();
}
let Some(symbol_id) = self.symbol_id(symbol) else {
return Vec::new();
};
let field = normalize_field(field);
let mut rows = self
.factor_by_date
.range(start..=end)
.flat_map(|(_, snapshots)| snapshots.iter())
.filter(|snapshot| snapshot.symbol == symbol)
.filter_map(|(date, _)| self.factor_by_symbol_id(*date, symbol_id))
.filter_map(|snapshot| {
factor_numeric_value(snapshot, &field).map(|value| FactorValue {
date: snapshot.date,