@@ -46,18 +46,18 @@ private static class ChainedDLStack {
4646 // a state for level points to a previous one
4747 // all the invocations that are linked together are the relevant invocations for the next dispatch
4848 private static class StateForLevel {
49- final @ Nullable DataLoaderInvocation dataLoaderInvocation ;
49+ final @ Nullable DataLoader dataLoader ;
5050 final boolean dispatchingStarted ;
5151 final boolean dispatchingFinished ;
5252 final boolean currentlyDelayedDispatching ;
5353 final @ Nullable StateForLevel prev ;
5454
55- public StateForLevel (@ Nullable DataLoaderInvocation dataLoaderInvocation ,
55+ public StateForLevel (@ Nullable DataLoader dataLoader ,
5656 boolean dispatchingStarted ,
5757 boolean dispatchingFinished ,
5858 boolean currentlyDelayedDispatching ,
5959 @ Nullable StateForLevel prev ) {
60- this .dataLoaderInvocation = dataLoaderInvocation ;
60+ this .dataLoader = dataLoader ;
6161 this .dispatchingStarted = dispatchingStarted ;
6262 this .dispatchingFinished = dispatchingFinished ;
6363 this .currentlyDelayedDispatching = currentlyDelayedDispatching ;
@@ -91,7 +91,7 @@ public StateForLevel(@Nullable DataLoaderInvocation dataLoaderInvocation,
9191 }
9292 }
9393
94- if (currentState == null || currentState .dataLoaderInvocation == null ) {
94+ if (currentState == null || currentState .dataLoader == null ) {
9595 if (normalDispatchOrDelayed ) {
9696 dispatchingFinished = true ;
9797 } else {
@@ -108,8 +108,7 @@ public StateForLevel(@Nullable DataLoaderInvocation dataLoaderInvocation,
108108 }
109109
110110
111- public boolean newDataLoaderInvocation (DataLoaderInvocation dataLoaderInvocation ) {
112- int level = dataLoaderInvocation .level ;
111+ public boolean newDataLoaderInvocation (int level , DataLoader dataLoader ) {
113112 AtomicReference <@ Nullable StateForLevel > currentStateRef = stateMapPerLevel .computeIfAbsent (level , __ -> new AtomicReference <>());
114113 while (true ) {
115114 StateForLevel currentState = currentStateRef .get ();
@@ -132,7 +131,7 @@ public boolean newDataLoaderInvocation(DataLoaderInvocation dataLoaderInvocation
132131 currentlyDelayedDispatching = true ;
133132 }
134133
135- StateForLevel newState = new StateForLevel (dataLoaderInvocation , dispatchingStarted , dispatchingFinished , currentlyDelayedDispatching , currentState );
134+ StateForLevel newState = new StateForLevel (dataLoader , dispatchingStarted , dispatchingFinished , currentlyDelayedDispatching , currentState );
136135
137136 if (currentStateRef .compareAndSet (currentState , newState )) {
138137 return newDelayedInvocation ;
@@ -487,20 +486,14 @@ private void dispatchAll(DataLoaderRegistry dataLoaderRegistry, int level) {
487486 private void dispatchDLCFImpl (Integer level , CallStack callStack , boolean normalOrDelayed , boolean chained ) {
488487
489488 ChainedDLStack .StateForLevel stateForLevel = callStack .chainedDLStack .aboutToStartDispatching (level , normalOrDelayed , chained );
490- if (stateForLevel == null || stateForLevel .dataLoaderInvocation == null ) {
489+ if (stateForLevel == null || stateForLevel .dataLoader == null ) {
491490 return ;
492491 }
493492
494493 List <CompletableFuture > allDispatchedCFs = new ArrayList <>();
495- while (stateForLevel != null && stateForLevel .dataLoaderInvocation != null ) {
496- final DataLoaderInvocation invocation = stateForLevel .dataLoaderInvocation ;
497- CompletableFuture <List > dispatch = invocation .dataLoader .dispatch ();
494+ while (stateForLevel != null && stateForLevel .dataLoader != null ) {
495+ CompletableFuture <List > dispatch = stateForLevel .dataLoader .dispatch ();
498496 allDispatchedCFs .add (dispatch );
499- dispatch .whenComplete ((objects , throwable ) -> {
500- if (objects != null && objects .size () > 0 ) {
501- profiler .batchLoadedNewStrategy (invocation .name , level , objects .size (), !normalOrDelayed , chained );
502- }
503- });
504497 stateForLevel = stateForLevel .prev ;
505498 }
506499 CompletableFuture .allOf (allDispatchedCFs .toArray (new CompletableFuture [0 ]))
@@ -512,51 +505,19 @@ private void dispatchDLCFImpl(Integer level, CallStack callStack, boolean normal
512505 }
513506
514507
515- public void newDataLoaderInvocation (String resultPath ,
516- int level ,
508+ public void newDataLoaderInvocation (int level ,
517509 DataLoader dataLoader ,
518- String dataLoaderName ,
519- Object key ,
520510 @ Nullable AlternativeCallContext alternativeCallContext ) {
521511 if (!enableDataLoaderChaining ) {
522512 return ;
523513 }
524- DataLoaderInvocation dataLoaderInvocation = new DataLoaderInvocation (resultPath , level , dataLoader , dataLoaderName , key );
525514 CallStack callStack = getCallStack (alternativeCallContext );
526- boolean newDelayedInvocation = callStack .chainedDLStack .newDataLoaderInvocation (dataLoaderInvocation );
515+ boolean newDelayedInvocation = callStack .chainedDLStack .newDataLoaderInvocation (level , dataLoader );
527516 if (newDelayedInvocation ) {
528517 dispatchDLCFImpl (level , callStack , false , false );
529518 }
530519 }
531520
532- /**
533- * A single data loader invocation.
534- */
535- private static class DataLoaderInvocation {
536- final String resultPath ;
537- final int level ;
538- final DataLoader dataLoader ;
539- final String name ;
540- final Object key ;
541-
542- public DataLoaderInvocation (String resultPath , int level , DataLoader dataLoader , String name , Object key ) {
543- this .resultPath = resultPath ;
544- this .level = level ;
545- this .dataLoader = dataLoader ;
546- this .name = name ;
547- this .key = key ;
548- }
549-
550- @ Override
551- public String toString () {
552- return "ResultPathWithDataLoader{" +
553- "resultPath='" + resultPath + '\'' +
554- ", level=" + level +
555- ", key=" + key +
556- ", name='" + name + '\'' +
557- '}' ;
558- }
559- }
560521
561522}
562523
0 commit comments