Class BinaryStorer.Default
- java.lang.Object
-
- org.eclipse.serializer.persistence.binary.types.BinaryStorer.Default
-
- All Implemented Interfaces:
BinaryStorer,PersistenceFunction,PersistenceLocalObjectIdRegistry<Binary>,PersistenceObjectIdRequestor<Binary>,PersistenceStoreHandler<Binary>,PersistenceStorer,PersistenceStoring,Storer
- Direct Known Subclasses:
BinaryStorer.Eager
- Enclosing interface:
- BinaryStorer
public static class BinaryStorer.Default extends Object implements BinaryStorer, PersistenceStoreHandler<Binary>, PersistenceLocalObjectIdRegistry<Binary>
Default implementation that stores referenced instances only if required (i.e. if they have no OID assigned yet, therefore have not been stored yet, therefore require to be stored). It can be seen as a "lazy" or "on demand" storer as opposed toBinaryStorer.Eager.
For a more differentiated solution between the two simple, but extreme strategies, seePersistenceEagerStoringFieldEvaluator.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.serializer.persistence.binary.types.BinaryStorer
BinaryStorer.Creator, BinaryStorer.Default, BinaryStorer.Eager, BinaryStorer.Item
-
Nested classes/interfaces inherited from interface org.eclipse.serializer.persistence.types.PersistenceObjectIdRequestor
PersistenceObjectIdRequestor.NoOp<D extends Object>
-
Nested classes/interfaces inherited from interface org.eclipse.serializer.persistence.types.PersistenceStorer
PersistenceStorer.CreationObserver
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefault(PersistenceObjectManager<Binary> objectManager, org.eclipse.serializer.reference.ObjectSwizzling objectRetriever, PersistenceTypeHandlerManager<Binary> typeManager, PersistenceTarget<Binary> target, org.eclipse.serializer.util.BufferSizeProviderIncremental bufferSizeProvider, int channelCount, boolean switchByteOrder, Persister persister)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> longapply(T instance)<T> longapply(T instance, PersistenceTypeHandler<Binary,T> localTypeHandler)<T> longapplyEager(T instance)<T> longapplyEager(T instance, PersistenceTypeHandler<Binary,T> localTypeHandler)voidclear()Objectcommit()longcurrentCapacity()protected static intdefaultSlotSize()PersistenceStorerensureCapacity(long desiredCapacity)org.eclipse.serializer.reference.ObjectSwizzlinggetObjectRetriever()PersistergetPersister()protected voidinternalInitialize(int hashLength)protected longinternalStore(Object root)Stores the passed instance (always) and interprets it as the root of a graph to be traversed and have its instances stored recursively if deemed necessary by the logic until all instance that can be reached by that logic have been handled.voiditerateMergeableEntries(PersistenceAcceptor iterator)<T> longlookupObjectId(T object, PersistenceObjectIdRequestor<Binary> objectIdRequestor, PersistenceTypeHandler<Binary,T> optionalHandler)longlookupOid(Object object)longmaximumCapacity()protected voidnotifyCommitListeners()PersistenceObjectManager<Binary>parentObjectManager()protected longregister(Object instance)voidregisterCommitListener(PersistenceCommitListener listener)<T> voidregisterEagerOptional(long objectId, T instance, PersistenceTypeHandler<Binary,T> optionalHandler)<T> voidregisterGuaranteed(long objectId, T instance, PersistenceTypeHandler<Binary,T> optionalHandler)protected longregisterGuaranteed(Object instance)<T> voidregisterLazyOptional(long objectId, T instance, PersistenceTypeHandler<Binary,T> optionalHandler)voidregisterRegistrationListener(PersistenceObjectRegistrationListener listener)PersistenceStorerreinitialize()PersistenceStorerreinitialize(long initialCapacity)longsize()booleanskip(Object instance)booleanskipMapped(Object instance, long objectId)booleanskipNulled(Object instance)longstore(Object root)voidstoreAll(Iterable<?> instances)long[]storeAll(Object... instances)protected voidstoreItem(BinaryStorer.Item item)protected BinarysynchComplete()protected ChunksBuffersynchLookupChunk(long objectId)voidsynchRebuildStoreItems()voidsynchRebuildStoreItems(int newLength)<T> BinaryStorer.ItemsynchRegisterObjectId(T instance, PersistenceTypeHandler<Binary,? super T> typeHandler, long objectId)
-
-
-
Constructor Detail
-
Default
protected Default(PersistenceObjectManager<Binary> objectManager, org.eclipse.serializer.reference.ObjectSwizzling objectRetriever, PersistenceTypeHandlerManager<Binary> typeManager, PersistenceTarget<Binary> target, org.eclipse.serializer.util.BufferSizeProviderIncremental bufferSizeProvider, int channelCount, boolean switchByteOrder, Persister persister)
-
-
Method Detail
-
defaultSlotSize
protected static int defaultSlotSize()
-
parentObjectManager
public final PersistenceObjectManager<Binary> parentObjectManager()
- Specified by:
parentObjectManagerin interfacePersistenceLocalObjectIdRegistry<Binary>
-
getObjectRetriever
public final org.eclipse.serializer.reference.ObjectSwizzling getObjectRetriever()
- Specified by:
getObjectRetrieverin interfacePersistenceStoreHandler<Binary>
-
maximumCapacity
public final long maximumCapacity()
- Specified by:
maximumCapacityin interfaceBinaryStorer- Specified by:
maximumCapacityin interfaceStorer
-
currentCapacity
public final long currentCapacity()
- Specified by:
currentCapacityin interfaceBinaryStorer- Specified by:
currentCapacityin interfaceStorer
-
getPersister
public Persister getPersister()
- Specified by:
getPersisterin interfacePersistenceStoreHandler<Binary>
-
synchLookupChunk
protected ChunksBuffer synchLookupChunk(long objectId)
-
synchComplete
protected Binary synchComplete()
-
reinitialize
public PersistenceStorer reinitialize()
- Specified by:
reinitializein interfaceBinaryStorer- Specified by:
reinitializein interfacePersistenceStorer- Specified by:
reinitializein interfaceStorer
-
reinitialize
public PersistenceStorer reinitialize(long initialCapacity)
- Specified by:
reinitializein interfaceBinaryStorer- Specified by:
reinitializein interfacePersistenceStorer- Specified by:
reinitializein interfaceStorer
-
internalInitialize
protected void internalInitialize(int hashLength)
-
ensureCapacity
public PersistenceStorer ensureCapacity(long desiredCapacity)
- Specified by:
ensureCapacityin interfaceBinaryStorer- Specified by:
ensureCapacityin interfacePersistenceStorer- Specified by:
ensureCapacityin interfaceStorer
-
apply
public <T> long apply(T instance)
- Specified by:
applyin interfacePersistenceFunction- Specified by:
applyin interfacePersistenceStoreHandler<Binary>
-
apply
public <T> long apply(T instance, PersistenceTypeHandler<Binary,T> localTypeHandler)- Specified by:
applyin interfacePersistenceStoreHandler<Binary>
-
applyEager
public final <T> long applyEager(T instance)
- Specified by:
applyEagerin interfacePersistenceStoreHandler<Binary>
-
applyEager
public <T> long applyEager(T instance, PersistenceTypeHandler<Binary,T> localTypeHandler)- Specified by:
applyEagerin interfacePersistenceStoreHandler<Binary>
-
internalStore
protected final long internalStore(Object root)
Stores the passed instance (always) and interprets it as the root of a graph to be traversed and have its instances stored recursively if deemed necessary by the logic until all instance that can be reached by that logic have been handled.- Parameters:
root- the root object of the graph- Returns:
- the root's object id
-
storeItem
protected final void storeItem(BinaryStorer.Item item)
-
store
public final long store(Object root)
- Specified by:
storein interfacePersistenceStoring
-
storeAll
public final long[] storeAll(Object... instances)
- Specified by:
storeAllin interfacePersistenceStoring
-
storeAll
public void storeAll(Iterable<?> instances)
- Specified by:
storeAllin interfacePersistenceStoring
-
iterateMergeableEntries
public void iterateMergeableEntries(PersistenceAcceptor iterator)
- Specified by:
iterateMergeableEntriesin interfacePersistenceLocalObjectIdRegistry<Binary>
-
registerCommitListener
public void registerCommitListener(PersistenceCommitListener listener)
- Specified by:
registerCommitListenerin interfacePersistenceStoreHandler<Binary>- Specified by:
registerCommitListenerin interfaceStorer
-
registerRegistrationListener
public void registerRegistrationListener(PersistenceObjectRegistrationListener listener)
- Specified by:
registerRegistrationListenerin interfaceStorer
-
notifyCommitListeners
protected void notifyCommitListeners()
-
lookupOid
public final long lookupOid(Object object)
-
lookupObjectId
public final <T> long lookupObjectId(T object, PersistenceObjectIdRequestor<Binary> objectIdRequestor, PersistenceTypeHandler<Binary,T> optionalHandler)- Specified by:
lookupObjectIdin interfacePersistenceLocalObjectIdRegistry<Binary>
-
registerGuaranteed
public final <T> void registerGuaranteed(long objectId, T instance, PersistenceTypeHandler<Binary,T> optionalHandler)- Specified by:
registerGuaranteedin interfacePersistenceObjectIdRequestor<Binary>
-
registerLazyOptional
public <T> void registerLazyOptional(long objectId, T instance, PersistenceTypeHandler<Binary,T> optionalHandler)- Specified by:
registerLazyOptionalin interfacePersistenceObjectIdRequestor<Binary>
-
registerEagerOptional
public <T> void registerEagerOptional(long objectId, T instance, PersistenceTypeHandler<Binary,T> optionalHandler)- Specified by:
registerEagerOptionalin interfacePersistenceObjectIdRequestor<Binary>
-
register
protected final long register(Object instance)
-
registerGuaranteed
protected final long registerGuaranteed(Object instance)
-
skipMapped
public final boolean skipMapped(Object instance, long objectId)
- Specified by:
skipMappedin interfaceStorer
-
skipNulled
public final boolean skipNulled(Object instance)
- Specified by:
skipNulledin interfaceStorer
-
synchRegisterObjectId
public final <T> BinaryStorer.Item synchRegisterObjectId(T instance, PersistenceTypeHandler<Binary,? super T> typeHandler, long objectId)
-
synchRebuildStoreItems
public final void synchRebuildStoreItems()
-
synchRebuildStoreItems
public final void synchRebuildStoreItems(int newLength)
-
-