Add a fix for enums being written as marshallables.

This commit is contained in:
Peter Lawrey
2017-06-04 14:01:48 +01:00
parent 52d8a0e6e3
commit ed8361b5cf
7 changed files with 227 additions and 204 deletions
@@ -56,20 +56,29 @@ public class VanillaChronicleMap<K, V, R>
ExternalMapQueryContext<K, V, ?>>
implements AbstractChronicleMap<K, V> {
/////////////////////////////////////////////////
// Value Data model
Class<V> valueClass;
public SizeMarshaller valueSizeMarshaller;
public SizedReader<V> valueReader;
public DataAccess<V> valueDataAccess;
public boolean constantlySizedEntry;
/////////////////////////////////////////////////
// Memory management and dependent fields
public int alignment;
public int worstAlignment;
public transient boolean couldNotDetermineAlignmentBeforeAllocation;
/** @see net.openhft.chronicle.set.SetFromMap */
public transient ChronicleSet<K> chronicleSet;
public transient MapEntryOperations<K, V, R> entryOperations;
public transient MapMethods<K, V, R> methods;
public transient DefaultValueProvider<K, V> defaultValueProvider;
/////////////////////////////////////////////////
// Value Data model
Class<V> valueClass;
/////////////////////////////////////////////////
// Behavior
transient boolean putReturnsNull;
transient boolean removeReturnsNull;
transient Set<Entry<K, V>> entrySet;
transient ThreadLocal<ContextHolder> cxt;
/////////////////////////////////////////////////
private transient String name;
/**
@@ -78,25 +87,7 @@ public class VanillaChronicleMap<K, V, R>
* initOwnTransients().
*/
private transient String identityString;
public transient boolean couldNotDetermineAlignmentBeforeAllocation;
/////////////////////////////////////////////////
// Behavior
transient boolean putReturnsNull;
transient boolean removeReturnsNull;
transient Set<Entry<K, V>> entrySet;
/** @see net.openhft.chronicle.set.SetFromMap */
public transient ChronicleSet<K> chronicleSet;
public transient MapEntryOperations<K, V, R> entryOperations;
public transient MapMethods<K, V, R> methods;
private transient boolean defaultEntryOperationsAndMethods;
public transient DefaultValueProvider<K, V> defaultValueProvider;
transient ThreadLocal<ContextHolder> cxt;
public VanillaChronicleMap(ChronicleMapBuilder<K, V> builder) throws IOException {
super(builder);
@@ -116,14 +107,18 @@ public class VanillaChronicleMap<K, V, R>
initTransients();
}
public static long alignAddr(long addr, long alignment) {
return (addr + alignment - 1) & ~(alignment - 1L);
}
@Override
protected void readMarshallableFields(@NotNull WireIn wireIn) {
super.readMarshallableFields(wireIn);
valueClass = wireIn.read(() -> "valueClass").typeLiteral();
valueSizeMarshaller = wireIn.read(() -> "valueSizeMarshaller").typedMarshallable();
valueReader = wireIn.read(() -> "valueReader").typedMarshallable();
valueDataAccess = wireIn.read(() -> "valueDataAccess").typedMarshallable();
valueSizeMarshaller = wireIn.read(() -> "valueSizeMarshaller").object(SizeMarshaller.class);
valueReader = wireIn.read(() -> "valueReader").object(SizedReader.class);
valueDataAccess = wireIn.read(() -> "valueDataAccess").object(DataAccess.class);
constantlySizedEntry = wireIn.read(() -> "constantlySizedEntry").bool();
@@ -136,9 +131,9 @@ public class VanillaChronicleMap<K, V, R>
super.writeMarshallable(wireOut);
wireOut.write(() -> "valueClass").typeLiteral(valueClass);
wireOut.write(() -> "valueSizeMarshaller").typedMarshallable(valueSizeMarshaller);
wireOut.write(() -> "valueReader").typedMarshallable(valueReader);
wireOut.write(() -> "valueDataAccess").typedMarshallable(valueDataAccess);
wireOut.write(() -> "valueSizeMarshaller").object(valueSizeMarshaller);
wireOut.write(() -> "valueReader").object(valueReader);
wireOut.write(() -> "valueDataAccess").object(valueDataAccess);
wireOut.write(() -> "constantlySizedEntry").bool(constantlySizedEntry);
@@ -287,7 +282,7 @@ public class VanillaChronicleMap<K, V, R>
", identityHashCode=" + System.identityHashCode(this) +
"}";
}
@Override
public void clear() {
forEachEntry(c -> c.context().remove(c));
@@ -306,10 +301,6 @@ public class VanillaChronicleMap<K, V, R>
entry.readSkip(skip);
}
public static long alignAddr(long addr, long alignment) {
return (addr + alignment - 1) & ~(alignment - 1L);
}
final ChainingInterface q() {
ThreadLocal<ContextHolder> cxt = this.cxt;
if (cxt == null)