Class StandardCacheBucket
java.lang.Object
com.inductiveautomation.ignition.common.sqltags.history.cache.StandardCacheBucket
- All Implemented Interfaces:
CacheBucket
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionStandardCacheBucket
(SubCache parent, long start, long end) Creates a new bucket that represents the time, and the parameters inherited from SubCache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
This where we look at our statistics and calculate how important this bucket is.
The parameters we have to work with:
Fetch time - how long the data took to load.boolean
eject()
Tells the bucket that the cache would like to eject it.getData
(TagHistoryQueryProvider backingProvider) Returns the cached data, or goes to the store and retrieves it.long
protected org.apache.log4j.Logger
int
Returns a very rough approximation of memory requirement.double
The score of how "important" this bucket is, so that it can be ranked against other buckets.long
boolean
hits
(long time) boolean
boolean
boolean
isValid()
Indicates that the bucket is still valid and hasn't been ejected.protected Dataset
loadData
(TagHistoryQueryProvider backingProvider) Loads the data fromstatic void
toString()
protected void
protected void
This function looks at the data that was loaded and adjusts the blocks validity and coverage size.
-
Constructor Details
-
StandardCacheBucket
Creates a new bucket that represents the time, and the parameters inherited from SubCache.
-
-
Method Details
-
getLogger
protected org.apache.log4j.Logger getLogger() -
isDataNull
public boolean isDataNull() -
getHitStatistics
-
isValid
public boolean isValid()Description copied from interface:CacheBucket
Indicates that the bucket is still valid and hasn't been ejected. Ejected buckets can still return good data, but they shouldn't be used much and should be removed when possible.- Specified by:
isValid
in interfaceCacheBucket
-
getRelevencyScore
public double getRelevencyScore()Description copied from interface:CacheBucket
The score of how "important" this bucket is, so that it can be ranked against other buckets.- Specified by:
getRelevencyScore
in interfaceCacheBucket
-
calculateRelevency
public void calculateRelevency()This where we look at our statistics and calculate how important this bucket is.
The parameters we have to work with:
- Fetch time - how long the data took to load. Each time, we calculate a deviation from a moving average, so its weight is relative to the overall performance of the system.
- Hit Count - how many times the bucket has been hit. Important to show more frequently used buckets
- Hit rating - how closely the hits are following a pattern.
- Last hit time - how long ago we got a hit.
- Data size - how much space the bucket is taking.
So basically, we want to assign points based on various properties, and then give a bonus- positive or negative, for the hit pattern.
- Specified by:
calculateRelevency
in interfaceCacheBucket
-
updateHitCount
protected void updateHitCount() -
getMemorySize
public int getMemorySize()Returns a very rough approximation of memory requirement.- Specified by:
getMemorySize
in interfaceCacheBucket
-
getData
Description copied from interface:CacheBucket
Returns the cached data, or goes to the store and retrieves it.- Specified by:
getData
in interfaceCacheBucket
- Throws:
Exception
-
loadData
Loads the data from- Throws:
Exception
-
validateData
protected void validateData()This function looks at the data that was loaded and adjusts the blocks validity and coverage size.This is necessary because we don't want to cache data that might change on the backend. That kind of thing can happen when the query range extends into the future, or when data is backfilled from the store and forward system.
This seems like a tricky thing to get right, and something that could impact performance a lot. We need a fast way to detect what data should be discarded. This current implementation does a binary search to find the last row of data with all "good" quality.
-
getStartTime
public long getStartTime()- Specified by:
getStartTime
in interfaceCacheBucket
-
getEndTime
public long getEndTime()- Specified by:
getEndTime
in interfaceCacheBucket
-
hits
public boolean hits(long time) -
isProvisional
public boolean isProvisional() -
eject
public boolean eject()Tells the bucket that the cache would like to eject it. If the bucket cannot be ejected, because it's in use, it can return false. If it can be ejected, the bucket will release its data and will notify its subcache.- Specified by:
eject
in interfaceCacheBucket
-
toString
-
resetStats
public static void resetStats()
-