use super::super::dense_key_index::{CommitInconsistency, IndexInconsistency};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum UniqueIndexInconsistency {
BucketUnavailable {
bucket: usize,
},
StoredRowUnrepresentable {
stored_row: u32,
},
KeyUnavailable {
row: usize,
},
StoredRowMismatch {
expected: usize,
actual: usize,
},
ProbeLimitReached,
InsertRowUnrepresentable {
bucket: usize,
row: usize,
},
InsertRowReserved {
bucket: usize,
row: usize,
},
InsertVacancyUnavailable {
bucket: usize,
row: usize,
},
InsertVacancyOccupied {
bucket: usize,
row: usize,
occupying_row: u32,
},
ExpectedRowMismatch {
expected: usize,
actual: usize,
},
}
impl From<IndexInconsistency> for UniqueIndexInconsistency {
fn from(reason: IndexInconsistency) -> Self {
match reason {
IndexInconsistency::BucketUnavailable { bucket } => Self::BucketUnavailable { bucket },
IndexInconsistency::StoredRowUnrepresentable { stored_row } => {
Self::StoredRowUnrepresentable { stored_row }
}
IndexInconsistency::KeyUnavailable { row } => Self::KeyUnavailable { row },
IndexInconsistency::StoredRowMismatch { expected, actual } => {
Self::StoredRowMismatch { expected, actual }
}
IndexInconsistency::ProbeLimitReached => Self::ProbeLimitReached,
}
}
}
impl From<CommitInconsistency> for UniqueIndexInconsistency {
fn from(reason: CommitInconsistency) -> Self {
match reason {
CommitInconsistency::RowUnrepresentable { vacancy, row } => {
Self::InsertRowUnrepresentable {
bucket: vacancy.bucket(),
row,
}
}
CommitInconsistency::RowReserved { vacancy, row } => Self::InsertRowReserved {
bucket: vacancy.bucket(),
row,
},
CommitInconsistency::VacancyUnavailable { vacancy, row } => {
Self::InsertVacancyUnavailable {
bucket: vacancy.bucket(),
row,
}
}
CommitInconsistency::VacancyOccupied {
vacancy,
row,
occupying_row,
} => Self::InsertVacancyOccupied {
bucket: vacancy.bucket(),
row,
occupying_row,
},
}
}
}