use std::collections::{BTreeSet, HashMap};
use crate::db::{DatabaseBackend, adapt_sql, now_rfc3339};
use crate::error::AppError;
use crate::lua::tid::generate_tid;
use crate::spaces::lthash::{LtHashState, record_element};
use crate::spaces::{commit, db};
type RecordVersion = (String, String, String, String, String);
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct BackfillReport {
pub records_scanned: usize,
pub records_updated: usize,
pub records_unencodable: usize,
pub oplog_rows_remapped: usize,
pub oplog_rows_unresolved: usize,
pub repos_rebuilt: usize,
}
impl BackfillReport {
pub fn is_noop(&self) -> bool {
self.records_updated == 0 && self.oplog_rows_remapped == 0
}
}
type RecordRow = (String, String, String, String, String, String, String);
const BACKFILL_MARKER_KEY: &str = "space_cid_backfill_completed_at";
async fn read_marker(
pool: &sqlx::AnyPool,
backend: DatabaseBackend,
) -> Result