public interface Storer extends PersistenceStoring
PersistenceStoring to enable stateful store handling.
This can be used to do what is generally called "transactions": preprocess data to be stored and then store
either all or nothing.skip(Object)| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clears all internal state regarding collected data and/or registered skips.
|
Object |
commit()
Ends the data collection process and causes all collected data to be persisted.
|
long |
currentCapacity()
Returns the internal state's value significant for its capacity of unique instances.
|
Storer |
ensureCapacity(long desiredCapacity)
Ensures that the instance's internal state is prepared for handling an amount of unique instance equal to
the passed value.
|
default boolean |
isEmpty()
Queries, whether this
Storer instance has no instances / references registered. |
long |
maximumCapacity()
The maximum value that
currentCapacity() can reach. |
Storer |
reinitialize()
Enforces the instance to be initialized, discarding any previous state (clearing it) if necessary.
|
Storer |
reinitialize(long initialCapacity)
Enforces the instance to be initialized, discarding any previous state (clearing it) if necessary.
|
long |
size() |
boolean |
skip(Object instance)
Registers the passed instance to be skipped from the data persisting process.
|
boolean |
skipMapped(Object instance,
long objectId)
Registers the passed instance under the passed objectId without persisting its data.
|
boolean |
skipNulled(Object instance)
Registers the passed instance to be skipped from the data persisting process.
|
store, storeAll, storeAllObject commit()
This is an atomatic all-or-nothing operation: either all collected data will be persisted successfully, or non of it will be persisted. Partially persisted data will be reverted / rolled back in case of a failure.
void clear()
boolean skipMapped(Object instance, long objectId)
This skip means that if the passed instance is encountered while collecting data to be persisted, its data will NOT be collected. References to the passed instance will be persisted as the passed objectId.
Warning:
This method can be very useful to rearrange object graphs on the persistence level, but it can also cause
inconsistencies if not used perfectly correctly.
It is strongly advised to use one of the following alternatives instead:
skip(Object)
skipNulled(Object)
instance - the instance / reference to be skipped.objectId - the objectId to be used as a reference to the skipped instance.skip(Object),
skipNulled(Object)boolean skip(Object instance)
This skip means that if the passed instance is encountered while collecting data to be persisted,
its data will NOT be collected. If the instance is already registered under a certain object id at the used
PersistenceObjectRegistry, then is associated object id will be used. Otherwise, the null-Id will be
used, effectively "nulling out" all references to this instance on the persistent level.
The latter behavior is exactly the same as skipNulled(Object).
instance - the instance / reference to be skipped.skipNulled(Object),
skipMapped(Object, long)boolean skipNulled(Object instance)
This skip means that if the passed instance is encountered while collecting data to be persisted,
its data will NOT be collected. References to this instance will always be persisted as null, no matter if
the instance is already registered for a certain object id at the used PersistenceObjectRegistry
or not.
To make the skipping consider existing object id registrations, use skip(Object).
instance - the instance / reference to be skipped by using .skip(Object),
skipMapped(Object, long)long size()
Storer instance. This includes both instances encountered during the data collection process and
instances that have explicitely been registered to be skipped.skip(Object),
skipMapped(Object, long)default boolean isEmpty()
Storer instance has no instances / references registered.
Calling this method is simply an alias for this.size() == 0L.
Storer instance is empty.long currentCapacity()
long maximumCapacity()
currentCapacity() can reach. For more explanation on the exact meaning of the
capacity, see there.Storer reinitialize()
Storer reinitialize(long initialCapacity)
initialCapacity - the amount of unique instances that this instance shall prepare to handle.Storer ensureCapacity(long desiredCapacity)
desiredCapacity - the amount of unique instances that this instance shall prepare to handle.Copyright © 2022 MicroStream Software. All rights reserved.