mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Reduce calls to deprecated methods, Fix #316
This commit is contained in:
@@ -249,6 +249,7 @@ public abstract class VanillaChronicleHash<K,
|
||||
return preShutdownAction;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void readMarshallableFields(@NotNull final WireIn wireIn) {
|
||||
dataFileVersion = wireIn.read(() -> "dataFileVersion").text();
|
||||
|
||||
@@ -259,87 +260,87 @@ public abstract class VanillaChronicleHash<K,
|
||||
|
||||
keyClass = wireIn.read(() -> "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<K>) wireIn.read("keyReader").object(SizedReader.class);
|
||||
keyDataAccess = (DataAccess<K>) 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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<Map<String, String>> 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<String, String> map = maps[mapIndex];
|
||||
final int mapIndex = random.nextInt(maps.size());
|
||||
final Map<String, String> 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<K, V, ?>.ModificationIterator modificationIterator,
|
||||
final ReplicatedChronicleMap<K, V, ?> sourceMap,
|
||||
final ReplicatedChronicleMap<K, V, ?> destinationMap) {
|
||||
destinationMaps.add(new IteratorAndDestinationMap<K, V>(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");
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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<K, V> {
|
||||
|
||||
static ChronicleMap<String, BondVOInterface> 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())
|
||||
|
||||
+2
-2
@@ -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<K, V> {
|
||||
|
||||
static ChronicleMap<String, BondVOInterface> 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())
|
||||
|
||||
-3
@@ -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<K, V> {
|
||||
|
||||
|
||||
+2
-2
@@ -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<String, BondVOInterface> 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();
|
||||
|
||||
@@ -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<String, Data> timedata = new ConcurrentHashMap<String, Data>();
|
||||
private Map<String, Data> starttimedata = new ConcurrentHashMap<String, Data>();
|
||||
private final Map<String, Data> timedata = new ConcurrentHashMap<String, Data>();
|
||||
private final Map<String, Data> starttimedata = new ConcurrentHashMap<String, Data>();
|
||||
|
||||
/**
|
||||
* Create a ProcessInstanceLimiter instance with a default callback, an
|
||||
|
||||
@@ -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<DoubleArray>, 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;
|
||||
|
||||
@@ -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<MovingAverageCompact> buffer = new ArrayList<>();
|
||||
private List<MovingAverageCompact> values = new ArrayList<>();
|
||||
public class MovingAverageArray extends BytesInBinaryMarshallable implements DynamicallySized {
|
||||
private final transient List<MovingAverageCompact> buffer = new ArrayList<>();
|
||||
private final List<MovingAverageCompact> values = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void readMarshallable(BytesIn bytes) throws IORuntimeException {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user