Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16cf340

Browse files
committed
keep order of keys without reversing
1 parent002f872 commit16cf340

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

‎src/main/java/org/dataloader/DataLoaderHelper.java‎

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
importjava.time.Clock;
2020
importjava.time.Instant;
2121
importjava.util.ArrayList;
22+
importjava.util.Arrays;
2223
importjava.util.Collection;
23-
importjava.util.Collections;
2424
importjava.util.LinkedHashSet;
2525
importjava.util.List;
2626
importjava.util.Map;
@@ -228,9 +228,6 @@ DispatchResult<V> dispatch() {
228228
DataLoaderInstrumentationContext<DispatchResult<?>>instrCtx =ctxOrNoopCtx(instrumentation().beginDispatch(dataLoader));
229229

230230
booleanbatchingEnabled =loaderOptions.batchingEnabled();
231-
finalList<K>keys;
232-
finalList<Object>callContexts;
233-
finalList<CompletableFuture<V>>queuedFutures;
234231

235232
LoaderQueueEntry<K,V>loaderQueueEntryHead;
236233
while (true) {
@@ -246,21 +243,21 @@ DispatchResult<V> dispatch() {
246243
}
247244
intqueueSize =calcQueueDepth(loaderQueueEntryHead);
248245
// we copy the pre-loaded set of futures ready for dispatch
249-
keys=newArrayList<>(queueSize);
250-
callContexts=newArrayList<>(queueSize);
251-
queuedFutures=newArrayList<>(queueSize);
252-
246+
Object[]keysArray=newObject[queueSize];
247+
CompletableFuture[]queuedFuturesArray=newCompletableFuture[queueSize];
248+
Object[]callContextsArray=newObject[queueSize];
249+
intindex =queueSize -1;
253250
while (loaderQueueEntryHead !=null) {
254-
keys.add(loaderQueueEntryHead.getKey());
255-
queuedFutures.add(loaderQueueEntryHead.getValue());
256-
callContexts.add(loaderQueueEntryHead.getCallContext());
251+
keysArray[index] =loaderQueueEntryHead.getKey();
252+
queuedFuturesArray[index] =loaderQueueEntryHead.getValue();
253+
callContextsArray[index] =loaderQueueEntryHead.getCallContext();
257254
loaderQueueEntryHead =loaderQueueEntryHead.prev;
255+
index--;
258256
}
259-
//TODO: to many test depend on the previous order, therefore we reverse the lists here
260-
// but this should not matter and we should change the tests
261-
Collections.reverse(keys);
262-
Collections.reverse(callContexts);
263-
Collections.reverse(queuedFutures);
257+
finalList<K>keys = (List<K>)Arrays.asList(keysArray);
258+
finalList<CompletableFuture<V>>queuedFutures =Arrays.asList(queuedFuturesArray);
259+
finalList<Object>callContexts =Arrays.asList(callContextsArray);
260+
264261
lastDispatchTime.set(now());
265262
if (!batchingEnabled) {
266263
instrCtx.onDispatched();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp