Skip to content

Commit 799e186

Browse files
authored
denzell/patch sync qdrant script (#4020)
1 parent 4ee43fa commit 799e186

1 file changed

Lines changed: 17 additions & 22 deletions

File tree

server/src/bin/sync-qdrant.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ async fn main() -> Result<(), ServiceError> {
4040
let mut offset = Some(uuid::Uuid::nil().to_string());
4141

4242
while let Some(cur_offset) = offset {
43+
println!("cur_offset: {}", cur_offset);
4344
let (qdrant_point_ids, new_offset) = scroll_qdrant_collection_ids(
4445
collection.clone(),
4546
Some(cur_offset.to_string()),
46-
Some(1000),
47+
Some(10000),
4748
)
4849
.await?;
4950

@@ -56,35 +57,29 @@ async fn main() -> Result<(), ServiceError> {
5657
.map(|(x, _)| *x)
5758
.collect::<Vec<uuid::Uuid>>();
5859

59-
let qdrant_point_ids_and_datasets_not_in_pg = qdrant_point_ids
60-
.iter()
61-
.filter(|x| !pg_point_ids.contains(x))
62-
.filter_map(|x| pg_point_ids_and_datasets.iter().find(|(y, _)| y == x))
63-
.cloned()
64-
.collect::<Vec<(uuid::Uuid, uuid::Uuid)>>();
65-
66-
let qdrant_point_ids_not_in_pg = qdrant_point_ids_and_datasets_not_in_pg
67-
.iter()
68-
.map(|(x, _)| *x)
69-
.collect::<Vec<uuid::Uuid>>();
60+
total += qdrant_point_ids.len();
7061

71-
let datasets_out_of_sync = qdrant_point_ids_and_datasets_not_in_pg
62+
let qdrant_points_missing = qdrant_point_ids
7263
.iter()
73-
.map(|(_, x)| *x)
64+
.filter(|x| !pg_point_ids.contains(x))
65+
.map(|x| *x)
7466
.collect::<Vec<uuid::Uuid>>();
7567

76-
total += qdrant_point_ids.len();
77-
78-
if !qdrant_point_ids_not_in_pg.is_empty() {
68+
if !qdrant_points_missing.is_empty() {
7969
println!(
80-
"len of qdrant_point_ids_not_in_pg: {:?}, {:?}",
81-
qdrant_point_ids_not_in_pg.len(),
82-
datasets_out_of_sync
70+
"len of qdrant_point_ids_not_in_pg: {:?}",
71+
qdrant_points_missing.len(),
8372
);
8473

85-
delete_points_from_qdrant(qdrant_point_ids_not_in_pg, collection.clone()).await?;
74+
delete_points_from_qdrant(qdrant_points_missing, collection.clone()).await?;
8675
} else {
87-
println!("Scrolled {}/{}", qdrant_point_ids.len(), total);
76+
println!(
77+
"{:?} Scrolled {}(qd) {}(pg) /{}",
78+
qdrant_point_ids.get(0),
79+
qdrant_point_ids.len(),
80+
pg_point_ids.len(),
81+
total
82+
);
8883
}
8984

9085
offset = new_offset;

0 commit comments

Comments
 (0)