mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
HCOLL-156 changed default value object factory from AllocateInstanceObjectFactory to NewInstanceObjectFactory
This commit is contained in:
@@ -63,10 +63,10 @@ final class SerializationBuilder<E> implements Cloneable {
|
||||
this.bufferIdentity = role;
|
||||
this.eClass = eClass;
|
||||
|
||||
ObjectFactory<E> factory = this.factory;
|
||||
if (factory == null && role == Role.VALUE) {
|
||||
ObjectFactory<E> factory = null;
|
||||
if (role == Role.VALUE) {
|
||||
factory = concreteClass(eClass) && marshallerUseFactory(eClass) ?
|
||||
new AllocateInstanceObjectFactory(eClass) :
|
||||
new NewInstanceObjectFactory<E>(eClass) :
|
||||
NullObjectFactory.INSTANCE;
|
||||
}
|
||||
|
||||
@@ -85,6 +85,9 @@ final class SerializationBuilder<E> implements Cloneable {
|
||||
if (marshaller != null)
|
||||
marshaller(marshaller, factory);
|
||||
}
|
||||
if (role == Role.VALUE && concreteClass(eClass) && marshallerUseFactory(eClass)) {
|
||||
factory(factory);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -52,15 +52,11 @@ public class OpenJDKAndHashMapExamplesTest {
|
||||
@Test
|
||||
public void bondExample() throws IOException, InterruptedException {
|
||||
|
||||
Class<BondVOInterface> bondVODirectClass = directClassFor(BondVOInterface.class);
|
||||
NewInstanceObjectFactory<BondVOInterface> bondVODirectObjectFactory =
|
||||
new NewInstanceObjectFactory<BondVOInterface>(bondVODirectClass);
|
||||
File file = new File(TMP + "/chm-myBondPortfolioCHM-" + System.nanoTime());
|
||||
file.deleteOnExit();
|
||||
ChronicleMap<String, BondVOInterface> chm = ChronicleMapBuilder
|
||||
.of(String.class, bondVODirectClass)
|
||||
.valueFactory(bondVODirectObjectFactory)
|
||||
.entrySize(512)
|
||||
.of(String.class, directClassFor(BondVOInterface.class))
|
||||
.keySize(10)
|
||||
.create(file);
|
||||
|
||||
|
||||
@@ -80,9 +76,8 @@ public class OpenJDKAndHashMapExamplesTest {
|
||||
|
||||
|
||||
ChronicleMap<String, BondVOInterface> chmB = ChronicleMapBuilder
|
||||
.of(String.class, bondVODirectClass)
|
||||
.valueFactory(bondVODirectObjectFactory)
|
||||
.entrySize(320)
|
||||
.of(String.class, directClassFor(BondVOInterface.class))
|
||||
.keySize(10)
|
||||
.create(file);
|
||||
|
||||
// ZERO Copy but creates a new off heap reference each time
|
||||
|
||||
Reference in New Issue
Block a user