@@ -65,6 +65,9 @@ use crate::MetadataRef;
65
65
use crate :: RefreshAggregatingIndexRewriter ;
66
66
use crate :: SUPPORTED_AGGREGATING_INDEX_FUNCTIONS ;
67
67
68
+ const MAXIMUM_BLOOM_SIZE : u64 = 10 * 1024 * 1024 ;
69
+ const MINIMUM_BLOOM_SIZE : u64 = 512 ;
70
+
68
71
// valid values for inverted index option tokenizer
69
72
static INDEX_TOKENIZER_VALUES : LazyLock < HashSet < & ' static str > > = LazyLock :: new ( || {
70
73
let mut r = HashSet :: new ( ) ;
@@ -580,13 +583,49 @@ impl Binder {
580
583
let value = val. to_lowercase ( ) ;
581
584
match key. as_str ( ) {
582
585
"gram_size" => {
583
- if value. parse :: < u32 > ( ) . is_err ( ) {
584
- return Err ( ErrorCode :: IndexOptionInvalid ( format ! (
585
- "value `{value}` is not a legal number" ,
586
- ) ) ) ;
586
+ match value. parse :: < usize > ( ) {
587
+ Ok ( num) => {
588
+ if num == 0 {
589
+ return Err ( ErrorCode :: IndexOptionInvalid (
590
+ "`gram_size` cannot be 0" ,
591
+ ) ) ;
592
+ }
593
+ }
594
+ Err ( _) => {
595
+ return Err ( ErrorCode :: IndexOptionInvalid ( format ! (
596
+ "value `{value}` is not a legal number" ,
597
+ ) ) ) ;
598
+ }
587
599
}
588
600
options. insert ( "gram_size" . to_string ( ) , value) ;
589
601
}
602
+ "bloom_size" => {
603
+ match value. parse :: < u64 > ( ) {
604
+ Ok ( num) => {
605
+ if num == 0 {
606
+ return Err ( ErrorCode :: IndexOptionInvalid (
607
+ "`bloom_size` cannot be 0" ,
608
+ ) ) ;
609
+ }
610
+ if num < MINIMUM_BLOOM_SIZE {
611
+ return Err ( ErrorCode :: IndexOptionInvalid ( format ! (
612
+ "bloom_size: `{num}` is too small (bloom_size is minimum: {MINIMUM_BLOOM_SIZE})" ,
613
+ ) ) ) ;
614
+ }
615
+ if num > MAXIMUM_BLOOM_SIZE {
616
+ return Err ( ErrorCode :: IndexOptionInvalid ( format ! (
617
+ "bloom_size: `{num}` is too large (bloom_size is maximum: {MAXIMUM_BLOOM_SIZE})" ,
618
+ ) ) ) ;
619
+ }
620
+ }
621
+ Err ( _) => {
622
+ return Err ( ErrorCode :: IndexOptionInvalid ( format ! (
623
+ "value `{value}` is not a legal number" ,
624
+ ) ) ) ;
625
+ }
626
+ }
627
+ options. insert ( "bloom_size" . to_string ( ) , value) ;
628
+ }
590
629
_ => {
591
630
return Err ( ErrorCode :: IndexOptionInvalid ( format ! (
592
631
"index option `{key}` is invalid key for create ngram index statement" ,
0 commit comments