@@ -31,7 +31,7 @@ use core::ops::RangeBounds;
3131use spacetimedb_primitives:: ColList ;
3232use spacetimedb_sats:: {
3333 algebraic_value:: Packed , i256, product_value:: InvalidFieldError , sum_value:: SumTag , u256, AlgebraicType ,
34- AlgebraicValue , ProductType ,
34+ AlgebraicValue , ProductType , F32 , F64 ,
3535} ;
3636
3737mod key_size;
@@ -104,6 +104,8 @@ enum TypedIndexRangeIter<'a> {
104104 BtreeI128 ( BtreeIndexRangeIter < ' a , Packed < i128 > > ) ,
105105 BtreeU256 ( BtreeIndexRangeIter < ' a , u256 > ) ,
106106 BtreeI256 ( BtreeIndexRangeIter < ' a , i256 > ) ,
107+ BtreeF32 ( BtreeIndexRangeIter < ' a , F32 > ) ,
108+ BtreeF64 ( BtreeIndexRangeIter < ' a , F64 > ) ,
107109 BtreeString ( BtreeIndexRangeIter < ' a , Box < str > > ) ,
108110 BtreeAV ( BtreeIndexRangeIter < ' a , AlgebraicValue > ) ,
109111
@@ -121,6 +123,8 @@ enum TypedIndexRangeIter<'a> {
121123 UniqueBtreeI128 ( BtreeUniqueIndexRangeIter < ' a , Packed < i128 > > ) ,
122124 UniqueBtreeU256 ( BtreeUniqueIndexRangeIter < ' a , u256 > ) ,
123125 UniqueBtreeI256 ( BtreeUniqueIndexRangeIter < ' a , i256 > ) ,
126+ UniqueBtreeF32 ( BtreeUniqueIndexRangeIter < ' a , F32 > ) ,
127+ UniqueBtreeF64 ( BtreeUniqueIndexRangeIter < ' a , F64 > ) ,
124128 UniqueBtreeString ( BtreeUniqueIndexRangeIter < ' a , Box < str > > ) ,
125129 UniqueBtreeAV ( BtreeUniqueIndexRangeIter < ' a , AlgebraicValue > ) ,
126130
@@ -145,6 +149,8 @@ impl Iterator for TypedIndexRangeIter<'_> {
145149 Self :: BtreeI128 ( this) => this. next ( ) . copied ( ) ,
146150 Self :: BtreeU256 ( this) => this. next ( ) . copied ( ) ,
147151 Self :: BtreeI256 ( this) => this. next ( ) . copied ( ) ,
152+ Self :: BtreeF32 ( this) => this. next ( ) . copied ( ) ,
153+ Self :: BtreeF64 ( this) => this. next ( ) . copied ( ) ,
148154 Self :: BtreeString ( this) => this. next ( ) . copied ( ) ,
149155 Self :: BtreeAV ( this) => this. next ( ) . copied ( ) ,
150156
@@ -161,6 +167,8 @@ impl Iterator for TypedIndexRangeIter<'_> {
161167 Self :: UniqueBtreeI128 ( this) => this. next ( ) . copied ( ) ,
162168 Self :: UniqueBtreeU256 ( this) => this. next ( ) . copied ( ) ,
163169 Self :: UniqueBtreeI256 ( this) => this. next ( ) . copied ( ) ,
170+ Self :: UniqueBtreeF32 ( this) => this. next ( ) . copied ( ) ,
171+ Self :: UniqueBtreeF64 ( this) => this. next ( ) . copied ( ) ,
164172 Self :: UniqueBtreeString ( this) => this. next ( ) . copied ( ) ,
165173 Self :: UniqueBtreeAV ( this) => this. next ( ) . copied ( ) ,
166174
@@ -204,6 +212,8 @@ enum TypedIndex {
204212 BtreeI128 ( BtreeIndex < Packed < i128 > > ) ,
205213 BtreeU256 ( BtreeIndex < u256 > ) ,
206214 BtreeI256 ( BtreeIndex < i256 > ) ,
215+ BtreeF32 ( BtreeIndex < F32 > ) ,
216+ BtreeF64 ( BtreeIndex < F64 > ) ,
207217 BtreeString ( BtreeIndex < Box < str > > ) ,
208218 BtreeAV ( BtreeIndex < AlgebraicValue > ) ,
209219
@@ -222,6 +232,8 @@ enum TypedIndex {
222232 UniqueBtreeI128 ( BtreeUniqueIndex < Packed < i128 > > ) ,
223233 UniqueBtreeU256 ( BtreeUniqueIndex < u256 > ) ,
224234 UniqueBtreeI256 ( BtreeUniqueIndex < i256 > ) ,
235+ UniqueBtreeF32 ( BtreeUniqueIndex < F32 > ) ,
236+ UniqueBtreeF64 ( BtreeUniqueIndex < F64 > ) ,
225237 UniqueBtreeString ( BtreeUniqueIndex < Box < str > > ) ,
226238 UniqueBtreeAV ( BtreeUniqueIndex < AlgebraicValue > ) ,
227239
@@ -249,6 +261,8 @@ impl MemoryUsage for TypedIndex {
249261 TypedIndex :: BtreeI128 ( this) => this. heap_usage ( ) ,
250262 TypedIndex :: BtreeU256 ( this) => this. heap_usage ( ) ,
251263 TypedIndex :: BtreeI256 ( this) => this. heap_usage ( ) ,
264+ TypedIndex :: BtreeF32 ( this) => this. heap_usage ( ) ,
265+ TypedIndex :: BtreeF64 ( this) => this. heap_usage ( ) ,
252266 TypedIndex :: BtreeString ( this) => this. heap_usage ( ) ,
253267 TypedIndex :: BtreeAV ( this) => this. heap_usage ( ) ,
254268
@@ -265,6 +279,8 @@ impl MemoryUsage for TypedIndex {
265279 TypedIndex :: UniqueBtreeI128 ( this) => this. heap_usage ( ) ,
266280 TypedIndex :: UniqueBtreeU256 ( this) => this. heap_usage ( ) ,
267281 TypedIndex :: UniqueBtreeI256 ( this) => this. heap_usage ( ) ,
282+ TypedIndex :: UniqueBtreeF32 ( this) => this. heap_usage ( ) ,
283+ TypedIndex :: UniqueBtreeF64 ( this) => this. heap_usage ( ) ,
268284 TypedIndex :: UniqueBtreeString ( this) => this. heap_usage ( ) ,
269285 TypedIndex :: UniqueBtreeAV ( this) => this. heap_usage ( ) ,
270286
@@ -318,6 +334,8 @@ impl TypedIndex {
318334 AlgebraicType :: U128 => UniqueBtreeU128 ( <_ >:: default ( ) ) ,
319335 AlgebraicType :: I256 => UniqueBtreeI256 ( <_ >:: default ( ) ) ,
320336 AlgebraicType :: U256 => UniqueBtreeU256 ( <_ >:: default ( ) ) ,
337+ AlgebraicType :: F32 => UniqueBtreeF32 ( <_ >:: default ( ) ) ,
338+ AlgebraicType :: F64 => UniqueBtreeF64 ( <_ >:: default ( ) ) ,
321339 AlgebraicType :: String => UniqueBtreeString ( <_ >:: default ( ) ) ,
322340 // For a plain enum, use `u8` as the native type.
323341 // We use a direct index here
@@ -343,6 +361,8 @@ impl TypedIndex {
343361 AlgebraicType :: U128 => BtreeU128 ( <_ >:: default ( ) ) ,
344362 AlgebraicType :: I256 => BtreeI256 ( <_ >:: default ( ) ) ,
345363 AlgebraicType :: U256 => BtreeU256 ( <_ >:: default ( ) ) ,
364+ AlgebraicType :: F32 => BtreeF32 ( <_ >:: default ( ) ) ,
365+ AlgebraicType :: F64 => BtreeF64 ( <_ >:: default ( ) ) ,
346366 AlgebraicType :: String => BtreeString ( <_ >:: default ( ) ) ,
347367
348368 // For a plain enum, use `u8` as the native type.
@@ -375,6 +395,8 @@ impl TypedIndex {
375395 BtreeI128 ( _) => BtreeI128 ( <_ >:: default ( ) ) ,
376396 BtreeU256 ( _) => BtreeU256 ( <_ >:: default ( ) ) ,
377397 BtreeI256 ( _) => BtreeI256 ( <_ >:: default ( ) ) ,
398+ BtreeF32 ( _) => BtreeF32 ( <_ >:: default ( ) ) ,
399+ BtreeF64 ( _) => BtreeF64 ( <_ >:: default ( ) ) ,
378400 BtreeString ( _) => BtreeString ( <_ >:: default ( ) ) ,
379401 BtreeAV ( _) => BtreeAV ( <_ >:: default ( ) ) ,
380402 UniqueBtreeBool ( _) => UniqueBtreeBool ( <_ >:: default ( ) ) ,
@@ -391,6 +413,8 @@ impl TypedIndex {
391413 UniqueBtreeI128 ( _) => UniqueBtreeI128 ( <_ >:: default ( ) ) ,
392414 UniqueBtreeU256 ( _) => UniqueBtreeU256 ( <_ >:: default ( ) ) ,
393415 UniqueBtreeI256 ( _) => UniqueBtreeI256 ( <_ >:: default ( ) ) ,
416+ UniqueBtreeF32 ( _) => UniqueBtreeF32 ( <_ >:: default ( ) ) ,
417+ UniqueBtreeF64 ( _) => UniqueBtreeF64 ( <_ >:: default ( ) ) ,
394418 UniqueBtreeString ( _) => UniqueBtreeString ( <_ >:: default ( ) ) ,
395419 UniqueBtreeAV ( _) => UniqueBtreeAV ( <_ >:: default ( ) ) ,
396420 UniqueDirectU8 ( _) => UniqueDirectU8 ( <_ >:: default ( ) ) ,
@@ -407,7 +431,7 @@ impl TypedIndex {
407431 match self {
408432 BtreeBool ( _) | BtreeU8 ( _) | BtreeSumTag ( _) | BtreeI8 ( _) | BtreeU16 ( _) | BtreeI16 ( _) | BtreeU32 ( _)
409433 | BtreeI32 ( _) | BtreeU64 ( _) | BtreeI64 ( _) | BtreeU128 ( _) | BtreeI128 ( _) | BtreeU256 ( _) | BtreeI256 ( _)
410- | BtreeString ( _) | BtreeAV ( _) => false ,
434+ | BtreeF32 ( _ ) | BtreeF64 ( _ ) | BtreeString ( _) | BtreeAV ( _) => false ,
411435 UniqueBtreeBool ( _)
412436 | UniqueBtreeU8 ( _)
413437 | UniqueBtreeSumTag ( _)
@@ -422,6 +446,8 @@ impl TypedIndex {
422446 | UniqueBtreeI128 ( _)
423447 | UniqueBtreeU256 ( _)
424448 | UniqueBtreeI256 ( _)
449+ | UniqueBtreeF32 ( _)
450+ | UniqueBtreeF64 ( _)
425451 | UniqueBtreeString ( _)
426452 | UniqueBtreeAV ( _)
427453 | UniqueDirectU8 ( _)
@@ -541,6 +567,8 @@ impl TypedIndex {
541567 Self :: BtreeI128 ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
542568 Self :: BtreeU256 ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
543569 Self :: BtreeI256 ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
570+ Self :: BtreeF32 ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
571+ Self :: BtreeF64 ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
544572 Self :: BtreeString ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
545573 Self :: BtreeAV ( this) => {
546574 // SAFETY: Caller promised that any `col` in `cols` is in-bounds of `row_ref`'s layout.
@@ -567,6 +595,8 @@ impl TypedIndex {
567595 Self :: UniqueBtreeI128 ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
568596 Self :: UniqueBtreeU256 ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
569597 Self :: UniqueBtreeI256 ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
598+ Self :: UniqueBtreeF32 ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
599+ Self :: UniqueBtreeF64 ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
570600 Self :: UniqueBtreeString ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
571601 Self :: UniqueBtreeAV ( this) => {
572602 // SAFETY: Caller promised that any `col` in `cols` is in-bounds of `row_ref`'s layout.
@@ -667,6 +697,8 @@ impl TypedIndex {
667697 Self :: BtreeI128 ( this) => mm_delete_at_type ( this, cols, row_ref) ,
668698 Self :: BtreeU256 ( this) => mm_delete_at_type ( this, cols, row_ref) ,
669699 Self :: BtreeI256 ( this) => mm_delete_at_type ( this, cols, row_ref) ,
700+ Self :: BtreeF32 ( this) => mm_delete_at_type ( this, cols, row_ref) ,
701+ Self :: BtreeF64 ( this) => mm_delete_at_type ( this, cols, row_ref) ,
670702 Self :: BtreeString ( this) => mm_delete_at_type ( this, cols, row_ref) ,
671703 Self :: BtreeAV ( this) => {
672704 let key = row_ref. project ( cols) ?;
@@ -692,6 +724,8 @@ impl TypedIndex {
692724 Self :: UniqueBtreeI128 ( this) => um_delete_at_type ( this, cols, row_ref) ,
693725 Self :: UniqueBtreeU256 ( this) => um_delete_at_type ( this, cols, row_ref) ,
694726 Self :: UniqueBtreeI256 ( this) => um_delete_at_type ( this, cols, row_ref) ,
727+ Self :: UniqueBtreeF32 ( this) => um_delete_at_type ( this, cols, row_ref) ,
728+ Self :: UniqueBtreeF64 ( this) => um_delete_at_type ( this, cols, row_ref) ,
695729 Self :: UniqueBtreeString ( this) => um_delete_at_type ( this, cols, row_ref) ,
696730 Self :: UniqueBtreeAV ( this) => {
697731 let key = row_ref. project ( cols) ?;
@@ -748,6 +782,8 @@ impl TypedIndex {
748782 BtreeI128 ( this) => BTree ( mm_iter_at_type ( this, key, AlgebraicValue :: as_i128) ) ,
749783 BtreeU256 ( this) => BTree ( mm_iter_at_type ( this, key, |av| av. as_u256 ( ) . map ( |x| & * * x) ) ) ,
750784 BtreeI256 ( this) => BTree ( mm_iter_at_type ( this, key, |av| av. as_i256 ( ) . map ( |x| & * * x) ) ) ,
785+ BtreeF32 ( this) => BTree ( mm_iter_at_type ( this, key, AlgebraicValue :: as_f32) ) ,
786+ BtreeF64 ( this) => BTree ( mm_iter_at_type ( this, key, AlgebraicValue :: as_f64) ) ,
751787 BtreeString ( this) => BTree ( mm_iter_at_type ( this, key, AlgebraicValue :: as_string) ) ,
752788 BtreeAV ( this) => BTree ( this. values_in_point ( key) ) ,
753789
@@ -765,6 +801,8 @@ impl TypedIndex {
765801 UniqueBtreeI128 ( this) => UniqueBTree ( um_iter_at_type ( this, key, AlgebraicValue :: as_i128) ) ,
766802 UniqueBtreeU256 ( this) => UniqueBTree ( um_iter_at_type ( this, key, |av| av. as_u256 ( ) . map ( |x| & * * x) ) ) ,
767803 UniqueBtreeI256 ( this) => UniqueBTree ( um_iter_at_type ( this, key, |av| av. as_i256 ( ) . map ( |x| & * * x) ) ) ,
804+ UniqueBtreeF32 ( this) => UniqueBTree ( um_iter_at_type ( this, key, AlgebraicValue :: as_f32) ) ,
805+ UniqueBtreeF64 ( this) => UniqueBTree ( um_iter_at_type ( this, key, AlgebraicValue :: as_f64) ) ,
768806 UniqueBtreeString ( this) => UniqueBTree ( um_iter_at_type ( this, key, AlgebraicValue :: as_string) ) ,
769807 UniqueBtreeAV ( this) => UniqueBTree ( this. values_in_point ( key) ) ,
770808
@@ -836,6 +874,8 @@ impl TypedIndex {
836874 Self :: BtreeI128 ( this) => BtreeI128 ( mm_iter_at_type ( this, range, AlgebraicValue :: as_i128) ) ,
837875 Self :: BtreeU256 ( this) => BtreeU256 ( mm_iter_at_type ( this, range, |av| av. as_u256 ( ) . map ( |x| & * * x) ) ) ,
838876 Self :: BtreeI256 ( this) => BtreeI256 ( mm_iter_at_type ( this, range, |av| av. as_i256 ( ) . map ( |x| & * * x) ) ) ,
877+ Self :: BtreeF32 ( this) => BtreeF32 ( mm_iter_at_type ( this, range, AlgebraicValue :: as_f32) ) ,
878+ Self :: BtreeF64 ( this) => BtreeF64 ( mm_iter_at_type ( this, range, AlgebraicValue :: as_f64) ) ,
839879 Self :: BtreeString ( this) => BtreeString ( mm_iter_at_type ( this, range, AlgebraicValue :: as_string) ) ,
840880 Self :: BtreeAV ( this) => BtreeAV ( this. values_in_range ( range) ) ,
841881
@@ -851,6 +891,8 @@ impl TypedIndex {
851891 Self :: UniqueBtreeI64 ( this) => UniqueBtreeI64 ( um_iter_at_type ( this, range, AlgebraicValue :: as_i64) ) ,
852892 Self :: UniqueBtreeU128 ( this) => UniqueBtreeU128 ( um_iter_at_type ( this, range, AlgebraicValue :: as_u128) ) ,
853893 Self :: UniqueBtreeI128 ( this) => UniqueBtreeI128 ( um_iter_at_type ( this, range, AlgebraicValue :: as_i128) ) ,
894+ Self :: UniqueBtreeF32 ( this) => UniqueBtreeF32 ( um_iter_at_type ( this, range, AlgebraicValue :: as_f32) ) ,
895+ Self :: UniqueBtreeF64 ( this) => UniqueBtreeF64 ( um_iter_at_type ( this, range, AlgebraicValue :: as_f64) ) ,
854896 Self :: UniqueBtreeU256 ( this) => {
855897 UniqueBtreeU256 ( um_iter_at_type ( this, range, |av| av. as_u256 ( ) . map ( |x| & * * x) ) )
856898 }
@@ -903,6 +945,8 @@ impl TypedIndex {
903945 Self :: BtreeI128 ( this) => this. clear ( ) ,
904946 Self :: BtreeU256 ( this) => this. clear ( ) ,
905947 Self :: BtreeI256 ( this) => this. clear ( ) ,
948+ Self :: BtreeF32 ( this) => this. clear ( ) ,
949+ Self :: BtreeF64 ( this) => this. clear ( ) ,
906950 Self :: BtreeString ( this) => this. clear ( ) ,
907951 Self :: BtreeAV ( this) => this. clear ( ) ,
908952
@@ -919,6 +963,8 @@ impl TypedIndex {
919963 Self :: UniqueBtreeI128 ( this) => this. clear ( ) ,
920964 Self :: UniqueBtreeU256 ( this) => this. clear ( ) ,
921965 Self :: UniqueBtreeI256 ( this) => this. clear ( ) ,
966+ Self :: UniqueBtreeF32 ( this) => this. clear ( ) ,
967+ Self :: UniqueBtreeF64 ( this) => this. clear ( ) ,
922968 Self :: UniqueBtreeString ( this) => this. clear ( ) ,
923969 Self :: UniqueBtreeAV ( this) => this. clear ( ) ,
924970
@@ -951,6 +997,8 @@ impl TypedIndex {
951997 Self :: BtreeI128 ( this) => this. len ( ) ,
952998 Self :: BtreeU256 ( this) => this. len ( ) ,
953999 Self :: BtreeI256 ( this) => this. len ( ) ,
1000+ Self :: BtreeF32 ( this) => this. len ( ) ,
1001+ Self :: BtreeF64 ( this) => this. len ( ) ,
9541002 Self :: BtreeString ( this) => this. len ( ) ,
9551003 Self :: BtreeAV ( this) => this. len ( ) ,
9561004
@@ -967,6 +1015,8 @@ impl TypedIndex {
9671015 Self :: UniqueBtreeI128 ( this) => this. len ( ) ,
9681016 Self :: UniqueBtreeU256 ( this) => this. len ( ) ,
9691017 Self :: UniqueBtreeI256 ( this) => this. len ( ) ,
1018+ Self :: UniqueBtreeF32 ( this) => this. len ( ) ,
1019+ Self :: UniqueBtreeF64 ( this) => this. len ( ) ,
9701020 Self :: UniqueBtreeString ( this) => this. len ( ) ,
9711021 Self :: UniqueBtreeAV ( this) => this. len ( ) ,
9721022
@@ -993,6 +1043,8 @@ impl TypedIndex {
9931043 Self :: BtreeI128 ( this) => this. num_keys ( ) ,
9941044 Self :: BtreeU256 ( this) => this. num_keys ( ) ,
9951045 Self :: BtreeI256 ( this) => this. num_keys ( ) ,
1046+ Self :: BtreeF32 ( this) => this. num_keys ( ) ,
1047+ Self :: BtreeF64 ( this) => this. num_keys ( ) ,
9961048 Self :: BtreeString ( this) => this. num_keys ( ) ,
9971049 Self :: BtreeAV ( this) => this. num_keys ( ) ,
9981050
@@ -1009,6 +1061,8 @@ impl TypedIndex {
10091061 Self :: UniqueBtreeI128 ( this) => this. num_keys ( ) ,
10101062 Self :: UniqueBtreeU256 ( this) => this. num_keys ( ) ,
10111063 Self :: UniqueBtreeI256 ( this) => this. num_keys ( ) ,
1064+ Self :: UniqueBtreeF32 ( this) => this. num_keys ( ) ,
1065+ Self :: UniqueBtreeF64 ( this) => this. num_keys ( ) ,
10121066 Self :: UniqueBtreeString ( this) => this. num_keys ( ) ,
10131067 Self :: UniqueBtreeAV ( this) => this. num_keys ( ) ,
10141068
0 commit comments