Class PersistenceManager.Default<D>
java.lang.Object
one.microstream.persistence.types.PersistenceManager.Default<D>
- All Implemented Interfaces:
ByteOrderTargeting<PersistenceManager<D>>
,PersistenceManager<D>
,PersistenceObjectIdHolder
,PersistenceObjectIdLookup
,PersistenceObjectLookup
,PersistenceObjectManager<D>
,PersistenceRetrieving
,PersistenceSourceSupplier<D>
,PersistenceStoring
,PersistenceSwizzlingLookup
,Persister
,Unpersistable
,ObjectSwizzling
,Cloneable<PersistenceObjectManager<D>>
- Enclosing interface:
- PersistenceManager<D>
public static final class PersistenceManager.Default<D> extends Object implements PersistenceManager<D>, Unpersistable
-
Nested Class Summary
Nested classes/interfaces inherited from interface one.microstream.persistence.types.ByteOrderTargeting
ByteOrderTargeting.Mutable<T extends ByteOrderTargeting.Mutable<?>>
Nested classes/interfaces inherited from interface one.microstream.persistence.types.PersistenceManager
PersistenceManager.Default<D>
-
Constructor Summary
Constructors Constructor Description Default()
-
Method Summary
Modifier and Type Method Description void
close()
Closes all ties to outside resources, if applicable.<C extends Consumer<Object>>
Ccollect(C collector, long... objectIds)
void
consolidate()
PersistenceStorer
createEagerStorer()
Creates a newStorer
instance with eager storing behavior.PersistenceStorer
createLazyStorer()
Creates a newStorer
instance with lazy storing behavior.PersistenceLoader
createLoader()
PersistenceRegisterer
createRegisterer()
PersistenceStorer
createStorer()
Creates a newStorer
instance with default storing behavior.PersistenceStorer
createStorer(PersistenceStorer.Creator<D> storerCreator)
long
currentObjectId()
long
ensureObjectId(Object object)
<T> long
ensureObjectId(T object, PersistenceObjectIdRequestor<D> objectIdRequestor, PersistenceTypeHandler<D,T> optionalHandler)
<T> long
ensureObjectIdGuaranteedRegister(T object, PersistenceObjectIdRequestor<D> objectIdRequestor, PersistenceTypeHandler<D,T> optionalHandler)
Object
get()
Object
getObject(long objectId)
Retrieves the instance associated with the passed objectId.ByteOrder
getTargetByteOrder()
Object
lookupObject(long objectId)
long
lookupObjectId(Object object)
void
mergeEntries(PersistenceLocalObjectIdRegistry<D> localRegistry)
PersistenceObjectRegistry
objectRegistry()
boolean
registerLocalRegistry(PersistenceLocalObjectIdRegistry<D> localRegistry)
PersistenceSource<D>
source()
long
store(Object object)
Stores the passed instance in any case and all referenced instances of persistable references recursively, but stores referenced instances only if they are newly encountered (e.g.void
storeAll(Iterable<?> instances)
Convenience method toPersistenceStoring.store(Object)
all instances of anIterable
type, usually a collection.
The passed instance itself is NOT stored.
Note that this method does not return an array of objectIds, since the amount of instances supplied by the passedIterable
cannot be known until after all instances have been stored and the memory and performance overhead to collect them dynamically would not be worth it in most cases since the returned array is hardly ever needed.long[]
storeAll(Object... instances)
Convenience method toPersistenceStoring.store(Object)
multiple instances.PersistenceTarget<D>
target()
PersistenceTypeDictionary
typeDictionary()
PersistenceManager.Default<D>
updateCurrentObjectId(long currentObjectId)
void
updateMetadata(PersistenceTypeDictionary typeDictionary, long highestTypeId, long highestObjectId)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface one.microstream.persistence.types.ByteOrderTargeting
isByteOrderMismatch
Methods inherited from interface one.microstream.persistence.types.PersistenceManager
updateMetadata
-
Constructor Details
-
Default
public Default()
-
-
Method Details
-
getTargetByteOrder
- Specified by:
getTargetByteOrder
in interfaceByteOrderTargeting<D>
-
objectRegistry
- Specified by:
objectRegistry
in interfacePersistenceManager<D>
-
typeDictionary
- Specified by:
typeDictionary
in interfacePersistenceManager<D>
-
consolidate
public final void consolidate()- Specified by:
consolidate
in interfacePersistenceObjectManager<D>
-
createLazyStorer
Description copied from interface:Persister
Creates a newStorer
instance with lazy storing behavior. This means an entity instance encountered while traversing the entity graph is only stored if it is not yet known to the persistence context, i.e. does not have an objectId associated with it in the persistence context'sPersistenceObjectRegistry
.- Specified by:
createLazyStorer
in interfacePersistenceManager<D>
- Specified by:
createLazyStorer
in interfacePersister
- Returns:
- the newly created
Storer
instance.
-
createStorer
Description copied from interface:Persister
Creates a newStorer
instance with default storing behavior. The default is lazy storing. SeePersister.createLazyStorer()
.- Specified by:
createStorer
in interfacePersistenceManager<D>
- Specified by:
createStorer
in interfacePersister
- Returns:
- the newly created
Storer
instance.
-
createEagerStorer
Description copied from interface:Persister
Creates a newStorer
instance with eager storing behavior. This means an entity instance encountered while traversing the entity graph is always stored, regardless of if it is already known to the persistence context or not, i.e. does have an objectId associated with it in the persistence context'sPersistenceObjectRegistry
.Note: Eager storing is a dangerous behavior since - depending on the entity graph's referential layout - it can cause the whole entity graph present in the heap to be stored. Therefore, it is stronly advised to instead use lazy storing logic (see
Persister.createLazyStorer()
) or some other kind of limiting storing logic.- Specified by:
createEagerStorer
in interfacePersistenceManager<D>
- Specified by:
createEagerStorer
in interfacePersister
- Returns:
- the newly created
Storer
instance.
-
createStorer
- Specified by:
createStorer
in interfacePersistenceManager<D>
-
createRegisterer
- Specified by:
createRegisterer
in interfacePersistenceManager<D>
-
store
Description copied from interface:Persister
Stores the passed instance in any case and all referenced instances of persistable references recursively, but stores referenced instances only if they are newly encountered (e.g. don't have an id associated with them in the object registry, yet and are therefore required to be handled). This is useful for the common case of just storing an updated instance and potentially newly created instances along with it while skipping all existing (and normally unchanged) referenced instances.- Specified by:
store
in interfacePersistenceStoring
- Specified by:
store
in interfacePersister
- Parameters:
object
- the root instance of the subgraph of required instances to be stored.- Returns:
- the object id representing the passed instance.
-
storeAll
Description copied from interface:Persister
Convenience method toPersistenceStoring.store(Object)
multiple instances. The passed array (maybe implicitely created by the compiler) itself is NOT stored.- Specified by:
storeAll
in interfacePersistenceStoring
- Specified by:
storeAll
in interfacePersister
- Parameters:
instances
- multiple root instances of the subgraphs of required instances to be stored.- Returns:
- an array containing the object ids representing the passed instances.
-
storeAll
Description copied from interface:Persister
Convenience method toPersistenceStoring.store(Object)
all instances of anIterable
type, usually a collection.
The passed instance itself is NOT stored.
Note that this method does not return an array of objectIds, since the amount of instances supplied by the passedIterable
cannot be known until after all instances have been stored and the memory and performance overhead to collect them dynamically would not be worth it in most cases since the returned array is hardly ever needed. If it should be needed, the desired behavior can be easily achieved with a tiny custom-made utility method.- Specified by:
storeAll
in interfacePersistenceStoring
- Specified by:
storeAll
in interfacePersister
- Parameters:
instances
- multiple root instances of the subgraphs of required instances to be stored.
-
ensureObjectId
- Specified by:
ensureObjectId
in interfacePersistenceObjectManager<D>
-
ensureObjectId
public final <T> long ensureObjectId(T object, PersistenceObjectIdRequestor<D> objectIdRequestor, PersistenceTypeHandler<D,T> optionalHandler)- Specified by:
ensureObjectId
in interfacePersistenceObjectManager<D>
-
ensureObjectIdGuaranteedRegister
public final <T> long ensureObjectIdGuaranteedRegister(T object, PersistenceObjectIdRequestor<D> objectIdRequestor, PersistenceTypeHandler<D,T> optionalHandler)- Specified by:
ensureObjectIdGuaranteedRegister
in interfacePersistenceObjectManager<D>
-
currentObjectId
public long currentObjectId()- Specified by:
currentObjectId
in interfacePersistenceManager<D>
- Specified by:
currentObjectId
in interfacePersistenceObjectIdHolder
- Specified by:
currentObjectId
in interfacePersistenceObjectManager<D>
-
lookupObjectId
- Specified by:
lookupObjectId
in interfacePersistenceObjectIdLookup
-
lookupObject
- Specified by:
lookupObject
in interfacePersistenceObjectLookup
-
registerLocalRegistry
- Specified by:
registerLocalRegistry
in interfacePersistenceObjectManager<D>
-
mergeEntries
- Specified by:
mergeEntries
in interfacePersistenceObjectManager<D>
-
get
- Specified by:
get
in interfacePersistenceRetrieving
-
collect
- Specified by:
collect
in interfacePersistenceRetrieving
-
getObject
Description copied from interface:ObjectSwizzling
Retrieves the instance associated with the passed objectId. Retrieving means guaranteeing that the associated instance is returned. If it does not yet exist, it will be created from persisted data, including all non-lazily referenced objects it is connected to.- Specified by:
getObject
in interfaceObjectSwizzling
- Specified by:
getObject
in interfacePersistenceRetrieving
- Specified by:
getObject
in interfacePersistenceSourceSupplier<D>
- Specified by:
getObject
in interfacePersister
- Parameters:
objectId
- the objectId defining which instance to return.- Returns:
- the instance associated with the passed objectId.
-
createLoader
- Specified by:
createLoader
in interfacePersistenceManager<D>
-
source
- Specified by:
source
in interfacePersistenceManager<D>
- Specified by:
source
in interfacePersistenceSourceSupplier<D>
-
target
- Specified by:
target
in interfacePersistenceManager<D>
-
close
public void close()Description copied from interface:PersistenceManager
Closes all ties to outside resources, if applicable. Typ- Specified by:
close
in interfacePersistenceManager<D>
-
updateCurrentObjectId
- Specified by:
updateCurrentObjectId
in interfacePersistenceManager<D>
- Specified by:
updateCurrentObjectId
in interfacePersistenceObjectIdHolder
- Specified by:
updateCurrentObjectId
in interfacePersistenceObjectManager<D>
-
updateMetadata
public void updateMetadata(PersistenceTypeDictionary typeDictionary, long highestTypeId, long highestObjectId)- Specified by:
updateMetadata
in interfacePersistenceManager<D>
-