Package org.nuxeo.ecm.core.storage.sql
Class SelectionContext
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.sql.SelectionContext
-
public class SelectionContext extends Object
ASelectionContextholds information for a setSelectionobjects, mostly acting as a cache.Some of the information is identical to what's in the database and can be safely be GC'ed, so it lives in a memory-sensitive map (softMap), otherwise it's moved to a normal map (hardMap) (creation or deletion).
-
-
Field Summary
Fields Modifier and Type Field Description protected io.dropwizard.metrics5.TimercacheGetTimerprotected io.dropwizard.metrics5.CountercacheHitCountMap<Serializable,Selection>hardMapprotected io.dropwizard.metrics5.CountermodifiedInTransactionCountprotected io.dropwizard.metrics5.MetricRegistryregistry
-
Constructor Summary
Constructors Constructor Description SelectionContext(SelectionType selType, Serializable criterion, RowMapper mapper, PersistenceContext context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplicable(SimpleFragment fragment)intclearCaches()voidgatherInvalidations(VCSInvalidations invalidations)Gathers invalidations from this session.SimpleFragmentgetSelectionFragment(Serializable selId, String filter)Find a fragment given its selection id and value.List<SimpleFragment>getSelectionFragments(Serializable selId, String filter)Finds all the selection fragments for a given id.Set<Serializable>getSelectionIds(List<Serializable> values)Gets all the selection fragment ids for a given list of values.protected SelectiongetSelectionOrNull(Serializable selId)Gets the proper selection cache, if it exists, otherwise returnsnull.intgetSize()voidmarkInvalidated(Set<RowId> modified)Marks locally all the invalidations gathered by aMapperoperation (like a version restore).voidnewSelection(Serializable selId)Notes that a new empty selection should be created.voidpostSave()voidprocessReceivedInvalidations(Set<RowId> modified)Processes all invalidations accumulated.voidrecordCreated(SimpleFragment fragment)Records the fragment as a just-created selection member.voidrecordExisting(SimpleFragment fragment, boolean invalidate)voidrecordRemoved(Serializable id, Serializable selId)Removes a selection item from the selection.voidrecordRemoved(SimpleFragment fragment)Removes a selection item from the selection.voidrecordRemovedSelection(Serializable selId)Records a selection as removed.
-
-
-
Field Detail
-
hardMap
public final Map<Serializable,Selection> hardMap
-
registry
protected final io.dropwizard.metrics5.MetricRegistry registry
-
modifiedInTransactionCount
protected final io.dropwizard.metrics5.Counter modifiedInTransactionCount
-
cacheHitCount
protected final io.dropwizard.metrics5.Counter cacheHitCount
-
cacheGetTimer
protected final io.dropwizard.metrics5.Timer cacheGetTimer
-
-
Constructor Detail
-
SelectionContext
public SelectionContext(SelectionType selType, Serializable criterion, RowMapper mapper, PersistenceContext context)
-
-
Method Detail
-
clearCaches
public int clearCaches()
-
getSize
public int getSize()
-
getSelectionOrNull
protected Selection getSelectionOrNull(Serializable selId)
Gets the proper selection cache, if it exists, otherwise returnsnull.- Since:
- 9.2
-
applicable
public boolean applicable(SimpleFragment fragment)
-
recordCreated
public void recordCreated(SimpleFragment fragment)
Records the fragment as a just-created selection member.
-
newSelection
public void newSelection(Serializable selId)
Notes that a new empty selection should be created.
-
recordExisting
public void recordExisting(SimpleFragment fragment, boolean invalidate)
- Parameters:
invalidate-trueif this is for a fragment newly created by internal database process (copy, etc.) and must notified to other session;falseif this is a normal read
-
recordRemoved
public void recordRemoved(SimpleFragment fragment)
Removes a selection item from the selection.
-
recordRemoved
public void recordRemoved(Serializable id, Serializable selId)
Removes a selection item from the selection.
-
recordRemovedSelection
public void recordRemovedSelection(Serializable selId)
Records a selection as removed.
-
getSelectionFragment
public SimpleFragment getSelectionFragment(Serializable selId, String filter)
Find a fragment given its selection id and value.If the fragment is not in the context, fetch it from the mapper.
- Parameters:
selId- the selection idfilter- the value to filter on- Returns:
- the fragment, or
nullif not found
-
getSelectionFragments
public List<SimpleFragment> getSelectionFragments(Serializable selId, String filter)
Finds all the selection fragments for a given id.No sorting on value is done.
- Parameters:
selId- the selection idfilter- the value to filter on, ornullfor all- Returns:
- the list of fragments
-
getSelectionIds
public Set<Serializable> getSelectionIds(List<Serializable> values)
Gets all the selection fragment ids for a given list of values.- Since:
- 9.2
-
postSave
public void postSave()
-
markInvalidated
public void markInvalidated(Set<RowId> modified)
Marks locally all the invalidations gathered by aMapperoperation (like a version restore).
-
gatherInvalidations
public void gatherInvalidations(VCSInvalidations invalidations)
Gathers invalidations from this session.Called post-transaction to gathers invalidations to be sent to others.
-
-