public class MappedLog
extends java.lang.Object
Log a string (single-line) into a file but also keep all text in a HashSet so
that the strings can quickly looked up. This class is useful to create simple
checkpoint mechanism.
At first call, MappedLog looks for the specified file and reads it into
memory if exists.
At each call, the MappedLog checks if a the input line already is in the set.
If not, it writes the line into the set and the file. It returns the boolean
flag indicating whether the line was already found (true) or not (false). The
check and write is an atomic operation, so two actors cannot mix up this
behaviour.
All actors can write into the same file, if their parameter points to the
same file. This allows checking if others already did (and logged) something.
Query only (not writing out a line, but only checking its existence) can be
achieved by setting the boolean flag 'checkOnly'.
If the line is empty (or only white spaces), nothing will be written and
false will be returned.
- Since:
- Ptolemy II 5.0.1
- Author:
- Norbert Podhorszki