risingwave_storage/
panic_store.rs1use std::marker::PhantomData;
16use std::sync::Arc;
17
18use bytes::Bytes;
19use risingwave_common::bitmap::Bitmap;
20use risingwave_common::hash::VirtualNode;
21use risingwave_hummock_sdk::HummockReadEpoch;
22use risingwave_hummock_sdk::key::{TableKey, TableKeyRange};
23
24use crate::error::StorageResult;
25use crate::store::*;
26
27#[derive(Clone, Default)]
30pub struct PanicStateStore;
31
32impl StateStoreGet for PanicStateStore {
33 fn on_key_value<O: Send + 'static>(
34 &self,
35 _key: TableKey<Bytes>,
36 _read_options: ReadOptions,
37 _on_key_value_fn: impl KeyValueFn<O>,
38 ) -> impl StorageFuture<'_, Option<O>> {
39 async { panic!("should not read from PanicStateStore") }
40 }
41}
42
43impl StateStoreRead for PanicStateStore {
44 type Iter = PanicStateStoreIter<StateStoreKeyedRow>;
45 type RevIter = PanicStateStoreIter<StateStoreKeyedRow>;
46
47 async fn iter(
48 &self,
49 _key_range: TableKeyRange,
50
51 _read_options: ReadOptions,
52 ) -> StorageResult<Self::Iter> {
53 panic!("should not read from the state store!");
54 }
55
56 async fn rev_iter(
57 &self,
58 _key_range: TableKeyRange,
59
60 _read_options: ReadOptions,
61 ) -> StorageResult<Self::RevIter> {
62 panic!("should not read from the state store!");
63 }
64}
65
66impl StateStoreReadLog for PanicStateStore {
67 type ChangeLogIter = PanicStateStoreIter<StateStoreReadLogItem>;
68
69 async fn next_epoch(&self, _epoch: u64, _options: NextEpochOptions) -> StorageResult<u64> {
70 unimplemented!()
71 }
72
73 async fn iter_log(
74 &self,
75 _epoch_range: (u64, u64),
76 _key_range: TableKeyRange,
77 _options: ReadLogOptions,
78 ) -> StorageResult<Self::ChangeLogIter> {
79 unimplemented!()
80 }
81}
82
83impl LocalStateStore for PanicStateStore {
84 type FlushedSnapshotReader = PanicStateStore;
85 type Iter<'a> = PanicStateStoreIter<StateStoreKeyedRow>;
86 type RevIter<'a> = PanicStateStoreIter<StateStoreKeyedRow>;
87
88 async fn iter(
89 &self,
90 _key_range: TableKeyRange,
91 _read_options: ReadOptions,
92 ) -> StorageResult<Self::Iter<'_>> {
93 panic!("should not operate on the panic state store!");
94 }
95
96 async fn rev_iter(
97 &self,
98 _key_range: TableKeyRange,
99 _read_options: ReadOptions,
100 ) -> StorageResult<Self::RevIter<'_>> {
101 panic!("should not operate on the panic state store!");
102 }
103
104 fn insert(
105 &mut self,
106 _key: TableKey<Bytes>,
107 _new_val: Bytes,
108 _old_val: Option<Bytes>,
109 ) -> StorageResult<()> {
110 panic!("should not operate on the panic state store!");
111 }
112
113 fn delete(&mut self, _key: TableKey<Bytes>, _old_val: Bytes) -> StorageResult<()> {
114 panic!("should not operate on the panic state store!");
115 }
116
117 fn get_table_watermark(&self, _vnode: VirtualNode) -> Option<Bytes> {
118 panic!("should not operate on the panic state store!");
119 }
120
121 fn new_flushed_snapshot_reader(&self) -> Self::FlushedSnapshotReader {
122 panic!()
123 }
124
125 async fn update_vnode_bitmap(&mut self, _vnodes: Arc<Bitmap>) -> StorageResult<Arc<Bitmap>> {
126 panic!("should not operate on the panic state store!");
127 }
128}
129
130impl StateStoreWriteEpochControl for PanicStateStore {
131 async fn flush(&mut self) -> StorageResult<usize> {
132 panic!("should not operate on the panic state store!");
133 }
134
135 async fn init(&mut self, _epoch: InitOptions) -> StorageResult<()> {
136 panic!("should not operate on the panic state store!");
137 }
138
139 fn seal_current_epoch(&mut self, _next_epoch: u64, _opts: SealCurrentEpochOptions) {
140 panic!("should not operate on the panic state store!")
141 }
142
143 async fn try_flush(&mut self) -> StorageResult<()> {
144 panic!("should not operate on the panic state store!");
145 }
146}
147
148impl StateStoreWriteVector for PanicStateStore {
149 fn insert(&mut self, _vec: Vector, _info: Bytes) -> StorageResult<()> {
150 panic!()
151 }
152}
153
154impl StateStoreReadVector for PanicStateStore {
155 async fn nearest<O: Send + 'static>(
156 &self,
157 _vec: Vector,
158 _options: VectorNearestOptions,
159 _on_nearest_item_fn: impl OnNearestItemFn<O>,
160 ) -> StorageResult<Vec<O>> {
161 panic!()
162 }
163}
164
165impl StateStore for PanicStateStore {
166 type Local = Self;
167 type ReadSnapshot = Self;
168 type VectorWriter = PanicStateStore;
169
170 async fn try_wait_epoch(
171 &self,
172 _epoch: HummockReadEpoch,
173 _options: TryWaitEpochOptions,
174 ) -> StorageResult<()> {
175 panic!("should not wait epoch from the panic state store!");
176 }
177
178 async fn new_local(&self, _option: NewLocalOptions) -> Self::Local {
179 panic!("should not call new local from the panic state store");
180 }
181
182 async fn new_read_snapshot(
183 &self,
184 _epoch: HummockReadEpoch,
185 _options: NewReadSnapshotOptions,
186 ) -> StorageResult<Self::ReadSnapshot> {
187 panic!()
188 }
189
190 async fn new_vector_writer(&self, _options: NewVectorWriterOptions) -> Self::VectorWriter {
191 panic!()
192 }
193}
194
195pub struct PanicStateStoreIter<T: IterItem>(PhantomData<T>);
196
197impl<T: IterItem> StateStoreIter<T> for PanicStateStoreIter<T> {
198 async fn try_next(&mut self) -> StorageResult<Option<T::ItemRef<'_>>> {
199 panic!("should not call next on panic state store iter")
200 }
201}