@@ -332,6 +332,86 @@ fn clears() -> anyhow::Result<()> {
332
332
Ok ( ( ) )
333
333
}
334
334
335
+ #[ test]
336
+ fn clears_respect_index_order ( ) -> anyhow:: Result < ( ) > {
337
+ re_log:: setup_logging ( ) ;
338
+
339
+ let mut db = EntityDb :: new ( StoreId :: random ( re_log_types:: StoreKind :: Recording ) ) ;
340
+
341
+ let timeline_frame = Timeline :: new_sequence ( "frame" ) ;
342
+
343
+ let entity_path: EntityPath = "parent" . into ( ) ;
344
+
345
+ let row_id1 = RowId :: new ( ) ;
346
+ let row_id2 = row_id1. next ( ) ;
347
+ let row_id3 = row_id2. next ( ) ;
348
+
349
+ let timepoint = TimePoint :: from_iter ( [ ( timeline_frame, 10 ) ] ) ;
350
+
351
+ let point = MyPoint :: new ( 1.0 , 2.0 ) ;
352
+ let row = DataRow :: from_component_batches (
353
+ row_id2,
354
+ timepoint. clone ( ) ,
355
+ entity_path. clone ( ) ,
356
+ [ & [ point] as _ ] ,
357
+ ) ?;
358
+
359
+ db. add_data_row ( row) ?;
360
+
361
+ {
362
+ let query = LatestAtQuery :: new ( timeline_frame, 11 ) ;
363
+ let ( _, _, got_point) =
364
+ query_latest_component :: < MyPoint > ( & db, & entity_path, & query) . unwrap ( ) ;
365
+ similar_asserts:: assert_eq!( point, got_point) ;
366
+ }
367
+
368
+ let clear = Clear :: recursive ( ) ;
369
+ let row = DataRow :: from_component_batches (
370
+ row_id1, // older row id!
371
+ timepoint. clone ( ) ,
372
+ entity_path. clone ( ) ,
373
+ clear. as_component_batches ( ) . iter ( ) . map ( |b| b. as_ref ( ) ) ,
374
+ ) ?;
375
+
376
+ db. add_data_row ( row) ?;
377
+
378
+ {
379
+ let query = LatestAtQuery :: new ( timeline_frame, 11 ) ;
380
+
381
+ let ( _, _, got_point) =
382
+ query_latest_component :: < MyPoint > ( & db, & entity_path, & query) . unwrap ( ) ;
383
+ similar_asserts:: assert_eq!( point, got_point) ;
384
+
385
+ // the `Clear` component itself doesn't get cleared!
386
+ let ( _, _, got_clear) =
387
+ query_latest_component :: < ClearIsRecursive > ( & db, & entity_path, & query) . unwrap ( ) ;
388
+ similar_asserts:: assert_eq!( clear. is_recursive, got_clear) ;
389
+ }
390
+
391
+ let clear = Clear :: recursive ( ) ;
392
+ let row = DataRow :: from_component_batches (
393
+ row_id3, // newer row id!
394
+ timepoint,
395
+ entity_path. clone ( ) ,
396
+ clear. as_component_batches ( ) . iter ( ) . map ( |b| b. as_ref ( ) ) ,
397
+ ) ?;
398
+
399
+ db. add_data_row ( row) ?;
400
+
401
+ {
402
+ let query = LatestAtQuery :: new ( timeline_frame, 11 ) ;
403
+
404
+ assert ! ( query_latest_component:: <MyPoint >( & db, & entity_path, & query) . is_none( ) ) ;
405
+
406
+ // the `Clear` component itself doesn't get cleared!
407
+ let ( _, _, got_clear) =
408
+ query_latest_component :: < ClearIsRecursive > ( & db, & entity_path, & query) . unwrap ( ) ;
409
+ similar_asserts:: assert_eq!( clear. is_recursive, got_clear) ;
410
+ }
411
+
412
+ Ok ( ( ) )
413
+ }
414
+
335
415
#[ test]
336
416
fn clear_and_gc ( ) -> anyhow:: Result < ( ) > {
337
417
use re_data_store:: DataStoreStats ;
0 commit comments