减少文本因子读取临时分配

This commit is contained in:
Boris
2026-08-26 05:08:34 +08:00
parent 77622e164c
commit 0867655d85
2 changed files with 11 additions and 4 deletions
+7
View File
@@ -2449,6 +2449,13 @@ impl DataSet {
.unwrap_or_default()
}
pub fn factor_text_rows_on(&self, date: NaiveDate) -> &[FactorTextValue] {
self.factor_text_by_date
.get(&date)
.map(Vec::as_slice)
.unwrap_or(&[])
}
pub fn market_snapshots_on(&self, date: NaiveDate) -> Vec<&DailyMarketSnapshot> {
self.market_by_date
.get(&date)
@@ -3687,8 +3687,8 @@ impl PlatformExprStrategy {
},
available_text_factor_names: if self.stock_text_factors_required {
ctx.data
.factor_text_snapshots_on(date)
.into_iter()
.factor_text_rows_on(date)
.iter()
.map(|row| row.field.clone())
.collect()
} else {
@@ -4081,8 +4081,8 @@ impl PlatformExprStrategy {
extra_factors,
extra_text_factors: if self.stock_text_factors_required {
ctx.data
.factor_text_snapshots_on(date)
.into_iter()
.factor_text_rows_on(date)
.iter()
.filter(|row| row.symbol == symbol)
.map(|row| (row.field.clone(), row.value.clone()))
.collect()