@@ -21,6 +21,7 @@ use std::sync::Arc;
21
21
22
22
use differential_dataflow:: difference:: Semigroup ;
23
23
use differential_dataflow:: lattice:: Lattice ;
24
+ use itertools:: Itertools ;
24
25
use mz_build_info:: { BuildInfo , build_info} ;
25
26
use mz_dyncfg:: ConfigSet ;
26
27
use mz_ore:: { instrument, soft_assert_or_log} ;
@@ -32,22 +33,20 @@ use semver::Version;
32
33
use timely:: progress:: { Antichain , Timestamp } ;
33
34
34
35
use crate :: async_runtime:: IsolatedRuntime ;
35
- use crate :: batch:: { BATCH_DELETE_ENABLED , BLOB_TARGET_SIZE , Batch , BatchBuilder , ProtoBatch } ;
36
+ use crate :: batch:: { BATCH_DELETE_ENABLED , Batch , BatchBuilder , ProtoBatch } ;
36
37
use crate :: cache:: { PersistClientCache , StateCache } ;
37
- use crate :: cfg:: { COMPACTION_MEMORY_BOUND_BYTES , PersistConfig } ;
38
+ use crate :: cfg:: PersistConfig ;
38
39
use crate :: critical:: { CriticalReaderId , SinceHandle } ;
39
40
use crate :: error:: InvalidUsage ;
40
- use crate :: fetch:: { BatchFetcher , BatchFetcherConfig , FetchBatchFilter , Lease } ;
41
+ use crate :: fetch:: { BatchFetcher , BatchFetcherConfig , Lease } ;
41
42
use crate :: internal:: compact:: Compactor ;
42
43
use crate :: internal:: encoding:: parse_id;
43
44
use crate :: internal:: gc:: GarbageCollector ;
44
45
use crate :: internal:: machine:: { Machine , retry_external} ;
45
46
use crate :: internal:: state_versions:: StateVersions ;
46
- use crate :: iter:: { Consolidator , StructuredSort } ;
47
47
use crate :: metrics:: Metrics ;
48
48
use crate :: read:: {
49
- Cursor , CursorConsolidator , LazyPartStats , LeasedReaderId , READER_LEASE_DURATION , ReadHandle ,
50
- Since ,
49
+ Cursor , LazyPartStats , LeasedReaderId , READER_LEASE_DURATION , ReadHandle , Since ,
51
50
} ;
52
51
use crate :: rpc:: PubSubSender ;
53
52
use crate :: schema:: CaESchema ;
@@ -643,57 +642,31 @@ impl PersistClient {
643
642
should_fetch_part : impl for < ' a > Fn ( Option < & ' a LazyPartStats > ) -> bool ,
644
643
) -> Result < Cursor < K , V , T , D > , Since < T > >
645
644
where
646
- K : Debug + Codec ,
647
- V : Debug + Codec ,
645
+ K : Debug + Codec + Ord ,
646
+ V : Debug + Codec + Ord ,
648
647
T : Timestamp + Lattice + Codec64 + Sync ,
649
648
D : Semigroup + Ord + Codec64 + Send + Sync ,
650
649
{
651
- let context = format ! ( "{}[as_of={:?}]" , shard_id, as_of. elements( ) ) ;
652
- let filter = FetchBatchFilter :: Snapshot {
653
- as_of : as_of. clone ( ) ,
654
- } ;
655
-
650
+ // WIP!
651
+ let lease = Lease :: new ( SeqNo ( 0 ) ) ;
656
652
let shard_metrics = self . metrics . shards . shard ( & shard_id, "peek_stash" ) ;
657
653
658
- let consolidator = {
659
- let mut consolidator = Consolidator :: new (
660
- context,
661
- shard_id,
662
- StructuredSort :: new ( read_schemas. clone ( ) ) ,
663
- Arc :: clone ( & self . blob ) ,
664
- Arc :: clone ( & self . metrics ) ,
665
- Arc :: clone ( & shard_metrics) ,
666
- self . metrics . read . snapshot . clone ( ) ,
667
- filter,
668
- COMPACTION_MEMORY_BOUND_BYTES . get ( & self . cfg ) ,
669
- ) ;
670
- for batch in batches {
671
- for ( meta, run) in batch. batch . runs ( ) {
672
- consolidator. enqueue_run (
673
- & batch. batch . desc ,
674
- meta,
675
- run. into_iter ( )
676
- . filter ( |p| should_fetch_part ( p. stats ( ) ) )
677
- . cloned ( ) ,
678
- ) ;
679
- }
680
- }
681
- CursorConsolidator :: Structured {
682
- consolidator,
683
- // This default may end up consolidating more records than previously
684
- // for cases like fast-path peeks, where only the first few entries are used.
685
- // If this is a noticeable performance impact, thread the max-len in from the caller.
686
- max_len : self . cfg . compaction_yield_after_n_updates ,
687
- max_bytes : BLOB_TARGET_SIZE . get ( & self . cfg ) . max ( 1 ) ,
688
- }
689
- } ;
654
+ let hollow_batches = batches. iter ( ) . map ( |b| b. batch . clone ( ) ) . collect_vec ( ) ;
690
655
691
- Ok ( Cursor {
692
- consolidator,
693
- // WIP: What to do about this?
694
- _lease : Lease :: new ( SeqNo ( 0 ) ) ,
656
+ ReadHandle :: read_batches_consolidated (
657
+ & self . cfg ,
658
+ Arc :: clone ( & self . metrics ) ,
659
+ shard_metrics,
660
+ self . metrics . read . snapshot . clone ( ) ,
661
+ Arc :: clone ( & self . blob ) ,
662
+ lease,
663
+ shard_id,
664
+ as_of,
695
665
read_schemas,
696
- } )
666
+ & hollow_batches,
667
+ should_fetch_part,
668
+ )
669
+ . await
697
670
}
698
671
699
672
/// Returns the requested schema, if known at the current state.
0 commit comments