public final class MultiFetch extends RiakCommand<MultiFetch.Response,List<Location>>
Riak itself does not support pipelining of requests. MutliFetch addresses this issue by using a thread to parallelize and manage a set of async fetch operations for a given set of keys.
The result of executing this command is a List
of RiakFuture
objects, each one representing a single
fetch operation. The returned RiakFuture
that contains that list completes
when all the FetchValue operations contained have finished.
MultiFetch multifetch = ...;
MultiFetch.Response response = client.execute(multifetch);
List<MyPojo> myResults = new ArrayList<MyPojo>();
for (RiakFuture<FetchValue.Response, Location> f : response)
{
try
{
FetchValue.Response response = f.get();
myResults.add(response.getValue(MyPojo.class));
}
catch (ExecutionException e)
{
// log error, etc.
}
}
The maximum number of concurrent requests defaults to 10. This can be changed when constructing the operation.
Be aware that because requests are being parallelized performance is also dependent on the client's underlying connection pool. If there are no connections available performance will suffer initially as connections will need to be established or worse they could time out.
Modifier and Type | Class and Description |
---|---|
static class |
MultiFetch.Builder
Used to construct a MutiFetch command.
|
static class |
MultiFetch.Response
The response from Raik for a MultiFetch command.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_IN_FLIGHT |
Modifier and Type | Method and Description |
---|---|
protected RiakFuture<MultiFetch.Response,List<Location>> |
executeAsync(RiakCluster cluster) |
execute
public static final int DEFAULT_MAX_IN_FLIGHT
protected RiakFuture<MultiFetch.Response,List<Location>> executeAsync(RiakCluster cluster)
executeAsync
in class RiakCommand<MultiFetch.Response,List<Location>>
Copyright © 2014. All rights reserved.