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