org.openjena.atlas.data
Class ThresholdPolicyMemory<T>

java.lang.Object
  extended by org.openjena.atlas.data.ThresholdPolicyMemory<T>
All Implemented Interfaces:
ThresholdPolicy<T>

public class ThresholdPolicyMemory<T>
extends Object
implements ThresholdPolicy<T>

A threshold policy based on the estimated memory size of the tuples added.

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 Summary
ThresholdPolicyMemory(long threshold, SerializationFactory<T> serializerFactory)
           
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThresholdPolicyMemory

public ThresholdPolicyMemory(long threshold,
                             SerializationFactory<T> serializerFactory)
Method Detail

increment

public void increment(T item)
Description copied from interface: ThresholdPolicy
Call this method each time to increment the policy's threshold count.

Specified by:
increment in interface ThresholdPolicy<T>
Parameters:
item - The item that was added.

isThresholdExceeded

public boolean isThresholdExceeded()
Description copied from interface: ThresholdPolicy
Determines whether or not the configured threshold has been exceeded for this policy.

Specified by:
isThresholdExceeded in interface ThresholdPolicy<T>
Returns:
true if the threshold has been reached; false otherwise.

reset

public void reset()
Description copied from interface: ThresholdPolicy
Reset the policy back to the initial state.

Specified by:
reset in interface ThresholdPolicy<T>

getThreshold

public long getThreshold()
Returns the threshold before the list is written to disk.

Returns:
The threshold point.

getCount

public long getCount()
Returns the current count of the number of items incremented in this policy.

Returns:
The item count.

getMemorySize

public long getMemorySize()
Returns the current total estimated memory size of all the items incremented in this policy.

Returns:
The item count.

toString

public String toString()
Overrides:
toString in class Object


Licenced under the Apache License, Version 2.0