Skip to content

Commit 6e3713f

Browse files
committed
update
1 parent 8c0db6a commit 6e3713f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/query/storages/fuse/src/operations/analyze.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,11 @@ struct SegmentWithHLL {
503503
indexes: Vec<usize>,
504504
new_hlls: Vec<Option<BlockHLL>>,
505505
}
506-
507506
enum State {
508507
ReadData(Option<PartInfoPtr>),
509508
CollectNDV {
510509
location: Location,
511-
info: CompactSegmentInfo,
510+
info: Arc<CompactSegmentInfo>,
512511
hlls: Vec<RawBlockHLL>,
513512
},
514513
GenerateHLL,
@@ -601,6 +600,8 @@ impl Processor for AnalyzeCollectNDVSource {
601600
new_hlls,
602601
});
603602
self.state = State::GenerateHLL;
603+
} else {
604+
self.state = State::ReadData(None);
604605
}
605606
}
606607
State::SyncGen => {
@@ -629,6 +630,7 @@ impl Processor for AnalyzeCollectNDVSource {
629630
let part = FuseLazyPartInfo::from_part(&part)?;
630631
let (path, ver) = &part.segment_location;
631632
if *ver < 2 {
633+
self.state = State::ReadData(None);
632634
return Ok(());
633635
}
634636
let load_param = LoadParams {
@@ -654,6 +656,11 @@ impl Processor for AnalyzeCollectNDVSource {
654656
} else {
655657
vec![vec![]; block_count]
656658
};
659+
self.state = State::CollectNDV {
660+
location: part.segment_location.clone(),
661+
info: compact_segment_info,
662+
hlls: block_hlls,
663+
};
657664
}
658665
State::GenerateHLL => {
659666
let segment_with_hll = self.segment_with_hll.as_mut().unwrap();
@@ -669,9 +676,7 @@ impl Processor for AnalyzeCollectNDVSource {
669676
let storage_format = self.storage_format.clone();
670677
let block_meta = segment_with_hll.blocks[idx].clone();
671678
let ndv_columns_map = self.ndv_columns_map.clone();
672-
let handler: databend_common_base::JoinHandle<
673-
std::result::Result<Option<HashMap<u32, MetaHLL>>, ErrorCode>,
674-
> = runtime.spawn(async move {
679+
let handler = runtime.spawn(async move {
675680
let block = block_reader
676681
.read_by_meta(&settings, &block_meta, &storage_format)
677682
.await?;
@@ -690,8 +695,11 @@ impl Processor for AnalyzeCollectNDVSource {
690695
})?;
691696
let new_hlls = joint.into_iter().collect::<Result<Vec<_>>>()?;
692697
if new_hlls.iter().all(|v| v.is_none()) {
698+
self.segment_with_hll = None;
699+
self.state = State::ReadData(None);
693700
} else {
694701
segment_with_hll.new_hlls = new_hlls;
702+
self.state = State::Write;
695703
}
696704
}
697705
State::Write => {
@@ -719,6 +727,7 @@ impl Processor for AnalyzeCollectNDVSource {
719727
new_segment
720728
.write_meta_through_cache(&self.dal, segment_loc)
721729
.await?;
730+
self.state = State::ReadData(None);
722731
}
723732
_ => return Err(ErrorCode::Internal("It's a bug.")),
724733
}

0 commit comments

Comments
 (0)