public class ThresholdPolicyMemory<T> extends Object implements ThresholdPolicy<T>
TODO This policy isn't ready to be used because the SerializationFactorys don't support generating memory estimates yet.
TODO It might be too expensive to examine each tuple individually. We could change it to sample the first 100 tuples to calculate an average tuple size.
Constructor and Description |
---|
ThresholdPolicyMemory(long threshold,
SerializationFactory<T> serializerFactory) |
Modifier and Type | Method and Description |
---|---|
long |
getCount()
Returns the current count of the number of items incremented in this policy.
|
long |
getMemorySize()
Returns the current total estimated memory size of all the items incremented in this policy.
|
long |
getThreshold()
Returns the threshold before the list is written to disk.
|
void |
increment(T item)
Call this method each time to increment the policy's threshold count.
|
boolean |
isThresholdExceeded()
Determines whether or not the configured threshold has been exceeded for this policy.
|
void |
reset()
Reset the policy back to the initial state.
|
String |
toString() |
public ThresholdPolicyMemory(long threshold, SerializationFactory<T> serializerFactory)
public void increment(T item)
ThresholdPolicy
increment
in interface ThresholdPolicy<T>
item
- The item that was added.public boolean isThresholdExceeded()
ThresholdPolicy
isThresholdExceeded
in interface ThresholdPolicy<T>
true
if the threshold has been reached; false
otherwise.public void reset()
ThresholdPolicy
reset
in interface ThresholdPolicy<T>
public long getThreshold()
public long getCount()
public long getMemorySize()
Licenced under the Apache License, Version 2.0