@@ -49,13 +49,6 @@ export interface BucketSource {
4949 */
5050 readonly dataSources : BucketDataSource [ ] ;
5151
52- /**
53- * BucketParameterQuerierSource describing the parameter queries / stream subqueries in this bucket/stream definition.
54- *
55- * The same source could in theory be present in multiple stream definitions.
56- */
57- readonly parameterQuerierSources : BucketParameterQuerierSourceDefinition [ ] ;
58-
5952 /**
6053 * BucketParameterLookupSource describing the parameter tables used in this bucket/stream definition.
6154 *
@@ -64,12 +57,26 @@ export interface BucketSource {
6457 readonly parameterIndexLookupCreators : ParameterIndexLookupCreator [ ] ;
6558
6659 debugRepresentation ( ) : any ;
60+
61+ hydrate ( params : CreateSourceParams ) : HydratedBucketSource ;
6762}
6863
69- export interface HydratedBucketSource {
70- readonly definition : BucketSource ;
64+ /**
65+ * Internal interface for individual queriers. This is not used on its in the public API directly, apart
66+ * from in HydratedBucketSource. Everywhere else it is just to standardize the internal functions that we re-use.
67+ */
68+ export interface BucketParameterQuerierSource {
69+ /**
70+ * Reports {@link BucketParameterQuerier}s resolving buckets that a specific stream request should have access to.
71+ *
72+ * @param result The target array to insert queriers and errors into.
73+ * @param options Options, including parameters that may affect the buckets loaded by this source.
74+ */
75+ pushBucketParameterQueriers ( result : PendingQueriers , options : GetQuerierOptions ) : void ;
76+ }
7177
72- readonly parameterQuerierSources : BucketParameterQuerierSource [ ] ;
78+ export interface HydratedBucketSource extends BucketParameterQuerierSource {
79+ readonly definition : BucketSource ;
7380}
7481
7582export type ScopedEvaluateRow = ( options : EvaluateRowOptions ) => EvaluationResult [ ] ;
@@ -145,38 +152,7 @@ export interface ParameterIndexLookupCreator {
145152 tableSyncsParameters ( table : SourceTableInterface ) : boolean ;
146153}
147154
148- /**
149- * Parameter querier source definitions define how to bucket parameter queries are evaluated.
150- *
151- * This may use request data only, or it may use parameter lookup data persisted by a BucketParameterLookupSourceDefinition.
152- */
153- export interface BucketParameterQuerierSourceDefinition {
154- /**
155- * For debug use only.
156- */
157- readonly bucketParameters : string [ ] ;
158-
159- /**
160- * The data source linked to this querier. This determines the bucket names that the querier generates.
161- *
162- * Note that queriers do not persist data themselves; they only resolve which buckets to load based on request parameters.
163- */
164- readonly querierDataSource : BucketDataSource ;
165-
166- createParameterQuerierSource ( params : CreateSourceParams ) : BucketParameterQuerierSource ;
167- }
168-
169- export interface BucketParameterQuerierSource {
170- /**
171- * Reports {@link BucketParameterQuerier}s resolving buckets that a specific stream request should have access to.
172- *
173- * @param result The target array to insert queriers and errors into.
174- * @param options Options, including parameters that may affect the buckets loaded by this source.
175- */
176- pushBucketParameterQueriers ( result : PendingQueriers , options : GetQuerierOptions ) : void ;
177- }
178-
179- export interface DebugMergedSource extends BucketParameterQuerierSource {
155+ export interface DebugMergedSource extends HydratedBucketSource {
180156 evaluateRow : ScopedEvaluateRow ;
181157 evaluateParameterRow : ScopedEvaluateParameterRow ;
182158}
@@ -247,16 +223,6 @@ export function mergeParameterIndexLookupCreators(
247223 } ;
248224}
249225
250- export function mergeParameterQuerierSources ( sources : BucketParameterQuerierSource [ ] ) : BucketParameterQuerierSource {
251- return {
252- pushBucketParameterQueriers ( result : PendingQueriers , options : GetQuerierOptions ) : void {
253- for ( let source of sources ) {
254- source . pushBucketParameterQueriers ( result , options ) ;
255- }
256- }
257- } ;
258- }
259-
260226/**
261227 * For production purposes, we typically need to operate on the different sources separately. However, for debugging,
262228 * it is useful to have a single merged source that can evaluate everything.
@@ -269,12 +235,11 @@ export function debugHydratedMergedSource(bucketSource: BucketSource, params?: C
269235 hydrationState ,
270236 bucketSource . parameterIndexLookupCreators
271237 ) ;
272- const parameterQuerierSource = mergeParameterQuerierSources (
273- bucketSource . parameterQuerierSources . map ( ( source ) => source . createParameterQuerierSource ( resolvedParams ) )
274- ) ;
238+ const hydratedBucketSource = bucketSource . hydrate ( resolvedParams ) ;
275239 return {
240+ definition : bucketSource ,
276241 evaluateParameterRow : parameterLookupSource . evaluateParameterRow . bind ( parameterLookupSource ) ,
277242 evaluateRow : dataSource . evaluateRow . bind ( dataSource ) ,
278- pushBucketParameterQueriers : parameterQuerierSource . pushBucketParameterQueriers . bind ( parameterQuerierSource )
243+ pushBucketParameterQueriers : hydratedBucketSource . pushBucketParameterQueriers . bind ( hydratedBucketSource )
279244 } ;
280245}
0 commit comments