|
JTemporal Home Tutorial |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jtemporal.spi.LazyTemporalAttributeStorage<V>
V
- the type of the valuepublic class LazyTemporalAttributeStorage<V>
This storage is based on a cache whose size grows lazily, until all the underlying data is in the cache. This caching strategy is appropriate for applications handling primarily recent data, which is the case of most applications
It loads lazily the data between the positive infinity and the requested
instant. If subsequently you ask an instant that precedes the previous request,
it loads then the gap between both requested instants. This continues until
the whole history is in cache.
Unlike usual caching APIs, these methods intentionally return void, in
order to give you full freedom in implementing prefetching strategies,
where on a call you decide to load more data than requested, possibly
in other instances of LazyTemporalAttributeStorage.
Warning: the methods with no instant or period as a parameter
usually cause the entire underlying data to be loaded. For example,
isEmpty() will load all the underlying data.
Nested Class Summary | |
---|---|
static interface |
LazyTemporalAttributeStorage.ChangeHandler<V>
Applies the changes on the underlying data source. |
static interface |
LazyTemporalAttributeStorage.MissingRangeHandler<V>
Loads the data from the real physical storage into the the LazyTemporalAttributeStorage cache, when additional data is requested. |
Constructor Summary | |
---|---|
LazyTemporalAttributeStorage(LazyTemporalAttributeStorage.MissingRangeHandler<V> loader)
Instantiates a read only LazyTemporalAttributeStorage. |
|
LazyTemporalAttributeStorage(LazyTemporalAttributeStorage.MissingRangeHandler<V> loader,
LazyTemporalAttributeStorage.ChangeHandler<V> writer)
Instantiates a read-write LazyTemporalAttributeStorage. |
Method Summary | |
---|---|
void |
beginAtomicOperation()
Tells the storage that the JTemporal client is calling a method that can result in multiples updates in the storage. |
void |
clear()
Removes all the stored mappings. |
void |
clearCache()
|
boolean |
containsValue(java.lang.Object value)
Returns true if this map maps one or more Periods to the specified value. |
boolean |
containsValue(java.lang.Object value,
Period range)
Returns true if this map maps one or more Periods to the specified value, during the specified period. |
void |
endAtomicOperation()
Tells the storage that an atomic operation has finished. |
CloseableIterator |
entryIterator()
Iterates over all the entries of the storage. |
CloseableIterator |
entryIterator(Period p)
Iterates over all the entries of the storage that intersects the period P. |
Period |
firstPeriod()
Returns the first (lowest) period currently in this storage. |
Period |
firstPeriod(Period p)
Returns the first (lowest) period currently in this storage, that intersects the given period. |
TimedObject |
getEntry(Instant instant)
Returns the entry valid at the given instant, if any is found. |
TimedObject |
getEntryEndingAt(Instant instant)
Returns the entry finishing exactly at the given instant, if any is found. |
TimedObject |
getEntryStartingAt(Instant instant)
Returns the entry starting exactly at the given instant, if any is found. |
Period |
getPeriod(Instant instant)
Returns the period that encloses the given instant, if any is found. |
java.lang.Object |
getValue(Instant instant)
Returns the value to which this map maps the specified Instant. |
boolean |
isEmpty()
Returns true if this storage does not contain objects. |
boolean |
isEmpty(Period p)
Returns true if this storage does not contain objects intersecting the given period. |
Period |
lastPeriod()
Returns the last (highest) period currently in this storage. |
Period |
lastPeriod(Period p)
Returns the last (highest) period currently in this storage, that intersects the given period. |
CloseableIterator |
periodIterator()
Iterates over all the periods of the storage. |
CloseableIterator |
periodIterator(Period p)
Iterates over all the periods of the storage that intersects the period P. |
void |
populated(Period p)
Called by the implementation of LazyTemporalAttributeStorage.MissingRangeHandler.populateRange(LazyTemporalAttributeStorage, Period) to to tell which Period (or additional Period) can now considered as complete in the cache. |
void |
put(Period p,
java.lang.Object value)
Stores a mapping (entry, tuple, row) composed by period and value. |
void |
putInCache(Period p,
V o)
Called by the implementation of LazyTemporalAttributeStorage.MissingRangeHandler.populateRange(LazyTemporalAttributeStorage, Period) to add entries in the cache. |
void |
removeEntry(Period p)
Removes an entry composed by period and value previously stored. |
int |
removeRange(Period range)
Removes all the entries whose period indersects the given period. |
int |
size()
Returns the number of Period-value mappings in this map. |
int |
size(Period p)
Returns the number of Period-value mappings in this map, for the given priod. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LazyTemporalAttributeStorage(LazyTemporalAttributeStorage.MissingRangeHandler<V> loader)
loader
- public LazyTemporalAttributeStorage(LazyTemporalAttributeStorage.MissingRangeHandler<V> loader, LazyTemporalAttributeStorage.ChangeHandler<V> writer)
loader
- Method Detail |
---|
public void clearCache()
public void putInCache(Period p, V o)
p
- period with which the specified value is associated. Cannot be null.o
- value to be associated with the specified key. Cannot be null.put(Period, Object)
public void populated(Period p)
public Period lastPeriod()
TemporalAttributeStorage
lastPeriod
in interface TemporalAttributeStorage
public Period lastPeriod(Period p)
TemporalAttributeStorage
lastPeriod
in interface TemporalAttributeStorage
p
- the intersecting period
public Period firstPeriod()
TemporalAttributeStorage
firstPeriod
in interface TemporalAttributeStorage
public Period firstPeriod(Period p)
TemporalAttributeStorage
firstPeriod
in interface TemporalAttributeStorage
p
- the intersecting period
public boolean isEmpty()
TemporalAttributeStorage
isEmpty
in interface TemporalAttributeStorage
public boolean isEmpty(Period p)
TemporalAttributeStorage
isEmpty
in interface TemporalAttributeStorage
p
- the intersecting period
public boolean containsValue(java.lang.Object value)
TemporalAttributeStorage
containsValue
in interface TemporalAttributeStorage
value
- value whose presence in this map is to be tested.
public boolean containsValue(java.lang.Object value, Period range)
TemporalAttributeStorage
containsValue
in interface TemporalAttributeStorage
value
- value whose presence in this map is to be tested.range
- the period intersecting the value mappings
public java.lang.Object getValue(Instant instant)
TemporalAttributeStorage
getValue
in interface TemporalAttributeStorage
instant
- instant whose associated value is to be returned
public Period getPeriod(Instant instant)
TemporalAttributeStorage
getPeriod
in interface TemporalAttributeStorage
instant
- instant whose associated value is to be returned
public TimedObject getEntry(Instant instant)
TemporalAttributeStorage
getEntry
in interface TemporalAttributeStorage
instant
- instant whose associated value is to be returned
public TimedObject getEntryEndingAt(Instant instant)
TemporalAttributeStorage
getEntryEndingAt
in interface TemporalAttributeStorage
instant
- the instant the equals the entry end
public TimedObject getEntryStartingAt(Instant instant)
TemporalAttributeStorage
getEntryStartingAt
in interface TemporalAttributeStorage
instant
- the instant the equals the entry end
public void beginAtomicOperation()
TemporalAttributeStorage
beginAtomicOperation
in interface TemporalAttributeStorage
TemporalAttributeStorage.endAtomicOperation()
public void endAtomicOperation()
TemporalAttributeStorage
endAtomicOperation
in interface TemporalAttributeStorage
TemporalAttributeStorage.beginAtomicOperation()
public void clear()
TemporalAttributeStorage
clear
in interface TemporalAttributeStorage
public int size()
TemporalAttributeStorage
size
in interface TemporalAttributeStorage
public int size(Period p)
TemporalAttributeStorage
size
in interface TemporalAttributeStorage
p
- the intersecting period
public void put(Period p, java.lang.Object value)
TemporalAttributeStorage
put
in interface TemporalAttributeStorage
p
- period with which the specified value is associated. Cannot be null.value
- value to be associated with the specified key. Cannot be null.public void removeEntry(Period p)
TemporalAttributeStorage
removeEntry
in interface TemporalAttributeStorage
p
- period whose mapping is to be removed from the storage. It
must exactly match the key of an existing entry.public int removeRange(Period range)
TemporalAttributeStorage
removeRange
in interface TemporalAttributeStorage
range
- the period specifying that range whose interecting entries are
to be deleted.
public CloseableIterator entryIterator()
TemporalAttributeStorage
entryIterator
in interface TemporalAttributeStorage
TimedObject
public CloseableIterator entryIterator(Period p)
TemporalAttributeStorage
entryIterator
in interface TemporalAttributeStorage
p
- the intersecting period.
TimedObject
public CloseableIterator periodIterator()
TemporalAttributeStorage
periodIterator
in interface TemporalAttributeStorage
Period
public CloseableIterator periodIterator(Period p)
TemporalAttributeStorage
periodIterator
in interface TemporalAttributeStorage
p
- the intersecting period.
Period
public java.lang.String toString()
toString
in class java.lang.Object
|
JTemporal Home Tutorial |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |