Package elki.logging.progress
Class AbstractProgress
- java.lang.Object
-
- elki.logging.progress.AbstractProgress
-
- All Implemented Interfaces:
Progress
- Direct Known Subclasses:
FiniteProgress,IndefiniteProgress,MutableProgress
public abstract class AbstractProgress extends java.lang.Object implements Progress
Abstract base class for FiniteProgress objects.- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private longlastLoggedFor logging rate control.private intlastValueLast logged value.private java.util.concurrent.atomic.AtomicIntegerprocessedThe number of items already processed at a time being.protected doubleratemsLast rate.private java.lang.StringtaskThe task name.
-
Constructor Summary
Constructors Constructor Description AbstractProgress(java.lang.String task)Default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.StringBuilderappendToBuffer(java.lang.StringBuilder buf)Serialize a description into a String buffer.intgetProcessed()Get the number of items already processed at a time being.java.lang.StringgetTask()Provides the name of the task.voidincrementProcessed(Logging logger)Increment the processed counter.protected voidsetProcessed(int processed)Sets the number of items already processed at a time being.voidsetProcessed(int processed, Logging logger)Sets the number of items already processed at a time being.protected booleantestLoggingRate(int processed)Logging rate control.java.lang.StringtoString()Returns a String representation of the progress suitable as a message for printing to the command line interface.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface elki.logging.progress.Progress
isComplete
-
-
-
-
Field Detail
-
processed
private java.util.concurrent.atomic.AtomicInteger processed
The number of items already processed at a time being. We use AtomicInteger to allow threaded use without synchronization.
-
task
private java.lang.String task
The task name.
-
lastLogged
private long lastLogged
For logging rate control.
-
lastValue
private int lastValue
Last logged value.
-
ratems
protected double ratems
Last rate.
-
-
Method Detail
-
getTask
public java.lang.String getTask()
Provides the name of the task.- Returns:
- the name of the task
-
setProcessed
protected void setProcessed(int processed) throws java.lang.IllegalArgumentExceptionSets the number of items already processed at a time being.- Parameters:
processed- the number of items already processed at a time being- Throws:
java.lang.IllegalArgumentException- if an invalid value was passed.
-
setProcessed
public void setProcessed(int processed, Logging logger) throws java.lang.IllegalArgumentExceptionSets the number of items already processed at a time being.- Parameters:
processed- the number of items already processed at a time beinglogger- Logger to report to- Throws:
java.lang.IllegalArgumentException- if an invalid value was passed.
-
getProcessed
public int getProcessed()
Get the number of items already processed at a time being.- Returns:
- number of processed items
-
appendToBuffer
public abstract java.lang.StringBuilder appendToBuffer(java.lang.StringBuilder buf)
Serialize a description into a String buffer.- Specified by:
appendToBufferin interfaceProgress- Parameters:
buf- Buffer to serialize to- Returns:
- Buffer the data was serialized to.
-
toString
public java.lang.String toString()
Returns a String representation of the progress suitable as a message for printing to the command line interface.
-
incrementProcessed
public void incrementProcessed(Logging logger)
Increment the processed counter.- Parameters:
logger- Logger to report to.
-
testLoggingRate
protected boolean testLoggingRate(int processed)
Logging rate control.- Parameters:
processed- Counter- Returns:
- true when logging is sensible
-
-