use crate::error::{ErrorClass, InternalError};
#[derive(Clone, Copy, Debug)]
#[remain::sorted]
pub enum ExecKind {
Delete,
Load,
Save,
}
#[derive(Clone, Copy, Debug)]
#[remain::sorted]
pub enum ExecOutcome {
Aborted,
ErrorConflict,
ErrorCorruption,
ErrorIncompatiblePersistedFormat,
ErrorInternal,
ErrorInvariantViolation,
ErrorNotFound,
ErrorUnsupported,
Success,
}
#[derive(Clone, Copy, Debug)]
#[remain::sorted]
pub enum CacheKind {
SharedQueryPlan,
SqlCompiledCommand,
}
#[derive(Clone, Copy, Debug)]
#[remain::sorted]
pub enum CacheOutcome {
Hit,
Insert,
Miss,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum CacheMissReason {
Cold,
DistinctKey,
MethodVersion,
SchemaFingerprint,
SchemaVersion,
Surface,
Visibility,
}
impl ExecOutcome {
#[remain::check]
pub(super) const fn from_error(error: &InternalError) -> Self {
#[remain::sorted]
match error.class() {
ErrorClass::Conflict => Self::ErrorConflict,
ErrorClass::Corruption => Self::ErrorCorruption,
ErrorClass::IncompatiblePersistedFormat => Self::ErrorIncompatiblePersistedFormat,
ErrorClass::Internal => Self::ErrorInternal,
ErrorClass::InvariantViolation => Self::ErrorInvariantViolation,
ErrorClass::NotFound => Self::ErrorNotFound,
ErrorClass::Unsupported => Self::ErrorUnsupported,
}
}
}
#[derive(Clone, Copy, Debug)]
#[remain::sorted]
pub enum SaveMutationKind {
Insert,
Replace,
Update,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum MutationCommitClass {
DurableOnly,
LiveOnly,
MixedDurableAndLive,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum SchemaReconcileOutcome {
ExactMatch,
FirstCreate,
LatestSnapshotCorrupt,
RejectedFieldSlot,
RejectedOther,
RejectedRowLayout,
RejectedSchemaVersion,
StoreWriteError,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum SchemaTransitionOutcome {
AppendOnlyNullableFields,
ExactMatch,
RejectedEntityIdentity,
RejectedFieldContract,
RejectedFieldSlot,
RejectedRowLayout,
RejectedSchemaVersion,
RejectedSnapshot,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum SqlCompileRejectPhase {
CacheKey,
Parse,
Semantic,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum SqlWriteKind {
Delete,
Insert,
InsertSelect,
Update,
}
#[derive(Clone, Copy, Debug)]
#[remain::sorted]
pub enum PlanKind {
ByKey,
ByKeys,
FullScan,
IndexMultiLookup,
IndexPrefix,
IndexRange,
Intersection,
KeyRange,
Union,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum PlanChoiceReason {
ConflictingPrimaryKeyChildrenAccessPreferred,
ConstantFalsePredicate,
EmptyChildAccessPreferred,
FullScanAccess,
IntentKeyAccessOverride,
LimitZeroWindow,
NonIndexAccess,
PlannerCompositeNonIndex,
PlannerFullScanFallback,
PlannerKeySetAccess,
PlannerPrimaryKeyLookup,
PlannerPrimaryKeyRange,
RequiredOrderPrimaryKeyRangePreferred,
SingletonPrimaryKeyChildAccessPreferred,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum PreparedShapeFinalizationOutcome {
AlreadyFinalized,
GeneratedFallback,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[remain::sorted]
pub enum GroupedPlanExecutionMode {
HashMaterialized,
OrderedMaterialized,
}
#[derive(Clone, Copy, Debug)]
#[remain::sorted]
pub enum MetricsEvent {
AcceptedSchemaFootprint {
entity_path: &'static str,
fields: u64,
nested_leaf_facts: u64,
},
Cache {
entity_path: &'static str,
kind: CacheKind,
outcome: CacheOutcome,
},
CacheEntries {
kind: CacheKind,
entries: u64,
},
CacheMissReason {
entity_path: &'static str,
kind: CacheKind,
reason: CacheMissReason,
},
ExecError {
kind: ExecKind,
entity_path: &'static str,
outcome: ExecOutcome,
},
ExecFinish {
kind: ExecKind,
entity_path: &'static str,
rows_touched: u64,
inst_delta: u64,
outcome: ExecOutcome,
},
ExecStart {
kind: ExecKind,
entity_path: &'static str,
},
IndexDelta {
entity_path: &'static str,
inserts: u64,
removes: u64,
},
LoadRowEfficiency {
entity_path: &'static str,
candidate_rows_scanned: u64,
candidate_rows_filtered: u64,
result_rows_emitted: u64,
},
MutationCommitPlan {
entity_path: &'static str,
class: MutationCommitClass,
},
NonAtomicPartialCommit {
entity_path: &'static str,
committed_rows: u64,
},
Plan {
entity_path: &'static str,
kind: PlanKind,
grouped_execution_mode: Option<GroupedPlanExecutionMode>,
},
PlanChoice {
entity_path: &'static str,
reason: PlanChoiceReason,
},
PreparedShapeFinalization {
entity_path: &'static str,
outcome: PreparedShapeFinalizationOutcome,
},
RelationValidation {
entity_path: &'static str,
reverse_lookups: u64,
blocked_deletes: u64,
},
ReverseIndexDelta {
entity_path: &'static str,
inserts: u64,
removes: u64,
},
RowsAggregated {
entity_path: &'static str,
rows_aggregated: u64,
},
RowsEmitted {
entity_path: &'static str,
rows_emitted: u64,
},
RowsFiltered {
entity_path: &'static str,
rows_filtered: u64,
},
RowsScanned {
entity_path: &'static str,
rows_scanned: u64,
},
SaveMutation {
entity_path: &'static str,
kind: SaveMutationKind,
rows_touched: u64,
},
SchemaReconcile {
entity_path: &'static str,
outcome: SchemaReconcileOutcome,
},
SchemaStoreFootprint {
encoded_bytes: u64,
entity_path: &'static str,
latest_snapshot_bytes: u64,
snapshots: u64,
},
SchemaTransition {
entity_path: &'static str,
outcome: SchemaTransitionOutcome,
},
SqlCompileReject {
entity_path: &'static str,
phase: SqlCompileRejectPhase,
},
SqlWrite {
entity_path: &'static str,
kind: SqlWriteKind,
matched_rows: u64,
mutated_rows: u64,
returning_rows: u64,
},
SqlWriteError {
entity_path: &'static str,
kind: SqlWriteKind,
class: ErrorClass,
},
UniqueViolation {
entity_path: &'static str,
},
}