diff --git a/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java b/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java index 78270c925..4248e76ff 100644 --- a/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java +++ b/src/main/java/net/openhft/chronicle/hash/impl/VanillaChronicleHash.java @@ -249,6 +249,7 @@ public abstract class VanillaChronicleHash "dataFileVersion").text(); @@ -259,87 +260,87 @@ public abstract class VanillaChronicleHash "keyClass").lenientTypeLiteral(); keySizeMarshaller = wireIn.read(() -> "keySizeMarshaller").object(SizeMarshaller.class); - keyReader = wireIn.read(() -> "keyReader").object(SizedReader.class); - keyDataAccess = wireIn.read(() -> "keyDataAccess").object(DataAccess.class); + keyReader = (SizedReader) wireIn.read("keyReader").object(SizedReader.class); + keyDataAccess = (DataAccess) wireIn.read("keyDataAccess").object(DataAccess.class); - checksumEntries = wireIn.read(() -> "checksumEntries").bool(); + checksumEntries = wireIn.read("checksumEntries").bool(); - actualSegments = wireIn.read(() -> "actualSegments").int32(); - hashSplitting = wireIn.read(() -> "hashSplitting").typedMarshallable(); + actualSegments = wireIn.read("actualSegments").int32(); + hashSplitting = wireIn.read("hashSplitting").typedMarshallable(); - chunkSize = wireIn.read(() -> "chunkSize").int64(); - maxChunksPerEntry = wireIn.read(() -> "maxChunksPerEntry").int32(); - actualChunksPerSegmentTier = wireIn.read(() -> "actualChunksPerSegmentTier").int64(); + chunkSize = wireIn.read("chunkSize").int64(); + maxChunksPerEntry = wireIn.read("maxChunksPerEntry").int32(); + actualChunksPerSegmentTier = wireIn.read("actualChunksPerSegmentTier").int64(); - segmentHeaderSize = wireIn.read(() -> "segmentHeaderSize").int32(); + segmentHeaderSize = wireIn.read("segmentHeaderSize").int32(); - tierHashLookupValueBits = wireIn.read(() -> "tierHashLookupValueBits").int32(); - tierHashLookupKeyBits = wireIn.read(() -> "tierHashLookupKeyBits").int32(); - tierHashLookupSlotSize = wireIn.read(() -> "tierHashLookupSlotSize").int32(); - tierHashLookupCapacity = wireIn.read(() -> "tierHashLookupCapacity").int64(); - maxEntriesPerHashLookup = wireIn.read(() -> "maxEntriesPerHashLookup").int64(); - tierHashLookupInnerSize = wireIn.read(() -> "tierHashLookupInnerSize").int64(); - tierHashLookupOuterSize = wireIn.read(() -> "tierHashLookupOuterSize").int64(); + tierHashLookupValueBits = wireIn.read("tierHashLookupValueBits").int32(); + tierHashLookupKeyBits = wireIn.read("tierHashLookupKeyBits").int32(); + tierHashLookupSlotSize = wireIn.read("tierHashLookupSlotSize").int32(); + tierHashLookupCapacity = wireIn.read("tierHashLookupCapacity").int64(); + maxEntriesPerHashLookup = wireIn.read("maxEntriesPerHashLookup").int64(); + tierHashLookupInnerSize = wireIn.read("tierHashLookupInnerSize").int64(); + tierHashLookupOuterSize = wireIn.read("tierHashLookupOuterSize").int64(); - tierFreeListInnerSize = wireIn.read(() -> "tierFreeListInnerSize").int64(); - tierFreeListOuterSize = wireIn.read(() -> "tierFreeListOuterSize").int64(); + tierFreeListInnerSize = wireIn.read("tierFreeListInnerSize").int64(); + tierFreeListOuterSize = wireIn.read("tierFreeListOuterSize").int64(); - tierEntrySpaceInnerSize = wireIn.read(() -> "tierEntrySpaceInnerSize").int64(); - tierEntrySpaceInnerOffset = wireIn.read(() -> "tierEntrySpaceInnerOffset").int32(); - tierEntrySpaceOuterSize = wireIn.read(() -> "tierEntrySpaceOuterSize").int64(); + tierEntrySpaceInnerSize = wireIn.read("tierEntrySpaceInnerSize").int64(); + tierEntrySpaceInnerOffset = wireIn.read("tierEntrySpaceInnerOffset").int32(); + tierEntrySpaceOuterSize = wireIn.read("tierEntrySpaceOuterSize").int64(); - tierSize = wireIn.read(() -> "tierSize").int64(); + tierSize = wireIn.read("tierSize").int64(); - maxExtraTiers = wireIn.read(() -> "maxExtraTiers").int64(); - tierBulkSizeInBytes = wireIn.read(() -> "tierBulkSizeInBytes").int64(); - tierBulkInnerOffsetToTiers = wireIn.read(() -> "tierBulkInnerOffsetToTiers").int64(); - tiersInBulk = wireIn.read(() -> "tiersInBulk").int64(); - log2TiersInBulk = wireIn.read(() -> "log2TiersInBulk").int32(); + maxExtraTiers = wireIn.read("maxExtraTiers").int64(); + tierBulkSizeInBytes = wireIn.read("tierBulkSizeInBytes").int64(); + tierBulkInnerOffsetToTiers = wireIn.read("tierBulkInnerOffsetToTiers").int64(); + tiersInBulk = wireIn.read("tiersInBulk").int64(); + log2TiersInBulk = wireIn.read("log2TiersInBulk").int32(); } @Override public void writeMarshallable(@NotNull final WireOut wireOut) { - wireOut.write(() -> "dataFileVersion").text(dataFileVersion); + wireOut.write("dataFileVersion").text(dataFileVersion); - wireOut.write(() -> "keyClass").typeLiteral(keyClass); - wireOut.write(() -> "keySizeMarshaller").object(keySizeMarshaller); - wireOut.write(() -> "keyReader").object(keyReader); - wireOut.write(() -> "keyDataAccess").object(keyDataAccess); + wireOut.write("keyClass").typeLiteral(keyClass); + wireOut.write("keySizeMarshaller").object(keySizeMarshaller); + wireOut.write("keyReader").object(keyReader); + wireOut.write("keyDataAccess").object(keyDataAccess); - wireOut.write(() -> "checksumEntries").bool(checksumEntries); + wireOut.write("checksumEntries").bool(checksumEntries); - wireOut.write(() -> "actualSegments").int32(actualSegments); - wireOut.write(() -> "hashSplitting").object(hashSplitting); + wireOut.write("actualSegments").int32(actualSegments); + wireOut.write("hashSplitting").object(hashSplitting); - wireOut.write(() -> "chunkSize").int64(chunkSize); - wireOut.write(() -> "maxChunksPerEntry").int32(maxChunksPerEntry); - wireOut.write(() -> "actualChunksPerSegmentTier").int64(actualChunksPerSegmentTier); + wireOut.write("chunkSize").int64(chunkSize); + wireOut.write("maxChunksPerEntry").int32(maxChunksPerEntry); + wireOut.write("actualChunksPerSegmentTier").int64(actualChunksPerSegmentTier); - wireOut.write(() -> "segmentHeaderSize").int32(segmentHeaderSize); + wireOut.write("segmentHeaderSize").int32(segmentHeaderSize); - wireOut.write(() -> "tierHashLookupValueBits").int32(tierHashLookupValueBits); - wireOut.write(() -> "tierHashLookupKeyBits").int32(tierHashLookupKeyBits); - wireOut.write(() -> "tierHashLookupSlotSize").int32(tierHashLookupSlotSize); - wireOut.write(() -> "tierHashLookupCapacity").int64(tierHashLookupCapacity); - wireOut.write(() -> "maxEntriesPerHashLookup").int64(maxEntriesPerHashLookup); - wireOut.write(() -> "tierHashLookupInnerSize").int64(tierHashLookupInnerSize); - wireOut.write(() -> "tierHashLookupOuterSize").int64(tierHashLookupOuterSize); + wireOut.write("tierHashLookupValueBits").int32(tierHashLookupValueBits); + wireOut.write("tierHashLookupKeyBits").int32(tierHashLookupKeyBits); + wireOut.write("tierHashLookupSlotSize").int32(tierHashLookupSlotSize); + wireOut.write("tierHashLookupCapacity").int64(tierHashLookupCapacity); + wireOut.write("maxEntriesPerHashLookup").int64(maxEntriesPerHashLookup); + wireOut.write("tierHashLookupInnerSize").int64(tierHashLookupInnerSize); + wireOut.write("tierHashLookupOuterSize").int64(tierHashLookupOuterSize); - wireOut.write(() -> "tierFreeListInnerSize").int64(tierFreeListInnerSize); - wireOut.write(() -> "tierFreeListOuterSize").int64(tierFreeListOuterSize); + wireOut.write("tierFreeListInnerSize").int64(tierFreeListInnerSize); + wireOut.write("tierFreeListOuterSize").int64(tierFreeListOuterSize); - wireOut.write(() -> "tierEntrySpaceInnerSize").int64(tierEntrySpaceInnerSize); - wireOut.write(() -> "tierEntrySpaceInnerOffset").int32(tierEntrySpaceInnerOffset); - wireOut.write(() -> "tierEntrySpaceOuterSize").int64(tierEntrySpaceOuterSize); + wireOut.write("tierEntrySpaceInnerSize").int64(tierEntrySpaceInnerSize); + wireOut.write("tierEntrySpaceInnerOffset").int32(tierEntrySpaceInnerOffset); + wireOut.write("tierEntrySpaceOuterSize").int64(tierEntrySpaceOuterSize); - wireOut.write(() -> "tierSize").int64(tierSize); + wireOut.write("tierSize").int64(tierSize); - wireOut.write(() -> "maxExtraTiers").int64(maxExtraTiers); - wireOut.write(() -> "tierBulkSizeInBytes").int64(tierBulkSizeInBytes); - wireOut.write(() -> "tierBulkInnerOffsetToTiers").int64(tierBulkInnerOffsetToTiers); - wireOut.write(() -> "tiersInBulk").int64(tiersInBulk); - wireOut.write(() -> "log2TiersInBulk").int32(log2TiersInBulk); + wireOut.write("maxExtraTiers").int64(maxExtraTiers); + wireOut.write("tierBulkSizeInBytes").int64(tierBulkSizeInBytes); + wireOut.write("tierBulkInnerOffsetToTiers").int64(tierBulkInnerOffsetToTiers); + wireOut.write("tiersInBulk").int64(tiersInBulk); + wireOut.write("log2TiersInBulk").int32(log2TiersInBulk); } protected VanillaGlobalMutableState createGlobalMutableState() { diff --git a/src/test/java/eg/BigData.java b/src/test/java/eg/BigData.java index f6f316602..8eee83102 100644 --- a/src/test/java/eg/BigData.java +++ b/src/test/java/eg/BigData.java @@ -16,7 +16,7 @@ package eg; -import net.openhft.affinity.AffinitySupport; +import net.openhft.affinity.Affinity; import net.openhft.chronicle.map.ChronicleMapBuilder; import java.io.*; @@ -121,7 +121,7 @@ public class BigData { } public static void populate(int n) { - AffinitySupport.setThreadId(); + Affinity.setThreadId(); long start = System.currentTimeMillis(); BigDataStuff value = new BigDataStuff(0); @@ -138,7 +138,7 @@ public class BigData { public static void _test() { // improves logging of these threads. - AffinitySupport.setThreadId(); + Affinity.setThreadId(); try { test(); } catch (IOException e) { diff --git a/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java b/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java index 54df6ae69..146f13125 100644 --- a/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java +++ b/src/test/java/net/openhft/chronicle/map/BasicReplicationTest.java @@ -72,11 +72,11 @@ public class BasicReplicationTest { executorService.submit(processorTwo::processPendingChangesLoop); executorService.submit(processorThree::processPendingChangesLoop); - final Map[] maps = new Map[]{mapOne, mapTwo, mapThree}; + final List> maps = Arrays.asList(mapOne, mapTwo, mapThree); final Random random = new Random(0xBAD5EED); for (int i = 0; i < 5000; i++) { - final int mapIndex = random.nextInt(maps.length); - final Map map = maps[mapIndex]; + final int mapIndex = random.nextInt(maps.size()); + final Map map = maps.get(mapIndex); final String key = "key" + random.nextInt(100); final String value = "val" + random.nextInt(500); map.put(key, value); @@ -135,7 +135,8 @@ public class BasicReplicationTest { void addDestinationMap(final ReplicatedChronicleMap.ModificationIterator modificationIterator, final ReplicatedChronicleMap sourceMap, final ReplicatedChronicleMap destinationMap) { - destinationMaps.add(new IteratorAndDestinationMap(modificationIterator, sourceMap, destinationMap)); + + destinationMaps.add(new IteratorAndDestinationMap<>(modificationIterator, sourceMap, destinationMap)); if (this.sourceMap != null && this.sourceMap != sourceMap) { throw new IllegalArgumentException("All iterators must belong to the same source map"); } diff --git a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java index 88e383f9d..1d082eb21 100644 --- a/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java +++ b/src/test/java/net/openhft/chronicle/map/CHMUseCasesTest.java @@ -104,7 +104,7 @@ interface IData extends BytesMarshallable { long magic = in.readLong(); if (magic != MAGIC) throw new AssertionError("Start " + Long.toHexString(magic)); - text = in.readUTFΔ(); + text = in.readUtf8(); number = in.readInt(); long magic2 = in.readLong(); if (magic2 != MAGIC2) @@ -114,7 +114,7 @@ interface IData extends BytesMarshallable { @Override public void writeMarshallable(@NotNull BytesOut out) { out.writeLong(MAGIC); - out.writeUTFΔ(text); + out.writeUtf8(text); out.writeInt(number); out.writeLong(MAGIC2); } @@ -412,7 +412,7 @@ public class CHMUseCasesTest { byte[][] value = {bytes1, bytes2}; map.put("Key".getBytes(), value); - assertEquals(value, map.get("Key".getBytes())); + assertArrayEquals(value, map.get("Key".getBytes())); mapChecks(); } } diff --git a/src/test/java/net/openhft/chronicle/map/ForEachSegmentTest.java b/src/test/java/net/openhft/chronicle/map/ForEachSegmentTest.java index 33071a07a..b24bb93f4 100644 --- a/src/test/java/net/openhft/chronicle/map/ForEachSegmentTest.java +++ b/src/test/java/net/openhft/chronicle/map/ForEachSegmentTest.java @@ -4,7 +4,7 @@ import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.OS; import net.openhft.chronicle.core.pool.ClassAliasPool; import net.openhft.chronicle.core.util.Time; -import net.openhft.chronicle.wire.AbstractBytesMarshallable; +import net.openhft.chronicle.wire.BytesInBinaryMarshallable; import org.junit.Test; import java.io.File; @@ -77,7 +77,7 @@ public class ForEachSegmentTest { } } - static class MyDto extends AbstractBytesMarshallable { + static final class MyDto extends BytesInBinaryMarshallable { String s1; String s2; } diff --git a/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java b/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java index 6eb4116f5..95f0277e7 100644 --- a/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java +++ b/src/test/java/net/openhft/chronicle/map/IntValueMapTest.java @@ -17,7 +17,7 @@ package net.openhft.chronicle.map; import net.openhft.chronicle.bytes.Byteable; -import net.openhft.chronicle.bytes.NativeBytesStore; +import net.openhft.chronicle.bytes.BytesStore; import net.openhft.chronicle.core.values.IntValue; import net.openhft.chronicle.values.Values; import org.junit.Test; @@ -39,7 +39,7 @@ public class IntValueMapTest { .averageValue("test") .entries(20000).create()) { IntValue value = Values.newNativeReference(IntValue.class); - ((Byteable) value).bytesStore(NativeBytesStore.nativeStoreWithFixedCapacity(4), 0, 4); + ((Byteable) value).bytesStore(BytesStore.nativeStoreWithFixedCapacity(4), 0, 4); value.setValue(1); final String expected = "test"; diff --git a/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java b/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java index 72c54c0f1..79d21fb34 100644 --- a/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java +++ b/src/test/java/net/openhft/chronicle/map/ValueAlignmentRelocationTest.java @@ -9,6 +9,7 @@ import org.junit.runners.Parameterized; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; import java.util.Collection; @@ -43,7 +44,7 @@ public class ValueAlignmentRelocationTest { @NotNull private static String toString(final byte[] value) { - return new String(value, 0, 0, value.length); + return new String(value, StandardCharsets.UTF_8); } @Test diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java index 1936e0e78..b7cba6d6e 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/exodus/DirtyReadTolerance.java @@ -1,6 +1,6 @@ package net.openhft.chronicle.map.fromdocs.acid.exodus; -import net.openhft.affinity.AffinitySupport; +import net.openhft.affinity.Affinity; import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.fromdocs.BondVOInterface; @@ -36,7 +36,7 @@ public class DirtyReadTolerance { static ChronicleMap offHeap(String operand) throws IOException { // ensure thread ids are globally unique. - AffinitySupport.setThreadId(); + Affinity.setThreadId(); return ChronicleMapBuilder.of(String.class, BondVOInterface.class) .entries(16) .averageKeySize("123456789".length()) diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java index 5b6acd82d..b1f53c778 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/genesis/DirtyReadTolerance.java @@ -1,6 +1,6 @@ package net.openhft.chronicle.map.fromdocs.acid.genesis; -import net.openhft.affinity.AffinitySupport; +import net.openhft.affinity.Affinity; import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.fromdocs.BondVOInterface; @@ -36,7 +36,7 @@ public class DirtyReadTolerance { static ChronicleMap offHeap(String operand) throws IOException { // ensure thread ids are globally unique. - AffinitySupport.setThreadId(); + Affinity.setThreadId(); return ChronicleMapBuilder.of(String.class, BondVOInterface.class) .entries(16) .averageKeySize("123456789".length()) diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java index bb86040da..1627b253a 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/acid/revelations/DirtyReadTolerance.java @@ -3,12 +3,9 @@ package net.openhft.chronicle.map.fromdocs.acid.revelations; import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.fromdocs.BondVOInterface; -import net.openhft.chronicle.map.fromdocs.acid.exodus.DirtyReadOffender; -import net.openhft.chronicle.map.fromdocs.acid.exodus.DirtyReadVictim; import java.io.File; import java.io.IOException; -import java.util.concurrent.locks.StampedLock; public class DirtyReadTolerance { diff --git a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java index 4475b0934..391ec6413 100644 --- a/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java +++ b/src/test/java/net/openhft/chronicle/map/fromdocs/pingpong_latency/PingPongCASLeft.java @@ -16,7 +16,7 @@ package net.openhft.chronicle.map.fromdocs.pingpong_latency; -import net.openhft.affinity.AffinitySupport; +import net.openhft.affinity.Affinity; import net.openhft.chronicle.map.ChronicleMap; import net.openhft.chronicle.map.ChronicleMapBuilder; import net.openhft.chronicle.map.fromdocs.BondVOInterface; @@ -87,7 +87,7 @@ public class PingPongCASLeft { static ChronicleMap acquireCHM() throws IOException { // ensure thread ids are globally unique. - AffinitySupport.setThreadId(); + Affinity.setThreadId(); return ChronicleMapBuilder.of(String.class, BondVOInterface.class) .entries(16) .averageKeySize("369604101".length()).create(); diff --git a/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java b/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java index 339ff22b9..25da87344 100644 --- a/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java +++ b/src/test/java/net/openhft/chronicle/map/utility/ProcessInstanceLimiter.java @@ -16,7 +16,7 @@ package net.openhft.chronicle.map.utility; -import net.openhft.affinity.AffinitySupport; +import net.openhft.affinity.Affinity; import net.openhft.chronicle.algo.locks.AcquisitionStrategies; import net.openhft.chronicle.algo.locks.ReadWriteLockingStrategy; import net.openhft.chronicle.algo.locks.TryAcquireOperations; @@ -92,7 +92,7 @@ public class ProcessInstanceLimiter implements Runnable { private static final String DEFAULT_PROCESS_NAME = "_DEFAULT_"; static { - AffinitySupport.setThreadId(); + Affinity.setThreadId(); } private final String sharedMapPath; @@ -103,8 +103,8 @@ public class ProcessInstanceLimiter implements Runnable { private long timeUpdateInterval = DEFAULT_TIME_UPDATE_INTERVAL_MS; private long startTime; private long[] lastStartTimes; - private Map timedata = new ConcurrentHashMap(); - private Map starttimedata = new ConcurrentHashMap(); + private final Map timedata = new ConcurrentHashMap(); + private final Map starttimedata = new ConcurrentHashMap(); /** * Create a ProcessInstanceLimiter instance with a default callback, an diff --git a/src/test/java/net/openhft/lang/values/DoubleArray.java b/src/test/java/net/openhft/lang/values/DoubleArray.java index d080f305d..8bc921c0b 100644 --- a/src/test/java/net/openhft/lang/values/DoubleArray.java +++ b/src/test/java/net/openhft/lang/values/DoubleArray.java @@ -19,7 +19,6 @@ package net.openhft.lang.values; import net.openhft.chronicle.bytes.Byteable; import net.openhft.chronicle.bytes.BytesStore; import net.openhft.chronicle.bytes.DynamicallySized; -import net.openhft.chronicle.bytes.NativeBytesStore; import net.openhft.chronicle.values.Copyable; /** @@ -27,16 +26,16 @@ import net.openhft.chronicle.values.Copyable; */ public class DoubleArray implements Byteable, Copyable, DynamicallySized { static boolean HACK = true; - private static int CAPACITY = 0; // assume a 32-bit size. - private static int LENGTH = CAPACITY + 4; // assume a 32-bit size. - private static int BASE = LENGTH + 4; + private static final int CAPACITY = 0; // assume a 32-bit size. + private static final int LENGTH = CAPACITY + 4; // assume a 32-bit size. + private static final int BASE = LENGTH + 4; private final int capacity; private BytesStore bs; private long offset; public DoubleArray(int capacity) { - bs = NativeBytesStore.nativeStoreWithFixedCapacity(BASE + capacity * 8L); + bs = BytesStore.nativeStoreWithFixedCapacity(BASE + capacity * 8L); bs.writeInt(CAPACITY, capacity); offset = 0; this.capacity = capacity; diff --git a/src/test/java/net/openhft/lang/values/MovingAverageArray.java b/src/test/java/net/openhft/lang/values/MovingAverageArray.java index 089e40582..48c3e628a 100644 --- a/src/test/java/net/openhft/lang/values/MovingAverageArray.java +++ b/src/test/java/net/openhft/lang/values/MovingAverageArray.java @@ -22,7 +22,7 @@ import net.openhft.chronicle.bytes.DynamicallySized; import net.openhft.chronicle.core.Maths; import net.openhft.chronicle.core.io.IORuntimeException; import net.openhft.chronicle.core.util.ObjectUtils; -import net.openhft.chronicle.wire.AbstractBytesMarshallable; +import net.openhft.chronicle.wire.BytesInBinaryMarshallable; import java.util.ArrayList; import java.util.List; @@ -30,9 +30,9 @@ import java.util.List; /** * Created by peter.lawrey on 23/04/2015. */ -public class MovingAverageArray extends AbstractBytesMarshallable implements DynamicallySized { - private transient List buffer = new ArrayList<>(); - private List values = new ArrayList<>(); +public class MovingAverageArray extends BytesInBinaryMarshallable implements DynamicallySized { + private final transient List buffer = new ArrayList<>(); + private final List values = new ArrayList<>(); @Override public void readMarshallable(BytesIn bytes) throws IORuntimeException { diff --git a/src/test/java/net/openhft/lang/values/MovingAverageCompact.java b/src/test/java/net/openhft/lang/values/MovingAverageCompact.java index 261f24286..f91eb6b8d 100644 --- a/src/test/java/net/openhft/lang/values/MovingAverageCompact.java +++ b/src/test/java/net/openhft/lang/values/MovingAverageCompact.java @@ -18,9 +18,9 @@ package net.openhft.lang.values; import net.openhft.chronicle.bytes.BytesIn; import net.openhft.chronicle.bytes.BytesOut; -import net.openhft.chronicle.wire.AbstractBytesMarshallable; +import net.openhft.chronicle.wire.BytesInBinaryMarshallable; -public class MovingAverageCompact extends AbstractBytesMarshallable { +public class MovingAverageCompact extends BytesInBinaryMarshallable { private double movingAverage; private double high;