public interface BatchLoaderScheduler
DataLoader.dispatch() is called, the BatchLoader / MappedBatchLoader function will be invoked
immediately. However, you can provide your own BatchLoaderScheduler that allows this call to be done some time into
the future. You will be passed a callback (BatchLoaderScheduler.ScheduledBatchLoaderCall / BatchLoaderScheduler.ScheduledMappedBatchLoaderCall and you are expected
to eventually call this callback method to make the batch loading happen.
Note: Because there is a DataLoaderOptions.maxBatchSize() it is possible for this scheduling to happen N times for a given DataLoader.dispatch()
call. The total set of keys will be sliced into batches themselves and then the BatchLoaderScheduler will be called for
each batch of keys. Do not assume that a single call to DataLoader.dispatch() results in a single call to BatchLoaderScheduler.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
BatchLoaderScheduler.ScheduledBatchLoaderCall<V>
This represents a callback that will invoke a
BatchLoader function under the covers |
static interface |
BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K,V>
This represents a callback that will invoke a
MappedBatchLoader function under the covers |
| Modifier and Type | Method and Description |
|---|---|
<K,V> java.util.concurrent.CompletionStage<java.util.List<V>> |
scheduleBatchLoader(BatchLoaderScheduler.ScheduledBatchLoaderCall<V> scheduledCall,
java.util.List<K> keys,
BatchLoaderEnvironment environment)
This is called to schedule a
BatchLoader call. |
<K,V> java.util.concurrent.CompletionStage<java.util.Map<K,V>> |
scheduleMappedBatchLoader(BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K,V> scheduledCall,
java.util.List<K> keys,
BatchLoaderEnvironment environment)
This is called to schedule a
MappedBatchLoader call. |
<K,V> java.util.concurrent.CompletionStage<java.util.List<V>> scheduleBatchLoader(BatchLoaderScheduler.ScheduledBatchLoaderCall<V> scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
BatchLoader call.K - the key typeV - the value typescheduledCall - the callback that needs to be invoked to allow the BatchLoader to proceed.keys - this is the list of keys that will be passed to the BatchLoader.
This is provided only for informative reasons and you cant change the keys that are usedenvironment - this is the BatchLoaderEnvironment in place,
which can be null if it's a simple BatchLoader callBatchLoader<K,V> java.util.concurrent.CompletionStage<java.util.Map<K,V>> scheduleMappedBatchLoader(BatchLoaderScheduler.ScheduledMappedBatchLoaderCall<K,V> scheduledCall, java.util.List<K> keys, BatchLoaderEnvironment environment)
MappedBatchLoader call.K - the key typeV - the value typescheduledCall - the callback that needs to be invoked to allow the MappedBatchLoader to proceed.keys - this is the list of keys that will be passed to the MappedBatchLoader.
This is provided only for informative reasons and you cant change the keys that are usedenvironment - this is the BatchLoaderEnvironment in place,
which can be null if it's a simple MappedBatchLoader callBatchLoader