@@ -71,6 +71,35 @@ class RoaringBitmap {
7171 this . keysAndCardinalities [ 2 ] = lspecial - 1 ;
7272 this . consumed_len_bytes = 5 ;
7373 return this ;
74+ } else if ( u8array [ i ] > 0xd0 ) {
75+ // Special representation of tiny sets that are close together
76+ const lspecial = u8array [ i ] & 0x0f ;
77+ this . keysAndCardinalities = new Uint8Array ( lspecial * 4 ) ;
78+ let pspecial = i + 1 ;
79+ let key = u8array [ pspecial + 2 ] | ( u8array [ pspecial + 3 ] << 8 ) ;
80+ let value = u8array [ pspecial ] | ( u8array [ pspecial + 1 ] << 8 ) ;
81+ let entry = ( key << 16 ) | value ;
82+ let container ;
83+ container = new RoaringBitmapArray ( 1 , new Uint8Array ( 4 ) ) ;
84+ container . array [ 0 ] = value & 0xFF ;
85+ container . array [ 1 ] = ( value >> 8 ) & 0xFF ;
86+ this . containers . push ( container ) ;
87+ this . keysAndCardinalities [ 0 ] = key ;
88+ this . keysAndCardinalities [ 1 ] = key >> 8 ;
89+ pspecial += 4 ;
90+ for ( let ispecial = 1 ; ispecial < lspecial ; ispecial += 1 ) {
91+ entry += u8array [ pspecial ] ;
92+ value = entry & 0xffff ;
93+ key = entry >> 16 ;
94+ container = this . addToArrayAt ( key ) ;
95+ const cardinalityOld = container . cardinality ;
96+ container . array [ cardinalityOld * 2 ] = value & 0xFF ;
97+ container . array [ ( cardinalityOld * 2 ) + 1 ] = ( value >> 8 ) & 0xFF ;
98+ container . cardinality = cardinalityOld + 1 ;
99+ pspecial += 1 ;
100+ }
101+ this . consumed_len_bytes = pspecial - i ;
102+ return this ;
74103 } else if ( u8array [ i ] < 0x3a ) {
75104 // Special representation of tiny sets with arbitrary 32-bit integers
76105 const lspecial = u8array [ i ] ;
@@ -2330,6 +2359,7 @@ function loadDatabase(hooks) {
23302359 leaves_count = 0 ;
23312360 }
23322361 i += 1 ;
2362+ /** @type {Uint8Array } */
23332363 let data = EMPTY_UINT8 ;
23342364 if ( ! is_suffixes_only && dlen !== 0 ) {
23352365 data = encoded . subarray ( i , i + dlen ) ;
@@ -2343,6 +2373,7 @@ function loadDatabase(hooks) {
23432373 const branch_dlen = encoded [ i ] & 0x0f ;
23442374 const branch_leaves_count = ( ( encoded [ i ] >> 4 ) & 0x0f ) + 1 ;
23452375 i += 1 ;
2376+ /** @type {Uint8Array } */
23462377 let branch_data = EMPTY_UINT8 ;
23472378 if ( ! is_suffixes_only && branch_dlen !== 0 ) {
23482379 branch_data = encoded . subarray ( i , i + branch_dlen ) ;
0 commit comments