DATAKV-36

+ update BulkMapper contract
This commit is contained in:
Costin Leau
2011-03-11 18:06:32 +02:00
parent f63da79892
commit d7db64fdbf
2 changed files with 7 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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);
}
}