From 408a8b5c43ffd78ac2ac1382b26a9ba1caea72b4 Mon Sep 17 00:00:00 2001 From: leventov Date: Mon, 15 Jun 2015 20:23:30 +0300 Subject: [PATCH 1/2] HCOLL-368 Optimized Engine replication implementation in ReplicatedChronicleMap --- .../chronicle/map/ReplicatedChronicleMap.java | 122 +++++++++++------- .../chronicle/map/VanillaChronicleMap.java | 17 +++ 2 files changed, 90 insertions(+), 49 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index ab3675d17..b30590c47 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -378,52 +378,47 @@ final class ReplicatedChronicleMap>instance(), + BytesBytesInterop.INSTANCE, key, key.remaining(), keyBytesToInstance, + GetRemoteSeparateBytesInterops.INSTANCE, value, valueBytesToInstance, + hash2, true, readValueToLazyBytes, true, identifier, timestamp, + true); + } finally { + writeUnlock(); + } + } + , RV, VB extends RV, VBI, MVBI extends MetaBytesInterop> RV put(@Nullable ThreadLocalCopies copies, @Nullable SegmentState segmentState, diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index 8870b2ced..bac785813 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -1016,6 +1016,23 @@ class VanillaChronicleMap, } } + enum GetRemoteSeparateBytesInterops + implements GetValueInterops, + DelegatingMetaBytesInterop>> { + INSTANCE; + + @Override + public DelegatingMetaBytesInterop> getMetaValueInterop( + @NotNull ThreadLocalCopies copies, BytesInterop valueInterop, Bytes value) { + return DelegatingMetaBytesInterop.>instance(); + } + + @Override + public BytesInterop getValueInterop(@NotNull ThreadLocalCopies copies) { + return BytesBytesInterop.INSTANCE; + } + } + @Override public final MVI getMetaValueInterop( @NotNull ThreadLocalCopies copies, VI valueInterop, V value) { From 87738b4f79bfe02597cf12d3268939ddaf7e1e11 Mon Sep 17 00:00:00 2001 From: leventov Date: Mon, 15 Jun 2015 20:30:17 +0300 Subject: [PATCH 2/2] HCOLL-368 removed unused thread local buffer in ReplicatedChronicleMap --- .../chronicle/map/ReplicatedChronicleMap.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java index b30590c47..b765b6f1a 100644 --- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java @@ -351,33 +351,6 @@ final class ReplicatedChronicleMap buffer = new ThreadLocal() { - @Override - protected IByteBufferBytes initialValue() { - return ByteBufferBytes.wrap(ByteBuffer.allocateDirect(1024)); - } - }; - - private Bytes threadlocalBuffer(long requiredSize) { - - final IByteBufferBytes bytes = buffer.get(); - bytes.clear(); - bytes.buffer().clear(); - - if (bytes.buffer().remaining() < requiredSize) { - - if (requiredSize > Integer.MAX_VALUE) - throw new IllegalStateException("entry is too large"); - - IByteBufferBytes result = ByteBufferBytes.wrap(ByteBuffer.allocateDirect((int) requiredSize)); - buffer.set(result); - return result; - } - - return bytes; - - } - @Override public void put(final Bytes key, final Bytes value, final byte id, final long timestamp) {