@@ -31,7 +31,7 @@ use core::ops::RangeBounds;
31
31
use spacetimedb_primitives:: ColList ;
32
32
use spacetimedb_sats:: {
33
33
algebraic_value:: Packed , i256, product_value:: InvalidFieldError , sum_value:: SumTag , u256, AlgebraicType ,
34
- AlgebraicValue , ProductType ,
34
+ AlgebraicValue , ProductType , F32 , F64 ,
35
35
} ;
36
36
37
37
mod key_size;
@@ -104,6 +104,8 @@ enum TypedIndexRangeIter<'a> {
104
104
BtreeI128 ( BtreeIndexRangeIter < ' a , Packed < i128 > > ) ,
105
105
BtreeU256 ( BtreeIndexRangeIter < ' a , u256 > ) ,
106
106
BtreeI256 ( BtreeIndexRangeIter < ' a , i256 > ) ,
107
+ BtreeF32 ( BtreeIndexRangeIter < ' a , F32 > ) ,
108
+ BtreeF64 ( BtreeIndexRangeIter < ' a , F64 > ) ,
107
109
BtreeString ( BtreeIndexRangeIter < ' a , Box < str > > ) ,
108
110
BtreeAV ( BtreeIndexRangeIter < ' a , AlgebraicValue > ) ,
109
111
@@ -121,6 +123,8 @@ enum TypedIndexRangeIter<'a> {
121
123
UniqueBtreeI128 ( BtreeUniqueIndexRangeIter < ' a , Packed < i128 > > ) ,
122
124
UniqueBtreeU256 ( BtreeUniqueIndexRangeIter < ' a , u256 > ) ,
123
125
UniqueBtreeI256 ( BtreeUniqueIndexRangeIter < ' a , i256 > ) ,
126
+ UniqueBtreeF32 ( BtreeUniqueIndexRangeIter < ' a , F32 > ) ,
127
+ UniqueBtreeF64 ( BtreeUniqueIndexRangeIter < ' a , F64 > ) ,
124
128
UniqueBtreeString ( BtreeUniqueIndexRangeIter < ' a , Box < str > > ) ,
125
129
UniqueBtreeAV ( BtreeUniqueIndexRangeIter < ' a , AlgebraicValue > ) ,
126
130
@@ -145,6 +149,8 @@ impl Iterator for TypedIndexRangeIter<'_> {
145
149
Self :: BtreeI128 ( this) => this. next ( ) . copied ( ) ,
146
150
Self :: BtreeU256 ( this) => this. next ( ) . copied ( ) ,
147
151
Self :: BtreeI256 ( this) => this. next ( ) . copied ( ) ,
152
+ Self :: BtreeF32 ( this) => this. next ( ) . copied ( ) ,
153
+ Self :: BtreeF64 ( this) => this. next ( ) . copied ( ) ,
148
154
Self :: BtreeString ( this) => this. next ( ) . copied ( ) ,
149
155
Self :: BtreeAV ( this) => this. next ( ) . copied ( ) ,
150
156
@@ -161,6 +167,8 @@ impl Iterator for TypedIndexRangeIter<'_> {
161
167
Self :: UniqueBtreeI128 ( this) => this. next ( ) . copied ( ) ,
162
168
Self :: UniqueBtreeU256 ( this) => this. next ( ) . copied ( ) ,
163
169
Self :: UniqueBtreeI256 ( this) => this. next ( ) . copied ( ) ,
170
+ Self :: UniqueBtreeF32 ( this) => this. next ( ) . copied ( ) ,
171
+ Self :: UniqueBtreeF64 ( this) => this. next ( ) . copied ( ) ,
164
172
Self :: UniqueBtreeString ( this) => this. next ( ) . copied ( ) ,
165
173
Self :: UniqueBtreeAV ( this) => this. next ( ) . copied ( ) ,
166
174
@@ -204,6 +212,8 @@ enum TypedIndex {
204
212
BtreeI128 ( BtreeIndex < Packed < i128 > > ) ,
205
213
BtreeU256 ( BtreeIndex < u256 > ) ,
206
214
BtreeI256 ( BtreeIndex < i256 > ) ,
215
+ BtreeF32 ( BtreeIndex < F32 > ) ,
216
+ BtreeF64 ( BtreeIndex < F64 > ) ,
207
217
BtreeString ( BtreeIndex < Box < str > > ) ,
208
218
BtreeAV ( BtreeIndex < AlgebraicValue > ) ,
209
219
@@ -222,6 +232,8 @@ enum TypedIndex {
222
232
UniqueBtreeI128 ( BtreeUniqueIndex < Packed < i128 > > ) ,
223
233
UniqueBtreeU256 ( BtreeUniqueIndex < u256 > ) ,
224
234
UniqueBtreeI256 ( BtreeUniqueIndex < i256 > ) ,
235
+ UniqueBtreeF32 ( BtreeUniqueIndex < F32 > ) ,
236
+ UniqueBtreeF64 ( BtreeUniqueIndex < F64 > ) ,
225
237
UniqueBtreeString ( BtreeUniqueIndex < Box < str > > ) ,
226
238
UniqueBtreeAV ( BtreeUniqueIndex < AlgebraicValue > ) ,
227
239
@@ -249,6 +261,8 @@ impl MemoryUsage for TypedIndex {
249
261
TypedIndex :: BtreeI128 ( this) => this. heap_usage ( ) ,
250
262
TypedIndex :: BtreeU256 ( this) => this. heap_usage ( ) ,
251
263
TypedIndex :: BtreeI256 ( this) => this. heap_usage ( ) ,
264
+ TypedIndex :: BtreeF32 ( this) => this. heap_usage ( ) ,
265
+ TypedIndex :: BtreeF64 ( this) => this. heap_usage ( ) ,
252
266
TypedIndex :: BtreeString ( this) => this. heap_usage ( ) ,
253
267
TypedIndex :: BtreeAV ( this) => this. heap_usage ( ) ,
254
268
@@ -265,6 +279,8 @@ impl MemoryUsage for TypedIndex {
265
279
TypedIndex :: UniqueBtreeI128 ( this) => this. heap_usage ( ) ,
266
280
TypedIndex :: UniqueBtreeU256 ( this) => this. heap_usage ( ) ,
267
281
TypedIndex :: UniqueBtreeI256 ( this) => this. heap_usage ( ) ,
282
+ TypedIndex :: UniqueBtreeF32 ( this) => this. heap_usage ( ) ,
283
+ TypedIndex :: UniqueBtreeF64 ( this) => this. heap_usage ( ) ,
268
284
TypedIndex :: UniqueBtreeString ( this) => this. heap_usage ( ) ,
269
285
TypedIndex :: UniqueBtreeAV ( this) => this. heap_usage ( ) ,
270
286
@@ -318,6 +334,8 @@ impl TypedIndex {
318
334
AlgebraicType :: U128 => UniqueBtreeU128 ( <_ >:: default ( ) ) ,
319
335
AlgebraicType :: I256 => UniqueBtreeI256 ( <_ >:: default ( ) ) ,
320
336
AlgebraicType :: U256 => UniqueBtreeU256 ( <_ >:: default ( ) ) ,
337
+ AlgebraicType :: F32 => UniqueBtreeF32 ( <_ >:: default ( ) ) ,
338
+ AlgebraicType :: F64 => UniqueBtreeF64 ( <_ >:: default ( ) ) ,
321
339
AlgebraicType :: String => UniqueBtreeString ( <_ >:: default ( ) ) ,
322
340
// For a plain enum, use `u8` as the native type.
323
341
// We use a direct index here
@@ -343,6 +361,8 @@ impl TypedIndex {
343
361
AlgebraicType :: U128 => BtreeU128 ( <_ >:: default ( ) ) ,
344
362
AlgebraicType :: I256 => BtreeI256 ( <_ >:: default ( ) ) ,
345
363
AlgebraicType :: U256 => BtreeU256 ( <_ >:: default ( ) ) ,
364
+ AlgebraicType :: F32 => BtreeF32 ( <_ >:: default ( ) ) ,
365
+ AlgebraicType :: F64 => BtreeF64 ( <_ >:: default ( ) ) ,
346
366
AlgebraicType :: String => BtreeString ( <_ >:: default ( ) ) ,
347
367
348
368
// For a plain enum, use `u8` as the native type.
@@ -375,6 +395,8 @@ impl TypedIndex {
375
395
BtreeI128 ( _) => BtreeI128 ( <_ >:: default ( ) ) ,
376
396
BtreeU256 ( _) => BtreeU256 ( <_ >:: default ( ) ) ,
377
397
BtreeI256 ( _) => BtreeI256 ( <_ >:: default ( ) ) ,
398
+ BtreeF32 ( _) => BtreeF32 ( <_ >:: default ( ) ) ,
399
+ BtreeF64 ( _) => BtreeF64 ( <_ >:: default ( ) ) ,
378
400
BtreeString ( _) => BtreeString ( <_ >:: default ( ) ) ,
379
401
BtreeAV ( _) => BtreeAV ( <_ >:: default ( ) ) ,
380
402
UniqueBtreeBool ( _) => UniqueBtreeBool ( <_ >:: default ( ) ) ,
@@ -391,6 +413,8 @@ impl TypedIndex {
391
413
UniqueBtreeI128 ( _) => UniqueBtreeI128 ( <_ >:: default ( ) ) ,
392
414
UniqueBtreeU256 ( _) => UniqueBtreeU256 ( <_ >:: default ( ) ) ,
393
415
UniqueBtreeI256 ( _) => UniqueBtreeI256 ( <_ >:: default ( ) ) ,
416
+ UniqueBtreeF32 ( _) => UniqueBtreeF32 ( <_ >:: default ( ) ) ,
417
+ UniqueBtreeF64 ( _) => UniqueBtreeF64 ( <_ >:: default ( ) ) ,
394
418
UniqueBtreeString ( _) => UniqueBtreeString ( <_ >:: default ( ) ) ,
395
419
UniqueBtreeAV ( _) => UniqueBtreeAV ( <_ >:: default ( ) ) ,
396
420
UniqueDirectU8 ( _) => UniqueDirectU8 ( <_ >:: default ( ) ) ,
@@ -407,7 +431,7 @@ impl TypedIndex {
407
431
match self {
408
432
BtreeBool ( _) | BtreeU8 ( _) | BtreeSumTag ( _) | BtreeI8 ( _) | BtreeU16 ( _) | BtreeI16 ( _) | BtreeU32 ( _)
409
433
| BtreeI32 ( _) | BtreeU64 ( _) | BtreeI64 ( _) | BtreeU128 ( _) | BtreeI128 ( _) | BtreeU256 ( _) | BtreeI256 ( _)
410
- | BtreeString ( _) | BtreeAV ( _) => false ,
434
+ | BtreeF32 ( _ ) | BtreeF64 ( _ ) | BtreeString ( _) | BtreeAV ( _) => false ,
411
435
UniqueBtreeBool ( _)
412
436
| UniqueBtreeU8 ( _)
413
437
| UniqueBtreeSumTag ( _)
@@ -422,6 +446,8 @@ impl TypedIndex {
422
446
| UniqueBtreeI128 ( _)
423
447
| UniqueBtreeU256 ( _)
424
448
| UniqueBtreeI256 ( _)
449
+ | UniqueBtreeF32 ( _)
450
+ | UniqueBtreeF64 ( _)
425
451
| UniqueBtreeString ( _)
426
452
| UniqueBtreeAV ( _)
427
453
| UniqueDirectU8 ( _)
@@ -541,6 +567,8 @@ impl TypedIndex {
541
567
Self :: BtreeI128 ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
542
568
Self :: BtreeU256 ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
543
569
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) ,
544
572
Self :: BtreeString ( idx) => mm_insert_at_type ( idx, cols, row_ref) ,
545
573
Self :: BtreeAV ( this) => {
546
574
// SAFETY: Caller promised that any `col` in `cols` is in-bounds of `row_ref`'s layout.
@@ -567,6 +595,8 @@ impl TypedIndex {
567
595
Self :: UniqueBtreeI128 ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
568
596
Self :: UniqueBtreeU256 ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
569
597
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) ,
570
600
Self :: UniqueBtreeString ( idx) => um_insert_at_type ( idx, cols, row_ref) ,
571
601
Self :: UniqueBtreeAV ( this) => {
572
602
// SAFETY: Caller promised that any `col` in `cols` is in-bounds of `row_ref`'s layout.
@@ -667,6 +697,8 @@ impl TypedIndex {
667
697
Self :: BtreeI128 ( this) => mm_delete_at_type ( this, cols, row_ref) ,
668
698
Self :: BtreeU256 ( this) => mm_delete_at_type ( this, cols, row_ref) ,
669
699
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) ,
670
702
Self :: BtreeString ( this) => mm_delete_at_type ( this, cols, row_ref) ,
671
703
Self :: BtreeAV ( this) => {
672
704
let key = row_ref. project ( cols) ?;
@@ -692,6 +724,8 @@ impl TypedIndex {
692
724
Self :: UniqueBtreeI128 ( this) => um_delete_at_type ( this, cols, row_ref) ,
693
725
Self :: UniqueBtreeU256 ( this) => um_delete_at_type ( this, cols, row_ref) ,
694
726
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) ,
695
729
Self :: UniqueBtreeString ( this) => um_delete_at_type ( this, cols, row_ref) ,
696
730
Self :: UniqueBtreeAV ( this) => {
697
731
let key = row_ref. project ( cols) ?;
@@ -748,6 +782,8 @@ impl TypedIndex {
748
782
BtreeI128 ( this) => BTree ( mm_iter_at_type ( this, key, AlgebraicValue :: as_i128) ) ,
749
783
BtreeU256 ( this) => BTree ( mm_iter_at_type ( this, key, |av| av. as_u256 ( ) . map ( |x| & * * x) ) ) ,
750
784
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) ) ,
751
787
BtreeString ( this) => BTree ( mm_iter_at_type ( this, key, AlgebraicValue :: as_string) ) ,
752
788
BtreeAV ( this) => BTree ( this. values_in_point ( key) ) ,
753
789
@@ -765,6 +801,8 @@ impl TypedIndex {
765
801
UniqueBtreeI128 ( this) => UniqueBTree ( um_iter_at_type ( this, key, AlgebraicValue :: as_i128) ) ,
766
802
UniqueBtreeU256 ( this) => UniqueBTree ( um_iter_at_type ( this, key, |av| av. as_u256 ( ) . map ( |x| & * * x) ) ) ,
767
803
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) ) ,
768
806
UniqueBtreeString ( this) => UniqueBTree ( um_iter_at_type ( this, key, AlgebraicValue :: as_string) ) ,
769
807
UniqueBtreeAV ( this) => UniqueBTree ( this. values_in_point ( key) ) ,
770
808
@@ -836,6 +874,8 @@ impl TypedIndex {
836
874
Self :: BtreeI128 ( this) => BtreeI128 ( mm_iter_at_type ( this, range, AlgebraicValue :: as_i128) ) ,
837
875
Self :: BtreeU256 ( this) => BtreeU256 ( mm_iter_at_type ( this, range, |av| av. as_u256 ( ) . map ( |x| & * * x) ) ) ,
838
876
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) ) ,
839
879
Self :: BtreeString ( this) => BtreeString ( mm_iter_at_type ( this, range, AlgebraicValue :: as_string) ) ,
840
880
Self :: BtreeAV ( this) => BtreeAV ( this. values_in_range ( range) ) ,
841
881
@@ -851,6 +891,8 @@ impl TypedIndex {
851
891
Self :: UniqueBtreeI64 ( this) => UniqueBtreeI64 ( um_iter_at_type ( this, range, AlgebraicValue :: as_i64) ) ,
852
892
Self :: UniqueBtreeU128 ( this) => UniqueBtreeU128 ( um_iter_at_type ( this, range, AlgebraicValue :: as_u128) ) ,
853
893
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) ) ,
854
896
Self :: UniqueBtreeU256 ( this) => {
855
897
UniqueBtreeU256 ( um_iter_at_type ( this, range, |av| av. as_u256 ( ) . map ( |x| & * * x) ) )
856
898
}
@@ -903,6 +945,8 @@ impl TypedIndex {
903
945
Self :: BtreeI128 ( this) => this. clear ( ) ,
904
946
Self :: BtreeU256 ( this) => this. clear ( ) ,
905
947
Self :: BtreeI256 ( this) => this. clear ( ) ,
948
+ Self :: BtreeF32 ( this) => this. clear ( ) ,
949
+ Self :: BtreeF64 ( this) => this. clear ( ) ,
906
950
Self :: BtreeString ( this) => this. clear ( ) ,
907
951
Self :: BtreeAV ( this) => this. clear ( ) ,
908
952
@@ -919,6 +963,8 @@ impl TypedIndex {
919
963
Self :: UniqueBtreeI128 ( this) => this. clear ( ) ,
920
964
Self :: UniqueBtreeU256 ( this) => this. clear ( ) ,
921
965
Self :: UniqueBtreeI256 ( this) => this. clear ( ) ,
966
+ Self :: UniqueBtreeF32 ( this) => this. clear ( ) ,
967
+ Self :: UniqueBtreeF64 ( this) => this. clear ( ) ,
922
968
Self :: UniqueBtreeString ( this) => this. clear ( ) ,
923
969
Self :: UniqueBtreeAV ( this) => this. clear ( ) ,
924
970
@@ -951,6 +997,8 @@ impl TypedIndex {
951
997
Self :: BtreeI128 ( this) => this. len ( ) ,
952
998
Self :: BtreeU256 ( this) => this. len ( ) ,
953
999
Self :: BtreeI256 ( this) => this. len ( ) ,
1000
+ Self :: BtreeF32 ( this) => this. len ( ) ,
1001
+ Self :: BtreeF64 ( this) => this. len ( ) ,
954
1002
Self :: BtreeString ( this) => this. len ( ) ,
955
1003
Self :: BtreeAV ( this) => this. len ( ) ,
956
1004
@@ -967,6 +1015,8 @@ impl TypedIndex {
967
1015
Self :: UniqueBtreeI128 ( this) => this. len ( ) ,
968
1016
Self :: UniqueBtreeU256 ( this) => this. len ( ) ,
969
1017
Self :: UniqueBtreeI256 ( this) => this. len ( ) ,
1018
+ Self :: UniqueBtreeF32 ( this) => this. len ( ) ,
1019
+ Self :: UniqueBtreeF64 ( this) => this. len ( ) ,
970
1020
Self :: UniqueBtreeString ( this) => this. len ( ) ,
971
1021
Self :: UniqueBtreeAV ( this) => this. len ( ) ,
972
1022
@@ -993,6 +1043,8 @@ impl TypedIndex {
993
1043
Self :: BtreeI128 ( this) => this. num_keys ( ) ,
994
1044
Self :: BtreeU256 ( this) => this. num_keys ( ) ,
995
1045
Self :: BtreeI256 ( this) => this. num_keys ( ) ,
1046
+ Self :: BtreeF32 ( this) => this. num_keys ( ) ,
1047
+ Self :: BtreeF64 ( this) => this. num_keys ( ) ,
996
1048
Self :: BtreeString ( this) => this. num_keys ( ) ,
997
1049
Self :: BtreeAV ( this) => this. num_keys ( ) ,
998
1050
@@ -1009,6 +1061,8 @@ impl TypedIndex {
1009
1061
Self :: UniqueBtreeI128 ( this) => this. num_keys ( ) ,
1010
1062
Self :: UniqueBtreeU256 ( this) => this. num_keys ( ) ,
1011
1063
Self :: UniqueBtreeI256 ( this) => this. num_keys ( ) ,
1064
+ Self :: UniqueBtreeF32 ( this) => this. num_keys ( ) ,
1065
+ Self :: UniqueBtreeF64 ( this) => this. num_keys ( ) ,
1012
1066
Self :: UniqueBtreeString ( this) => this. num_keys ( ) ,
1013
1067
Self :: UniqueBtreeAV ( this) => this. num_keys ( ) ,
1014
1068
0 commit comments