Skip to content

Commit

Permalink
Fix update_stats and add all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lanlou1554 committed Nov 8, 2024
1 parent 43e66c3 commit 52d290a
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 65 deletions.
Binary file removed optd-persistent/init.db
Binary file not shown.
14 changes: 13 additions & 1 deletion optd-persistent/src/cost_model/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ pub enum StatType {
Max,
}

#[derive(PartialEq)]
pub enum EpochOption {
// TODO(lanlou): Could I make i32 -> EpochId?
Existed(i32),
New(String, String),
}

#[derive(Clone)]
pub struct Stat {
pub stat_type: i32,
pub stat_value: Json,
Expand Down Expand Up @@ -72,7 +80,11 @@ pub trait CostModelStorageLayer {
epoch_id: Self::EpochId,
) -> StorageResult<()>;

async fn update_stats(&self, stat: Stat, epoch_id: Self::EpochId) -> StorageResult<()>;
async fn update_stats(
&mut self,
stat: Stat,
epoch_option: EpochOption,
) -> StorageResult<Option<Self::EpochId>>;

async fn store_cost(
&self,
Expand Down
Loading

0 comments on commit 52d290a

Please sign in to comment.