|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.vars.EventVariableValue
public final class EventVariableValue
Immutable value of a local or global system event variable. This contains the type/definition plus a total event count and a Map of event values.
To retrieve the very latest value that was set a SimpleVariableValue should be retrieved instead.
This is serialisable to enable it to be sent over network connections, persisted, etc.
Note that the interval number is strictly positive, the interval number multiplied by the period is the starting time of the interval in ms, and the starting time is always representable as a positive long.
May hold state in a compacted form internally to reduce memory footprint. In particular, String values may be held as more compact CharSequence forms, though are returned, matched and serialised as String.
| Nested Class Summary | |
|---|---|
static class |
EventVariableValue.ValueInfo
Immutable info collected about one particular value of an event. |
| Field Summary | |
|---|---|
private boolean |
authoratitive
If true, this variable has come from the authoritative end-point. |
(package private) static boolean |
AVOID_RECOMPRESSING
If true then avoid attempting to re-compact already nominally compact data. |
(package private) static boolean |
COMPRESS_INTERNAL_STATE
If true then try to compress the internal in-memory state to reduce footprint. |
private int[] |
counts
Counts of the different (non-null) values in non-increasing-count order (ie best first); never null. |
private SimpleVariableDefinition |
def
The variable definition; never null. |
private long |
intervalNumber
The interval number; strictly positive. |
(package private) static boolean |
LAZY_SORT
If true then defer (expensive) sorting where possible. |
private static int[] |
NO_COUNTS
Private shared (immutable) value meaning no counts, to save memory. |
private static java.lang.Object[] |
NO_VALUES
Private shared (immutable) value meaning no values, to save memory. |
private EventPeriod |
period
The event period; never null. |
private static long |
serialVersionUID
Unique Serialisation class ID. |
(package private) static java.util.Comparator<java.lang.CharSequence> |
SV_COMPARATOR
Case-sensitive comparator for nominally String-type values, even mixed compact and raw String items; not null. |
private int |
totalEventCount
Total event count; non-negative. |
private java.lang.Object[] |
values
Values of the different (non-null) events in non-increasing-count order (ie best first); never null. |
private short[] |
valuesSortedRank
Rank of each item in valuesSorted[]; CURRENTLY never null after construction. |
| Constructor Summary | |
|---|---|
EventVariableValue(boolean isAuthoritative,
SimpleVariableDefinition def,
EventPeriod period,
long intervalNumber,
int totalEventCount,
java.lang.Object[] values,
int[] counts)
Construct a single variable value. |
|
EventVariableValue(boolean isAuthoritative,
SimpleVariableDefinition def,
EventPeriod period,
long intervalNumber,
int totalEventCount,
java.lang.Object[] valuesIn,
int[] countsIn,
boolean tryIntern)
Construct a single variable value. |
|
| Method Summary | |
|---|---|
private void |
_compactAndSort(SimpleVariableDefinition def,
boolean tryIntern)
Creates _valuesSortedRank[] and compacts values[] as a side-effect if needed. |
(package private) static boolean |
allowCompactStringValues(SimpleVariableDefinition def)
If true then Name is a valid value type (in lieu of String). |
private void |
checkExternalLookupValueTypeAndNonNull(java.lang.Object value)
Checks that the supplied value is non-null and a legitimate value of the definition. |
private java.lang.Object |
convertValueToPrimaryForm(java.lang.Object o)
Convert value to primary form. |
private java.lang.Object |
convertValueToPrimaryFormNoIntern(java.lang.Object o)
Convert value to primary form, NOT intern()ing any generated String values as assumed short-lived. |
boolean |
equals(java.lang.Object obj)
Equality is based on the definition, period and interval number, but not the event values. |
int |
getCount(java.lang.Object value)
Get count of this event value; never negative. |
int |
getCountByRank(int rank)
Get count by rank; strictly positive. |
SimpleVariableDefinition |
getDef()
Get the variable definition; never null. |
java.util.List<java.lang.Object> |
getDistinctValuesInRankOrder()
Get an immutable RandomAccess List of the distinct values in rank order; never null but may be empty. |
java.util.List<java.lang.Object> |
getDistinctValuesSorted()
Get an immutable RandomAccess List of the distinct values in value-sorted order; never null but may be empty. |
private int |
getIndexInSortedValues(java.lang.Object key)
Return the index in a sorted version of values[] of the given value/key; -negative if not present. |
long |
getIntervalNumber()
Get the interval number; strictly positive. |
EventPeriod |
getPeriod()
Get the event period; never null. |
int |
getRank(java.lang.Object value)
Get rank/ranking of this event value; never negative. |
int |
getTotalDistinctValues()
Get total number of distinct event values recorded; non-negative. |
int |
getTotalEventCount()
Get the total event count; non-negative. |
java.lang.Object |
getValueByRank(int rank)
Get value by rank. |
java.lang.Object |
getValueByRankNoIntern(int rank)
Get value by rank and do not intern() any on-the-fly generated values as assumed to be short-lived. |
private short[] |
getValuesSortedRank()
Get rank of each values[] item in sorted order; never null. |
int |
hashCode()
The hash is built on a subset of the fields. |
boolean |
isAuthoritative()
Returns true if this variable has come from the authoritative end-point. |
EventVariableValue |
makeAuthoritative()
Return a (new) authoritative value with the same content as the current value; never null. |
private void |
readObject(java.io.ObjectInputStream ois)
Deserialise. |
protected java.lang.Object |
readResolve()
Deserialise: use constructor for validation, defensive copying, conversion from old formats, etc. |
(package private) static boolean |
shouldIntern(SimpleVariableDefinition def)
Returns true if we should probably automatically intern() the value. |
java.lang.String |
toString()
Generate human-readable summary of important state. |
void |
validateObject()
Check that the object state is consistent and legal. |
private void |
writeObject(java.io.ObjectOutputStream oos)
Customise how we save state when serialising. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
static final java.util.Comparator<java.lang.CharSequence> SV_COMPARATOR
private static final java.lang.Object[] NO_VALUES
private static final int[] NO_COUNTS
private SimpleVariableDefinition def
private EventPeriod period
private long intervalNumber
private boolean authoratitive
private int totalEventCount
private int[] counts
Same length as values[].
private java.lang.Object[] values
Same length as counts[].
The general case is that a value's rank is its position in this array.
private transient volatile short[] valuesSortedRank
Marked volatile for thread-safe lock-free access.
static final boolean LAZY_SORT
static final boolean COMPRESS_INTERNAL_STATE
This flag may also be used by EventVariableValueBuffer to optimise its internal state and interactions with this class; thus package-visible.
static final boolean AVOID_RECOMPRESSING
private static final long serialVersionUID
| Constructor Detail |
|---|
public EventVariableValue(boolean isAuthoritative,
SimpleVariableDefinition def,
EventPeriod period,
long intervalNumber,
int totalEventCount,
java.lang.Object[] values,
int[] counts)
throws java.lang.IllegalArgumentException
May attempt to compact and/or intern() key values to minimise memory consumption at the cost of some performance at construction/deserialisation/access.
isAuthoritative - if true, this is authoritative data
from the master data storedef - the variable definition; never null and must be an eventperiod - the event period for this sample; never nullintervalNumber - the period number; strictly positivetotalEventCount - the total event count; non-negativevalues - event values in decreasing order of count;
null == empty, not containing duplicates, same length as counts[] argumentcounts - event counts for each item in values[],
in non-increasing order, with a sum no more than total-event count;
null == empty, not containing negative values, same length as values[]
java.lang.IllegalArgumentException - if the arguments are invalid
EventVariableValue(boolean isAuthoritative,
SimpleVariableDefinition def,
EventPeriod period,
long intervalNumber,
int totalEventCount,
java.lang.Object[] valuesIn,
int[] countsIn,
boolean tryIntern)
May attempt to effectively intern() key values to minimise memory consumption at the cost of some performance at construction/deserialisation.
Package-visible so that only classes in this package (that we trust) can avoid having their values intern()ed.
isAuthoritative - if true, this is authoritative data
from the master data storedef - the variable definition; never null and must be an eventperiod - the event period for this sample; never nullintervalNumber - the period number; strictly positivetotalEventCount - the total event count; non-negativevaluesIn - event values in decreasing order of count;
null == empty, not containing duplicates, same length as counts[] argumentcountsIn - event counts for each item in values[],
in non-increasing order, with a sum no more than total-event count;
null == empty, not containing negative values, same length as values[]tryIntern - if false then we do not try hard to intern()/compress any of the values
java.lang.IllegalArgumentException - if the arguments are invalid| Method Detail |
|---|
private void _compactAndSort(SimpleVariableDefinition def,
boolean tryIntern)
static boolean allowCompactStringValues(SimpleVariableDefinition def)
static boolean shouldIntern(SimpleVariableDefinition def)
public EventVariableValue makeAuthoritative()
(If this instance is already authoritative, then "this" is returned to avoid wasting memory.)
public SimpleVariableDefinition getDef()
public EventPeriod getPeriod()
public long getIntervalNumber()
public boolean isAuthoritative()
public int getTotalEventCount()
private short[] getValuesSortedRank()
public java.lang.String toString()
toString in class java.lang.Objectprivate int getIndexInSortedValues(java.lang.Object key)
public int getTotalDistinctValues()
public java.util.List<java.lang.Object> getDistinctValuesInRankOrder()
public java.util.List<java.lang.Object> getDistinctValuesSorted()
public int getCount(java.lang.Object value)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - if the argument is null
or not a legal type/value
private void checkExternalLookupValueTypeAndNonNull(java.lang.Object value)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public int getRank(java.lang.Object value)
throws java.lang.IllegalArgumentException
If we have no count recorded for this value, ie no ranking, the routine returns Integer.MAX_VALUE.
java.lang.IllegalArgumentException - if the argument is null
or not a legal type/valueprivate java.lang.Object convertValueToPrimaryForm(java.lang.Object o)
private java.lang.Object convertValueToPrimaryFormNoIntern(java.lang.Object o)
public java.lang.Object getValueByRank(int rank)
rank - of value to select in range [0,getTotalDistinctValues()-1]
java.lang.ArrayIndexOutOfBoundsException - if the rank is out of boundspublic java.lang.Object getValueByRankNoIntern(int rank)
rank - of value to select in range [0,getTotalDistinctValues()-1]
java.lang.ArrayIndexOutOfBoundsException - if the rank is out of boundspublic int getCountByRank(int rank)
java.lang.ArrayIndexOutOfBoundsException - if the rank is out of boundspublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
private void writeObject(java.io.ObjectOutputStream oos)
throws java.io.IOException
java.io.IOException
private void readObject(java.io.ObjectInputStream ois)
throws java.io.IOException,
java.lang.ClassNotFoundException
This does not attempt to build some of the transient state assembled by the constructor, nor do defensive copying or significant validation.
java.io.IOException
java.lang.ClassNotFoundExceptionprotected java.lang.Object readResolve()
public void validateObject()
throws java.io.InvalidObjectException
validateObject in interface java.io.ObjectInputValidationjava.io.InvalidObjectException
|
DHD Multimedia Gallery V1.60.69 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||