@@ -95,6 +95,12 @@ pub enum Feature {
95
95
Unknown ,
96
96
}
97
97
98
+ pub enum VerifyResult {
99
+ MissMatch ,
100
+ Success ,
101
+ Failure ,
102
+ }
103
+
98
104
impl fmt:: Display for Feature {
99
105
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
100
106
match self {
@@ -159,34 +165,40 @@ impl Feature {
159
165
}
160
166
}
161
167
162
- pub fn verify ( & self , feature : & Feature ) -> Result < bool , ErrorCode > {
168
+ pub fn verify ( & self , feature : & Feature ) -> Result < VerifyResult , ErrorCode > {
163
169
match ( self , feature) {
164
170
( Feature :: ComputeQuota ( c) , Feature :: ComputeQuota ( v) ) => {
165
171
if let Some ( thread_num) = c. threads_num {
166
172
if thread_num <= v. threads_num . unwrap_or ( usize:: MAX ) {
167
- return Ok ( false ) ;
173
+ return Ok ( VerifyResult :: Failure ) ;
168
174
}
169
175
}
170
176
171
177
if let Some ( max_memory_usage) = c. memory_usage {
172
178
if max_memory_usage <= v. memory_usage . unwrap_or ( usize:: MAX ) {
173
- return Ok ( false ) ;
179
+ return Ok ( VerifyResult :: Failure ) ;
174
180
}
175
181
}
176
182
177
- Ok ( true )
183
+ Ok ( VerifyResult :: Success )
178
184
}
179
185
( Feature :: StorageQuota ( c) , Feature :: StorageQuota ( v) ) => {
180
186
if let Some ( max_storage_usage) = c. storage_usage {
181
187
if max_storage_usage <= v. storage_usage . unwrap_or ( usize:: MAX ) {
182
- return Ok ( false ) ;
188
+ return Ok ( VerifyResult :: Failure ) ;
183
189
}
184
190
}
185
191
186
- Ok ( true )
192
+ Ok ( VerifyResult :: Success )
187
193
}
188
- ( Feature :: MaxCpuQuota ( c) , Feature :: MaxCpuQuota ( v) ) => Ok ( c > v) ,
189
- ( Feature :: MaxNodeQuota ( c) , Feature :: MaxNodeQuota ( v) ) => Ok ( c > v) ,
194
+ ( Feature :: MaxCpuQuota ( c) , Feature :: MaxCpuQuota ( v) ) => match c > v {
195
+ true => Ok ( VerifyResult :: Success ) ,
196
+ false => Ok ( VerifyResult :: Failure ) ,
197
+ } ,
198
+ ( Feature :: MaxNodeQuota ( c) , Feature :: MaxNodeQuota ( v) ) => match c > v {
199
+ true => Ok ( VerifyResult :: Success ) ,
200
+ false => Ok ( VerifyResult :: Failure ) ,
201
+ } ,
190
202
( Feature :: Test , Feature :: Test )
191
203
| ( Feature :: AggregateIndex , Feature :: AggregateIndex )
192
204
| ( Feature :: ComputedColumn , Feature :: ComputedColumn )
@@ -201,8 +213,8 @@ impl Feature {
201
213
| ( Feature :: StorageEncryption , Feature :: StorageEncryption )
202
214
| ( Feature :: HilbertClustering , Feature :: HilbertClustering )
203
215
| ( Feature :: NgramIndex , Feature :: NgramIndex )
204
- | ( Feature :: VectorIndex , Feature :: VectorIndex ) => Ok ( true ) ,
205
- ( _, _) => Ok ( false ) ,
216
+ | ( Feature :: VectorIndex , Feature :: VectorIndex ) => Ok ( VerifyResult :: Success ) ,
217
+ ( _, _) => Ok ( VerifyResult :: MissMatch ) ,
206
218
}
207
219
}
208
220
}
0 commit comments