Move approx_log_bytes into a flavour::LogLiteralHelper trait
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TeyhRfMYjMditek6geDRoQ
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
82fa0dfeb4
commit
d0ce524e95
@@ -18,6 +18,7 @@ use crate::consts::{
|
||||
MAX_AUTO_DECLARED_PARAMS, MAX_NEW_AUTO_PARAMS_PER_LINE, OTTYL_RESERVED_PARAM_NAMES,
|
||||
SORT_HELPER_INDEX_PURGE_AFTER,
|
||||
};
|
||||
use crate::flavour::LogLiteralHelper;
|
||||
use crate::engine::data_value::{DataValue, MetricPrimitiveKind, ParamDeclaration};
|
||||
use crate::engine::filter_parser::{self, CompareOp, FilterExpr, FilterValue};
|
||||
use crate::engine::index_key::IndexKey;
|
||||
@@ -123,10 +124,6 @@ impl EngineSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn approx_log_bytes(text: &str) -> u64 {
|
||||
text.len() as u64
|
||||
}
|
||||
|
||||
impl EngineSnapshot {
|
||||
pub(crate) fn from_index(index: BTreeMap<IndexKey, DataValue>) -> Self {
|
||||
let mut snapshot = EngineSnapshot { index, ..Default::default() };
|
||||
@@ -165,7 +162,7 @@ impl EngineSnapshot {
|
||||
break;
|
||||
};
|
||||
if let Some(DataValue::LogLiteral { text }) = self.index.get(&oldest_key) {
|
||||
self.approx_bytes_total = self.approx_bytes_total.saturating_sub(approx_log_bytes(text));
|
||||
self.approx_bytes_total = self.approx_bytes_total.saturating_sub(text.approx_log_bytes());
|
||||
}
|
||||
self.index.remove(&oldest_key);
|
||||
self.log_count -= 1;
|
||||
|
||||
Reference in New Issue
Block a user