improved chunking in putAll()

This commit is contained in:
Rob Austin
2015-03-13 17:20:58 +00:00
parent e43765cf44
commit a89f31eae6
2 changed files with 32 additions and 14 deletions
@@ -448,12 +448,18 @@ class MapWireHandler<K, V> implements WireHandler, Consumer<WireHandlers> {
@Override
public void run() {
boolean hasNext = inWire.read(HAS_NEXT).bool();
collectData.put(toBytes(ARG_1), toBytes(ARG_2));
if (!hasNext) {
// the old code assumed that all the data would fit into a single buffer
// this assumption is invalid
if (!collectData.isEmpty()) {
// the old code assumed that ALL of the entries would fit into a single buffer
// this assumption is invalid
boolean hasNext;
for(;;) {
hasNext = inWire.read(HAS_NEXT).bool();
collectData.put(toBytes(ARG_1), toBytes(ARG_2));
if (!hasNext) {
incompleteWork.remove(transactionId);
@@ -463,8 +469,10 @@ class MapWireHandler<K, V> implements WireHandler, Consumer<WireHandlers> {
bytesMap.delegate.putAll((Map) collectData);
return null;
});
return;
}
if (inWire.bytes().remaining() == 0)
return;
}
}
};