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