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 StateStoreRead for PanicStateStore {
33 type Iter = PanicStateStoreIter<StateStoreKeyedRow>;
34 type RevIter = PanicStateStoreIter<StateStoreKeyedRow>;
35
36 #[allow(clippy::unused_async)]
37 async fn get_keyed_row(
38 &self,
39 _key: TableKey<Bytes>,
40
41 _read_options: ReadOptions,
42 ) -> StorageResult<Option<StateStoreKeyedRow>> {
43 panic!("should not read from the state store!");
44 }
45
46 #[allow(clippy::unused_async)]
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 #[allow(clippy::unused_async)]
57 async fn rev_iter(
58 &self,
59 _key_range: TableKeyRange,
60
61 _read_options: ReadOptions,
62 ) -> StorageResult<Self::RevIter> {
63 panic!("should not read from the state store!");
64 }
65}
66
67impl StateStoreReadLog for PanicStateStore {
68 type ChangeLogIter = PanicStateStoreIter<StateStoreReadLogItem>;
69
70 async fn next_epoch(&self, _epoch: u64, _options: NextEpochOptions) -> StorageResult<u64> {
71 unimplemented!()
72 }
73
74 async fn iter_log(
75 &self,
76 _epoch_range: (u64, u64),
77 _key_range: TableKeyRange,
78 _options: ReadLogOptions,
79 ) -> StorageResult<Self::ChangeLogIter> {
80 unimplemented!()
81 }
82}
83
84impl LocalStateStore for PanicStateStore {
85 type FlushedSnapshotReader = PanicStateStore;
86 type Iter<'a> = PanicStateStoreIter<StateStoreKeyedRow>;
87 type RevIter<'a> = PanicStateStoreIter<StateStoreKeyedRow>;
88
89 #[allow(clippy::unused_async)]
90 async fn get(
91 &self,
92 _key: TableKey<Bytes>,
93 _read_options: ReadOptions,
94 ) -> StorageResult<Option<Bytes>> {
95 panic!("should not operate on the panic state store!");
96 }
97
98 #[allow(clippy::unused_async)]
99 async fn iter(
100 &self,
101 _key_range: TableKeyRange,
102 _read_options: ReadOptions,
103 ) -> StorageResult<Self::Iter<'_>> {
104 panic!("should not operate on the panic state store!");
105 }
106
107 #[allow(clippy::unused_async)]
108 async fn rev_iter(
109 &self,
110 _key_range: TableKeyRange,
111 _read_options: ReadOptions,
112 ) -> StorageResult<Self::RevIter<'_>> {
113 panic!("should not operate on the panic state store!");
114 }
115
116 fn insert(
117 &mut self,
118 _key: TableKey<Bytes>,
119 _new_val: Bytes,
120 _old_val: Option<Bytes>,
121 ) -> StorageResult<()> {
122 panic!("should not operate on the panic state store!");
123 }
124
125 fn delete(&mut self, _key: TableKey<Bytes>, _old_val: Bytes) -> StorageResult<()> {
126 panic!("should not operate on the panic state store!");
127 }
128
129 #[allow(clippy::unused_async)]
130 async fn flush(&mut self) -> StorageResult<usize> {
131 panic!("should not operate on the panic state store!");
132 }
133
134 fn epoch(&self) -> u64 {
135 panic!("should not operate on the panic state store!");
136 }
137
138 fn is_dirty(&self) -> bool {
139 panic!("should not operate on the panic state store!");
140 }
141
142 #[allow(clippy::unused_async)]
143 async fn init(&mut self, _epoch: InitOptions) -> StorageResult<()> {
144 panic!("should not operate on the panic state store!");
145 }
146
147 fn seal_current_epoch(&mut self, _next_epoch: u64, _opts: SealCurrentEpochOptions) {
148 panic!("should not operate on the panic state store!")
149 }
150
151 async fn try_flush(&mut self) -> StorageResult<()> {
152 panic!("should not operate on the panic state store!");
153 }
154
155 async fn update_vnode_bitmap(&mut self, _vnodes: Arc<Bitmap>) -> StorageResult<Arc<Bitmap>> {
156 panic!("should not operate on the panic state store!");
157 }
158
159 fn get_table_watermark(&self, _vnode: VirtualNode) -> Option<Bytes> {
160 panic!("should not operate on the panic state store!");
161 }
162
163 fn new_flushed_snapshot_reader(&self) -> Self::FlushedSnapshotReader {
164 panic!()
165 }
166}
167
168impl StateStore for PanicStateStore {
169 type Local = Self;
170 type ReadSnapshot = Self;
171
172 async fn try_wait_epoch(
173 &self,
174 _epoch: HummockReadEpoch,
175 _options: TryWaitEpochOptions,
176 ) -> StorageResult<()> {
177 panic!("should not wait epoch from the panic state store!");
178 }
179
180 async fn new_local(&self, _option: NewLocalOptions) -> Self::Local {
181 panic!("should not call new local from the panic state store");
182 }
183
184 async fn new_read_snapshot(
185 &self,
186 _epoch: HummockReadEpoch,
187 _options: NewReadSnapshotOptions,
188 ) -> StorageResult<Self::ReadSnapshot> {
189 panic!()
190 }
191}
192
193pub struct PanicStateStoreIter<T: IterItem>(PhantomData<T>);
194
195impl<T: IterItem> StateStoreIter<T> for PanicStateStoreIter<T> {
196 async fn try_next(&mut self) -> StorageResult<Option<T::ItemRef<'_>>> {
197 panic!("should not call next on panic state store iter")
198 }
199}