Class DataLoaderHelper<K,V>
java.lang.Object
org.dataloader.DataLoaderHelper<K,V>
- Type Parameters:
K- the type of keysV- the type of values
This helps break up the large DataLoader class functionality and it contains the logic to dispatch the
promises on behalf of its peer dataloader
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Objectprivate final Clockprivate final DataLoader<K, V> private final AtomicReference<Instant> private final DataLoaderOptionsprivate final List<DataLoaderHelper.LoaderQueueEntry<K, CompletableFuture<V>>> private final CompletableFuture<List<Try<V>>> private final StatisticsCollectorprivate final ValueCache<K, V> -
Constructor Summary
ConstructorsConstructorDescriptionDataLoaderHelper(DataLoader<K, V> dataLoader, Object batchLoadFunction, DataLoaderOptions loaderOptions, CacheMap<Object, V> futureCache, ValueCache<K, V> valueCache, StatisticsCollector stats, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidassertResultSize(List<K> keys, List<V> values) (package private) DispatchResult<V> dispatch()(package private) intprivate CompletableFuture<List<V>> dispatchQueueBatch(List<K> keys, List<Object> callContexts, List<CompletableFuture<V>> queuedFutures) (package private) ObjectgetCacheKey(K key) (package private) ObjectgetCacheKeyWithContext(K key, Object context) private CompletableFuture<List<Try<V>>> getFromValueCache(List<K> keys) (package private) Optional<CompletableFuture<V>> getIfCompleted(K key) (package private) Optional<CompletableFuture<V>> getIfPresent(K key) private CompletableFuture<List<V>> invokeListBatchLoader(List<K> keys, BatchLoaderEnvironment environment) (package private) CompletableFuture<List<V>> invokeLoader(List<K> keys, List<Object> keyContexts) (package private) CompletableFuture<List<V>> invokeLoader(List<K> keys, List<Object> keyContexts, boolean cachingEnabled) (package private) CompletableFuture<V> invokeLoaderImmediately(K key, Object keyContext, boolean cachingEnabled) private CompletableFuture<List<V>> invokeMapBatchLoader(List<K> keys, BatchLoaderEnvironment environment) private boolean(package private) CompletableFuture<V> private CompletableFuture<V> loadFromCache(K key, Object loadContext, boolean batchingEnabled) (package private) Instantnow()private voidprivate CompletableFuture<V> queueOrInvokeLoader(K key, Object loadContext, boolean batchingEnabled, boolean cachingEnabled) private CompletableFuture<List<V>> private CompletableFuture<List<V>> sliceIntoBatchesOfBatches(List<K> keys, List<CompletableFuture<V>> queuedFutures, List<Object> callContexts, int maxBatchSize)
-
Field Details
-
dataLoader
-
batchLoadFunction
-
loaderOptions
-
futureCache
-
valueCache
-
loaderQueue
-
stats
-
clock
-
lastDispatchTime
-
NOT_SUPPORTED_LIST
-
NOT_SUPPORTED
-
ALWAYS_FAILED
-
-
Constructor Details
-
DataLoaderHelper
DataLoaderHelper(DataLoader<K, V> dataLoader, Object batchLoadFunction, DataLoaderOptions loaderOptions, CacheMap<Object, V> futureCache, ValueCache<K, V> valueCache, StatisticsCollector stats, Clock clock)
-
-
Method Details
-
now
Instant now() -
getLastDispatchTime
-
getIfPresent
-
getIfCompleted
-
load
-
getCacheKey
-
getCacheKeyWithContext
-
dispatch
DispatchResult<V> dispatch() -
sliceIntoBatchesOfBatches
private CompletableFuture<List<V>> sliceIntoBatchesOfBatches(List<K> keys, List<CompletableFuture<V>> queuedFutures, List<Object> callContexts, int maxBatchSize) -
dispatchQueueBatch
private CompletableFuture<List<V>> dispatchQueueBatch(List<K> keys, List<Object> callContexts, List<CompletableFuture<V>> queuedFutures) -
assertResultSize
-
possiblyClearCacheEntriesOnExceptions
-
loadFromCache
-
queueOrInvokeLoader
private CompletableFuture<V> queueOrInvokeLoader(K key, Object loadContext, boolean batchingEnabled, boolean cachingEnabled) -
invokeLoaderImmediately
-
invokeLoader
-
invokeLoader
-
invokeListBatchLoader
private CompletableFuture<List<V>> invokeListBatchLoader(List<K> keys, BatchLoaderEnvironment environment) -
invokeMapBatchLoader
private CompletableFuture<List<V>> invokeMapBatchLoader(List<K> keys, BatchLoaderEnvironment environment) -
isMapLoader
private boolean isMapLoader() -
dispatchDepth
int dispatchDepth() -
getFromValueCache
-
setToValueCache
-