#![deny(clippy::wildcard_enum_match_arm)]
use nodedb_physical::physical_plan::{
ArrayOp, ColumnarOp, CrdtOp, DocumentOp, GraphOp, KvOp, PhysicalPlan, TimeseriesOp, VectorOp,
};
fn document_is_write(op: &DocumentOp) -> bool {
match op {
DocumentOp::PointPut { .. }
| DocumentOp::PointInsert { .. }
| DocumentOp::PointDelete { .. }
| DocumentOp::PointUpdate { .. }
| DocumentOp::BatchInsert { .. }
| DocumentOp::InsertSelect { .. }
| DocumentOp::Upsert { .. }
| DocumentOp::BulkUpdate { .. }
| DocumentOp::BulkDelete { .. }
| DocumentOp::UpdateFromJoin { .. }
| DocumentOp::Truncate { .. } => true,
DocumentOp::PointGet { .. }
| DocumentOp::Scan { .. }
| DocumentOp::RangeScan { .. }
| DocumentOp::IndexLookup { .. }
| DocumentOp::IndexedFetch { .. }
| DocumentOp::EstimateCount { .. }
| DocumentOp::MaterializeScan { .. }
| DocumentOp::Register { .. }
| DocumentOp::DropIndex { .. }
| DocumentOp::BackfillIndex { .. }
| DocumentOp::Merge { .. } => false,
}
}
fn kv_is_write(op: &KvOp) -> bool {
match op {
KvOp::Put { .. }
| KvOp::Insert { .. }
| KvOp::InsertIfAbsent { .. }
| KvOp::InsertOnConflictUpdate { .. }
| KvOp::Delete { .. }
| KvOp::BatchPut { .. }
| KvOp::Expire { .. }
| KvOp::Persist { .. }
| KvOp::FieldSet { .. }
| KvOp::Truncate { .. }
| KvOp::Incr { .. }
| KvOp::IncrFloat { .. }
| KvOp::Cas { .. }
| KvOp::GetSet { .. }
| KvOp::Transfer { .. } => true,
KvOp::Get { .. }
| KvOp::Scan { .. }
| KvOp::GetTtl { .. }
| KvOp::BatchGet { .. }
| KvOp::FieldGet { .. }
| KvOp::MaterializeScan { .. }
| KvOp::SortedIndexRank { .. }
| KvOp::SortedIndexTopK { .. }
| KvOp::SortedIndexRange { .. }
| KvOp::SortedIndexCount { .. }
| KvOp::SortedIndexScore { .. }
| KvOp::RegisterIndex { .. }
| KvOp::DropIndex { .. }
| KvOp::RegisterSortedIndex { .. }
| KvOp::DropSortedIndex { .. }
| KvOp::TransferItem { .. } => false,
}
}
fn vector_is_write(op: &VectorOp) -> bool {
match op {
VectorOp::Insert { .. }
| VectorOp::BatchInsert { .. }
| VectorOp::Delete { .. }
| VectorOp::DeleteBySurrogate { .. }
| VectorOp::SparseInsert { .. }
| VectorOp::SparseDelete { .. }
| VectorOp::MultiVectorInsert { .. }
| VectorOp::MultiVectorDelete { .. }
| VectorOp::DirectUpsert { .. } => true,
VectorOp::Search { .. }
| VectorOp::MultiSearch { .. }
| VectorOp::QueryStats { .. }
| VectorOp::SparseSearch { .. }
| VectorOp::MultiVectorScoreSearch { .. }
| VectorOp::SetParams { .. }
| VectorOp::Seal { .. }
| VectorOp::CompactIndex { .. }
| VectorOp::Rebuild { .. } => false,
}
}
fn graph_is_write(op: &GraphOp) -> bool {
match op {
GraphOp::EdgePut { .. }
| GraphOp::EdgePutBatch { .. }
| GraphOp::EdgeDelete { .. }
| GraphOp::EdgeDeleteBatch { .. }
| GraphOp::SetNodeLabels { .. }
| GraphOp::RemoveNodeLabels { .. } => true,
GraphOp::Hop { .. }
| GraphOp::Neighbors { .. }
| GraphOp::NeighborsMulti { .. }
| GraphOp::Path { .. }
| GraphOp::Subgraph { .. }
| GraphOp::RagFusion { .. }
| GraphOp::Algo { .. }
| GraphOp::Match { .. }
| GraphOp::MatchContinuation { .. }
| GraphOp::MatchVarLenResume { .. }
| GraphOp::BspSuperstep(_)
| GraphOp::WccSuperstep(_)
| GraphOp::TemporalNeighbors { .. }
| GraphOp::TemporalAlgorithm { .. }
| GraphOp::Stats { .. } => false,
}
}
fn timeseries_is_write(op: &TimeseriesOp) -> bool {
match op {
TimeseriesOp::Ingest { .. } => true,
TimeseriesOp::Scan { .. } => false,
}
}
fn columnar_is_write(op: &ColumnarOp) -> bool {
match op {
ColumnarOp::Insert { .. } | ColumnarOp::Update { .. } | ColumnarOp::Delete { .. } => true,
ColumnarOp::Scan { .. } | ColumnarOp::MaterializeScan { .. } => false,
}
}
fn crdt_is_write(op: &CrdtOp) -> bool {
match op {
CrdtOp::Apply { .. }
| CrdtOp::ListInsert { .. }
| CrdtOp::ListDelete { .. }
| CrdtOp::ListMove { .. }
| CrdtOp::DocUpsert { .. }
| CrdtOp::DocDelete { .. }
| CrdtOp::SetConstraints { .. }
| CrdtOp::DropConstraints { .. }
| CrdtOp::RestoreToVersion { .. }
| CrdtOp::ImportSnapshot { .. } => true,
CrdtOp::Read { .. }
| CrdtOp::ReadConstraints { .. }
| CrdtOp::GetPolicy { .. }
| CrdtOp::ReadAtVersion { .. }
| CrdtOp::GetVersionVector { .. }
| CrdtOp::ExportDelta { .. }
| CrdtOp::SetPolicy { .. }
| CrdtOp::CompactAtVersion { .. } => false,
}
}
fn array_is_write(op: &ArrayOp) -> bool {
match op {
ArrayOp::Put { .. } | ArrayOp::Delete { .. } | ArrayOp::Flush { .. } => true,
ArrayOp::OpenArray { .. }
| ArrayOp::Compact { .. }
| ArrayOp::DropArray { .. }
| ArrayOp::Slice { .. }
| ArrayOp::Project { .. }
| ArrayOp::Aggregate { .. }
| ArrayOp::Elementwise { .. }
| ArrayOp::SurrogateBitmapScan { .. } => false,
}
}
pub fn is_write_plan(plan: &PhysicalPlan) -> bool {
match plan {
PhysicalPlan::Document(op) => document_is_write(op),
PhysicalPlan::Kv(op) => kv_is_write(op),
PhysicalPlan::Vector(op) => vector_is_write(op),
PhysicalPlan::Graph(op) => graph_is_write(op),
PhysicalPlan::Timeseries(op) => timeseries_is_write(op),
PhysicalPlan::Columnar(op) => columnar_is_write(op),
PhysicalPlan::Crdt(op) => crdt_is_write(op),
PhysicalPlan::Array(op) => array_is_write(op),
PhysicalPlan::Spatial(_)
| PhysicalPlan::Text(_)
| PhysicalPlan::Query(_)
| PhysicalPlan::Meta(_)
| PhysicalPlan::ClusterArray(_) => false,
}
}
#[cfg(test)]
#[path = "write_class_tests.rs"]
mod tests;