mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-263 assume direct off-heap impls only used if fails to generate generic off-heap/on-heap readers/writers
This commit is contained in:
@@ -188,7 +188,7 @@ this for best performance.
|
||||
or value objects that are created through, a directClass interface, for example :
|
||||
``` java
|
||||
ChronicleMap<String, BondVOInterface> chm = ChronicleMapBuilder
|
||||
.of(String.class, DataValueClasses.directClassFor(BondVOInterface.class))
|
||||
.of(String.class, ondVOInterface.class)
|
||||
.create();
|
||||
|
||||
```
|
||||
@@ -470,19 +470,12 @@ Below we show you how you can work directly with the off heap entries.
|
||||
|
||||
``` java
|
||||
ChronicleMap<CharSequence, BondVOInterface> map = ChronicleMapBuilder
|
||||
.of(String.class, DataValueClasses.directClassFor(BondVOInterface.class))
|
||||
.of(String.class, BondVOInterface.class)
|
||||
.keySize(10)
|
||||
.create();
|
||||
```
|
||||
|
||||
notice that the the builder is passed a wrapped value type
|
||||
|
||||
``` java
|
||||
.of(CharSequence.class, DataValueClasses.directClassFor(BondVOInterface.class))
|
||||
```
|
||||
|
||||
this is in order to tell the builder that we are going to work directly with the off heap
|
||||
entries.
|
||||
by default, builder assume that we are going to work directly with the off heap
|
||||
entries (`DataValueClasses.directClassFor(BondVOInterface.class)`).
|
||||
|
||||
The value class, in our case `BondVOInterface.class` is an `interface` rather than a `class`, now
|
||||
like before, we can
|
||||
|
||||
@@ -29,10 +29,7 @@ import net.openhft.lang.io.serialization.BytesMarshaller;
|
||||
import net.openhft.lang.io.serialization.ObjectFactory;
|
||||
import net.openhft.lang.io.serialization.ObjectSerializer;
|
||||
import net.openhft.lang.io.serialization.impl.*;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.model.DataValueGenerator;
|
||||
import net.openhft.lang.model.DataValueModel;
|
||||
import net.openhft.lang.model.DataValueModels;
|
||||
import net.openhft.lang.model.*;
|
||||
import net.openhft.lang.threadlocal.Provider;
|
||||
import net.openhft.lang.threadlocal.ThreadLocalCopies;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -104,10 +101,6 @@ final class SerializationBuilder<E> implements Cloneable, Serializable {
|
||||
private void configureByDefault(Class<E> eClass, Role role) {
|
||||
instancesAreMutable = instancesAreMutable(eClass);
|
||||
|
||||
ObjectFactory<E> factory = concreteClass(eClass) && marshallerUseFactory(eClass) ?
|
||||
new NewInstanceObjectFactory<E>(eClass) :
|
||||
NullObjectFactory.<E>of();
|
||||
|
||||
if (eClass.isInterface()) {
|
||||
try {
|
||||
BytesReader<E> reader = DataValueBytesMarshallers.acquireBytesReader(eClass);
|
||||
@@ -119,10 +112,19 @@ final class SerializationBuilder<E> implements Cloneable, Serializable {
|
||||
sizeMarshaller(constant((long) size));
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
eClass = DataValueClasses.directClassFor(eClass);
|
||||
} catch (Exception ex) {
|
||||
// ignore, fall through
|
||||
}
|
||||
// ignore, fall through
|
||||
}
|
||||
}
|
||||
|
||||
ObjectFactory<E> factory = concreteClass(eClass) && marshallerUseFactory(eClass) ?
|
||||
new NewInstanceObjectFactory<E>(eClass) :
|
||||
NullObjectFactory.<E>of();
|
||||
|
||||
if (concreteClass(eClass) && Byteable.class.isAssignableFrom(eClass)) {
|
||||
ByteableMarshaller byteableMarshaller = ByteableMarshaller.of((Class) eClass);
|
||||
sizeMarshaller(byteableMarshaller);
|
||||
|
||||
@@ -56,7 +56,7 @@ public class OpenJDKAndHashMapExamplesTest {
|
||||
file.deleteOnExit();
|
||||
|
||||
ChronicleMap<String, BondVOInterface> chm = ChronicleMapBuilder
|
||||
.of(String.class, DataValueClasses.directClassFor(BondVOInterface.class))
|
||||
.of(String.class, BondVOInterface.class)
|
||||
.keySize(10)
|
||||
.createPersistedTo(file);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user