DATAKV-36
+ update BulkMapper contract
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.keyvalue.redis.core;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper translating Redis bulk value responses (typically returned by a sort query) to actual objects. Implementations of this interface do not have to worry
|
||||
@@ -27,5 +27,5 @@ import java.util.Iterator;
|
||||
*/
|
||||
public interface BulkMapper<T, V> {
|
||||
|
||||
T mapBulk(Iterator<V> valueStream);
|
||||
T mapBulk(List<V> tuple);
|
||||
}
|
||||
|
||||
@@ -1963,14 +1963,14 @@ public class RedisTemplate<K, V> extends RedisAccessor implements RedisOperation
|
||||
int bulkSize = query.getGetPattern().size();
|
||||
List<T> result = new ArrayList<T>(values.size() / bulkSize + 1);
|
||||
|
||||
final List<S> bulk = new ArrayList<S>(bulkSize);
|
||||
final List<S> listView = Collections.unmodifiableList(bulk);
|
||||
|
||||
List<S> bulk = new ArrayList<S>(bulkSize);
|
||||
for (S s : values) {
|
||||
|
||||
bulk.add(s);
|
||||
if (bulk.size() == bulkSize) {
|
||||
result.add(bulkMapper.mapBulk(listView.iterator()));
|
||||
bulk.clear();
|
||||
result.add(bulkMapper.mapBulk(Collections.unmodifiableList(bulk)));
|
||||
// create a new list (we could reuse the old one but the client might hang on to it for some reason)
|
||||
bulk = new ArrayList<S>(bulkSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user