From 20cde48b5539187478d342a929ab5e6f688f995b Mon Sep 17 00:00:00 2001 From: leventov Date: Tue, 30 Dec 2014 01:05:10 +0700 Subject: [PATCH] HCOLL-244 fixed a bug in VanillaChornicleMap --- .../java/net/openhft/chronicle/map/MultiMapFactory.java | 4 ++-- .../net/openhft/chronicle/map/VanillaChronicleMap.java | 2 +- .../openhft/chronicle/map/TCPSocketReplicationTest.java | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java b/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java index 5e3349f54..ca137ab23 100644 --- a/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java +++ b/src/main/java/net/openhft/chronicle/map/MultiMapFactory.java @@ -80,8 +80,8 @@ enum MultiMapFactory { throw new IllegalArgumentException("Capacity " + capacity + " not supported"); } - public static long sizeOfBitSetInBytes(long minCapacity) { - return BYTES.convert(LONGS.align(multiMapCapacity(minCapacity), BITS), BITS); + public static long sizeOfBitSetInBytes(long actualChunksPerSegment) { + return LONGS.align(BYTES.alignAndConvert(actualChunksPerSegment, BITS), BYTES); } public static ATSDirectBitSet newPositions(long capacity) { diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java index c95c9fd63..3aae579d0 100755 --- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java +++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java @@ -1448,7 +1448,7 @@ class VanillaChronicleMap, * multiMapsPerSegment(); final NativeBytes bsBytes = new NativeBytes(ms.objectSerializer(), start, - start + LONGS.align(BYTES.alignAndConvert(actualChunksPerSegment, BITS), BYTES), + start + MultiMapFactory.sizeOfBitSetInBytes(actualChunksPerSegment), null); freeList = new SingleThreadedDirectBitSet(bsBytes); start += numberOfBitSets() * sizeOfSegmentFreeListBitSets(); diff --git a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java index 591756425..62ed81f0b 100644 --- a/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/TCPSocketReplicationTest.java @@ -53,8 +53,12 @@ public class TCPSocketReplicationTest { ChronicleMapBuilder map1Builder = newTcpSocketShmBuilder(Integer.class, CharSequence.class, (byte) 1, port, new InetSocketAddress("localhost", port + 1)); - map1 = map1Builder.averageValueSize(10).create(); - map2 = newTcpSocketShmIntString((byte) 2, port + 1); + map1 = map1Builder.entries(Builder.SIZE).averageValueSize(10).create(); + + ChronicleMapBuilder map2Builder = + newTcpSocketShmBuilder(Integer.class, CharSequence.class, + (byte) 2, port + 1); + map2 = map2Builder.entries(Builder.SIZE).averageValueSize(10).create(); s_port += 2; }