Skip to content

Commit

Permalink
fix naming and add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachelint committed Jun 15, 2023
1 parent 8544148 commit 669e802
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions analytic_engine/src/instance/open.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct ShardOpener {
shard_id: ShardId,
manifest: ManifestRef,
wal_manager: WalManagerRef,
states: HashMap<TableId, TableOpenStage>,
stages: HashMap<TableId, TableOpenStage>,
wal_replay_batch_size: usize,
flusher: Flusher,
max_retry_flush_limit: usize,
Expand Down Expand Up @@ -231,7 +231,7 @@ impl ShardOpener {
shard_id: shard_context.shard_id,
manifest,
wal_manager,
states,
stages: states,
wal_replay_batch_size,
flusher,
max_retry_flush_limit,
Expand All @@ -247,7 +247,7 @@ impl ShardOpener {
self.recover_table_datas().await?;

// Retrieve the table results and return.
let states = std::mem::take(&mut self.states);
let states = std::mem::take(&mut self.stages);
let mut table_results = HashMap::with_capacity(states.len());
for (table_id, state) in states {
match state {
Expand All @@ -273,7 +273,7 @@ impl ShardOpener {

/// Recover table meta data from manifest based on shard.
async fn recover_table_metas(&mut self) -> Result<()> {
for (table_id, state) in self.states.iter_mut() {
for (table_id, state) in self.stages.iter_mut() {
match state {
// Only do the meta recovery work in `RecoverTableMeta` state.
TableOpenStage::RecoverTableMeta(ctx) => {
Expand Down Expand Up @@ -319,8 +319,8 @@ impl ShardOpener {
/// Recover table data based on shard.
async fn recover_table_datas(&mut self) -> Result<()> {
// Replay wal logs of tables.
let mut replay_table_datas = Vec::with_capacity(self.states.len());
for (table_id, stage) in self.states.iter_mut() {
let mut replay_table_datas = Vec::with_capacity(self.stages.len());
for (table_id, stage) in self.stages.iter_mut() {
match stage {
// Only do the wal recovery work in `RecoverTableData` state.
TableOpenStage::RecoverTableData(ctx) => {
Expand Down Expand Up @@ -358,7 +358,9 @@ impl ShardOpener {
// Process the replay results.
for table_data in replay_table_datas {
let table_id = table_data.id;
let stage = self.states.get_mut(&table_id).unwrap();
// Each `table_data` has its related `stage` in `stages`, impossible to panic
// here.
let stage = self.stages.get_mut(&table_id).unwrap();
let failed_table_opt = table_results.remove(&table_id);

match (&stage, failed_table_opt) {
Expand Down
2 changes: 1 addition & 1 deletion analytic_engine/src/instance/wal_replayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl ReplayCore for RegionBasedCore {
context: &ReplayContext,
table_datas: &[TableDataRef],
) -> Result<FailedTables> {
debug!("Replay wal logs on region mode, context:{context}, states:{table_datas:?}",);
debug!("Replay wal logs on region mode, context:{context}, tables:{table_datas:?}",);

// Init all table results to be oks, and modify to errs when failed to replay.
let mut faileds = FailedTables::new();
Expand Down

0 comments on commit 669e802

Please sign in to comment.