From ff9f0e32af21ee6efb498f91aa5d3ed3d99213a9 Mon Sep 17 00:00:00 2001 From: Rob Austin Date: Mon, 27 Apr 2015 19:15:51 +0100 Subject: [PATCH] CE-24 Create marshal for Map type ( in wire ) --- .../java/net/openhft/chronicle/map/EngineMap.java | 5 ++++- .../net/openhft/chronicle/map/MapWireHandler.java | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/EngineMap.java b/src/main/java/net/openhft/chronicle/map/EngineMap.java index 0a25773df..facd20a1b 100644 --- a/src/main/java/net/openhft/chronicle/map/EngineMap.java +++ b/src/main/java/net/openhft/chronicle/map/EngineMap.java @@ -166,7 +166,10 @@ public class EngineMap implements ChronicleMap { @Override public V put(final K key, final V value) { nullCheck(key); - return toObject(vClass, () -> map.put(bytes(key), bytes(value))); + return toObject(vClass, () -> { + final byte[] put = map.put(bytes(key), bytes(value)); + return put; + }); } @Override diff --git a/src/main/java/net/openhft/chronicle/map/MapWireHandler.java b/src/main/java/net/openhft/chronicle/map/MapWireHandler.java index 81cba95b4..45d5d3177 100644 --- a/src/main/java/net/openhft/chronicle/map/MapWireHandler.java +++ b/src/main/java/net/openhft/chronicle/map/MapWireHandler.java @@ -304,8 +304,7 @@ public class MapWireHandler implements WireHandler, Consumer // todo remove the toByteArray(..) writeValueUsingDelegate(map -> { final byte[] key = toByteArray(valueIn); - final byte[] value = map.get(key); - return value; + return map.get(key); }); return; } @@ -316,9 +315,11 @@ public class MapWireHandler implements WireHandler, Consumer final Params[] params = getAndPut.params(); - MapWireHandler.this.writeValue(b -> b.put( - wire.read(params[0]).bytes(), - wire.read(params[1]).bytes())); + MapWireHandler.this.writeValue(b -> { + byte[] k = wire.read(params[0]).bytes(); + byte[] v = wire.read(params[1]).bytes(); + return b.put(k, v); + }); });