Class StateObjectCollection<T extends StateObject>
- Type Parameters:
T- type of the contained state objects.
- All Implemented Interfaces:
Serializable,Iterable<T>,Collection<T>,StateObject
StateObjects. Being a state object itself,
it delegates discardState() to all contained state objects and computes getStateSize() as sum of the state sizes of all contained objects.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.flink.runtime.state.StateObject
StateObject.StateObjectLocation, StateObject.StateObjectSizeStatsCollector -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new StateObjectCollection that is backed by anArrayList.StateObjectCollection(Collection<T> stateObjects) Creates a new StateObjectCollection wraps the given collection and delegates to it. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends T> c) asList()voidclear()voidCollects statistics about state size and location from the state object.booleanbooleancontainsAll(Collection<?> c) voidDiscards the state referred to and solemnly owned by this handle, to free up resources in the persistent storage.static <T extends StateObject>
StateObjectCollection<T>empty()static <T extends StateObject>
StateObjectCollection<T>emptyIfNull(StateObjectCollection<T> collection) booleanlonglongReturns the size of the state in bytes.inthashCode()booleanhasState()Returns true if this contains at least oneStateObject.booleanisEmpty()iterator()booleanbooleanremoveAll(Collection<?> c) booleanbooleanretainAll(Collection<?> c) static <T extends StateObject>
StateObjectCollection<T>singleton(T stateObject) static <T extends StateObject>
StateObjectCollection<T>singletonOrEmpty(T stateObject) intsize()Object[]toArray()<T1> T1[]toArray(T1[] a) toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, spliterator, stream, toArray
-
Constructor Details
-
StateObjectCollection
public StateObjectCollection()Creates a new StateObjectCollection that is backed by anArrayList. -
StateObjectCollection
Creates a new StateObjectCollection wraps the given collection and delegates to it.- Parameters:
stateObjects- collection of state objects to wrap.
-
-
Method Details
-
size
public int size()- Specified by:
sizein interfaceCollection<T extends StateObject>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<T extends StateObject>
-
contains
- Specified by:
containsin interfaceCollection<T extends StateObject>
-
iterator
- Specified by:
iteratorin interfaceCollection<T extends StateObject>- Specified by:
iteratorin interfaceIterable<T extends StateObject>
-
toArray
- Specified by:
toArrayin interfaceCollection<T extends StateObject>
-
toArray
public <T1> T1[] toArray(T1[] a) - Specified by:
toArrayin interfaceCollection<T extends StateObject>
-
add
- Specified by:
addin interfaceCollection<T extends StateObject>
-
remove
- Specified by:
removein interfaceCollection<T extends StateObject>
-
containsAll
- Specified by:
containsAllin interfaceCollection<T extends StateObject>
-
addAll
- Specified by:
addAllin interfaceCollection<T extends StateObject>
-
removeAll
- Specified by:
removeAllin interfaceCollection<T extends StateObject>
-
removeIf
- Specified by:
removeIfin interfaceCollection<T extends StateObject>
-
retainAll
- Specified by:
retainAllin interfaceCollection<T extends StateObject>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<T extends StateObject>
-
discardState
Description copied from interface:StateObjectDiscards the state referred to and solemnly owned by this handle, to free up resources in the persistent storage. This method is called when the state represented by this object will not be used anymore.- Specified by:
discardStatein interfaceStateObject- Throws:
Exception
-
getStateSize
public long getStateSize()Description copied from interface:StateObjectReturns the size of the state in bytes. If the size is not known, this method should return0.The values produced by this method are only used for informational purposes and for metrics/monitoring. If this method returns wrong values, the checkpoints and recovery will still behave correctly. However, efficiency may be impacted (wrong space pre-allocation) and functionality that depends on metrics (like monitoring) will be impacted.
Note for implementors: This method should not perform any I/O operations while obtaining the state size (hence it does not declare throwing an
IOException). Instead, the state size should be stored in the state object, or should be computable from the state stored in this object. The reason is that this method is called frequently by several parts of the checkpointing and issuing I/O requests from this method accumulates a heavy I/O load on the storage system at higher scale.- Specified by:
getStateSizein interfaceStateObject- Returns:
- Size of the state in bytes.
-
collectSizeStats
Description copied from interface:StateObjectCollects statistics about state size and location from the state object.- Specified by:
collectSizeStatsin interfaceStateObject- Parameters:
collector- the statistics collector.
-
getCheckpointedSize
public long getCheckpointedSize() -
hasState
public boolean hasState()Returns true if this contains at least oneStateObject. -
equals
- Specified by:
equalsin interfaceCollection<T extends StateObject>- Overrides:
equalsin classObject
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<T extends StateObject>- Overrides:
hashCodein classObject
-
toString
-
asList
-
empty
-
emptyIfNull
public static <T extends StateObject> StateObjectCollection<T> emptyIfNull(@Nullable StateObjectCollection<T> collection) -
singleton
-
singletonOrEmpty
public static <T extends StateObject> StateObjectCollection<T> singletonOrEmpty(@Nullable T stateObject)
-