|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.ExhibitPropsComputableMutable
public final class ExhibitPropsComputableMutable
Immutable (and serialisable) store of all ephemeral computable auxiliary properties of a single exhibit. These are properties that are computed from exhibit and non-exhibit data and that need to be periodically recomputed, such as popularity score.
This is is called "mutable" because although any one instance is immutable, successive values retrieved for the same exhibit may be different.
This data has limited lifetime, but may be somewhat useful even when stale, so can be persisted if desired.
This is designed to be efficient and robust on the wire and in memory, since these details will be held for each and every exhibit.
| Nested Class Summary | |
|---|---|
static class |
ExhibitPropsComputableMutable.Factor
Single (immutable) component of multi-factor value. |
| Field Summary | |
|---|---|
private static int |
_MIN_VLONG_SAMPLE_PERIODS
Minimum number of VLONG samples to smooth out daily/weekly cycles in data. |
private static ExhibitPropsComputableMutable.Factor |
_NOT_NEW
Contribution for goodness of non-new exhibits; zero goodness but the same "newness" weight. |
private static long |
_SAMPLE_CYCLE_PERIOD_MAJOR_MS
The longest cycle time we will look for in historical data, in ms; strictly positive. |
private static long |
_SAMPLE_CYCLE_PERIOD_MINOR_MS
Minimum sample period to even out short cycles in Web access patterns, in ms; strictly positive. |
private static int |
_SEASONAL_VLONG_CYCLE_PERIODS
Number of VLONG samples corresponding to annual cycles in data. |
private static ExhibitPropsComputableMutable.Factor |
FACTOR_HASDESC
Weighting factor for an item with a specific description. |
private static ExhibitPropsComputableMutable.Factor |
FACTOR_HASGENERICDESC
Weighting factor for an item with a generic description. |
static ExhibitPropsComputableMutable.Factor |
FACTOR_ZERO
Zero factor; zero weight, zero goodness. |
private static boolean |
FORCE_CORR_RECOMP
If true then force correlation data up to date. |
static float |
GOODBAD_LIMIT
Limit of goodness*correlation to consider something (eg category) significantly good or bad. |
static int |
GOODBAD_LIMIT_INT
Limit of goodness*correlation to consider something (eg category) significantly good or bad, is int value. |
private int |
goodness
The "goodness" score, -MAX_VALUE is maximally bad and MAX_VALUE maximally good, zero is neutral. |
static int |
MAX_AGE_BEFORE_STALE_MS
Maximum age (in ms) of instances before considering them stale and recomputing them. |
static float |
POP_AI_SCORER
Maximum weighting from Scorer judgement of exhibit content. |
static float |
POP_CORR_HASDESC
Weighting/correlation of has-description component of popularity. |
static float |
POP_CORR_NEWNESS
Weighting/correlation of "newness" component of popularity. |
static float |
POP_CORR_RANDOM
Weighting/correlation of "random" component of popularity. |
static float |
POP_RECENT_ACCESS
Maximum weighting for exhibit recently viewed or downloaded. |
static float |
POP_VOTE_CORR
Maximum weighting from correlated voting on related exhibits. |
static float |
POP_VOTES
Maximum weighting for vox pop user votes. |
private static long |
serialVersionUID
Our serial version... |
private long |
staleAfter
Time until which this data is considered valid; beyond this time is stale. |
static ExhibitPropsComputableMutable |
TRIVIAL_NEUTRAL
Trivially-stale entirely-neutral instance; never null. |
private static boolean |
USE_ALL_BUCKET
If true then include the "all" buckets in our calculations. |
private static boolean |
USE_ALL_VOTES
If true, use ALL available votes rather than a sampling in _computeSampleBitSet(). |
| Constructor Summary | |
|---|---|
private |
ExhibitPropsComputableMutable(ExhibitStaticAttr esa,
GenProps gp,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
ExhibitPropsComputableMutableVoteCacheIF voteCache,
ScorerCacheIF scorers)
Create a fully populated ExhibitPropsComputableMutable object. |
private |
ExhibitPropsComputableMutable(long staleAfter,
int goodness)
Create an instance with the specified goodness and stale 'best before' time. |
| Method Summary | |
|---|---|
private static void |
_chooseRandomSlot(java.util.Random rnd,
java.util.BitSet whichIntervals,
boolean forceNew)
Set a random bit in the BitSet to take a random sample. |
private static ExhibitPropsComputableMutable.Factor |
_computeNewnessBonusFactor(ExhibitStaticAttr esa)
Compute newness bonus (if any); never null. |
private static ExhibitPropsComputableMutable.Factor |
_computeRandomGoodnessFactor()
Compute random "goodness" factor symmetrical about zero; never null. |
private static java.util.BitSet |
_computeSampleBitSet(long minNearMs)
Compute BitSet of samples of event history to take; never null nor empty. |
private static ExhibitPropsComputableMutable.Factor |
_computeTotalGoodnessFactor(ExhibitStaticAttr esa,
GenProps gp,
AllExhibitProperties aep,
java.util.List<ExhibitPropsComputableMutable.Factor> initialComponents)
Compute full goodness factor, using full data source if available; never null. |
long |
bestBefore()
Get the basic 'best-before' time. |
static java.util.Collection<ExhibitPropsComputableMutable.Factor> |
calcAccessFactors(java.lang.String exhibitName,
AllExhibitProperties aep,
BasicVarMgrInterface vars)
Compute Factor(s) that depend on access data. |
private static java.util.List<ExhibitPropsComputableMutable.Factor> |
calcCorrelationFactors(ExhibitStaticAttr esa,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
ExhibitPropsComputableMutableVoteCacheIF voteCache)
Compute factors based on correlations. |
static ExhibitPropsComputableMutable.Factor |
calcVoteFactor(java.lang.String exhibitName,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
long minNearMs)
Compute exactly one Factor that depends on explicit user votes for specified exhibit; never null. |
static ExhibitPropsComputableMutable |
compute(ExhibitStaticAttr esa,
GenProps gp,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
ExhibitPropsComputableMutableVoteCacheIF voteCache,
ScorerCacheIF scorers)
Compute (accurate) value for a specified exhibit; never null. |
static ExhibitPropsComputableMutable |
generateFastApproximation(ExhibitStaticAttr esa,
GenProps gp)
Compute a "quick"/approximate value for a specified exhibit; never null. |
int |
getGoodness()
Get the "goodness" score, -MAX_VALUE is maximally bad and MAX_VALUE maximally good, zero is neutral. |
float |
getGoodnessAsFloat()
Get the "goodness" score as a normalised float in the range -1 (bad) to +1 (good), 0 is neutral. |
java.lang.Boolean |
isGood()
Find out if this exhibit is rated "good"/popular or not. |
boolean |
isStale()
If true, the data in this object is stale. |
boolean |
isTriviallyStale()
If true, the data in this object is not only stale; it is only even a fast approximation. |
protected java.lang.Object |
readResolve()
Deserialise: use constructor for validation, defensive copying, etc. |
void |
validateObject()
Validate fields/state. |
protected java.lang.Object |
writeReplace()
Serialise: replace all trivially-stale values being serialised with TRIVIAL_NEUTRAL. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final float GOODBAD_LIMIT
public static final int GOODBAD_LIMIT_INT
public static final ExhibitPropsComputableMutable TRIVIAL_NEUTRAL
private static final boolean FORCE_CORR_RECOMP
private final long staleAfter
If the stale date is too far in the future for us to believe, ie much more than would be allowed with this version of the object, then we treat the data as stale in case it is from a version of this object with very different staleness limits or there was a persistence error.
public static final int MAX_AGE_BEFORE_STALE_MS
Each instance of this object should pick a random time between about half of this value and the full value before going stale in order to spread out refresh computations over a reasonable interval. Recomputing these values may prove quite expensive.
This value is selected so that most exhibits actual scores will not have changed significantly in the given interval; something of the order of tens of hours to tens of days is good.
private final int goodness
Has enough significant digits to allow a total ordering even over a very large number of exhibits.
This is nominally logically thought of in the range [-1.0, +1.0].
public static final float POP_VOTES
The vote element can count for or against an exhibit (ie be +ve or -ve), and an absence of any votes may tend to dilute goodness back towards neutral.
public static final float POP_VOTE_CORR
public static final float POP_AI_SCORER
We give this equal weighting with the metadata-driven statistical methods.
public static final float POP_RECENT_ACCESS
We make this a little less important than vote correlations.
public static final float POP_CORR_NEWNESS
This factor should be relatively small, not overwhelming manually-set weightings for example, and mainly intended as a tie-breaker.
public static final float POP_CORR_RANDOM
This factor falls equally either side of zero, is a +/- limit.
public static final float POP_CORR_HASDESC
Should generally be greater than the randomness weighting, and probably less than the newness rating.
private static final ExhibitPropsComputableMutable.Factor FACTOR_HASDESC
private static final ExhibitPropsComputableMutable.Factor FACTOR_HASGENERICDESC
May apply to having location or AKA or description text.
public static final ExhibitPropsComputableMutable.Factor FACTOR_ZERO
private static final ExhibitPropsComputableMutable.Factor _NOT_NEW
private static final long _SAMPLE_CYCLE_PERIOD_MINOR_MS
private static final long _SAMPLE_CYCLE_PERIOD_MAJOR_MS
private static final int _SEASONAL_VLONG_CYCLE_PERIODS
private static final int _MIN_VLONG_SAMPLE_PERIODS
private static final boolean USE_ALL_BUCKET
private static final boolean USE_ALL_VOTES
private static final long serialVersionUID
| Constructor Detail |
|---|
private ExhibitPropsComputableMutable(long staleAfter,
int goodness)
private ExhibitPropsComputableMutable(ExhibitStaticAttr esa,
GenProps gp,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
ExhibitPropsComputableMutableVoteCacheIF voteCache,
ScorerCacheIF scorers)
The data source references are not stored in the object.
esa - the exhibit to compute properties for; never nullgp - the system properties; never nullaep - the exhibit properties; can be nullvars - source of event data; can be nullscorers - source of content-based sceoring; can be nullvoteCache - vote cache; can be null| Method Detail |
|---|
public static ExhibitPropsComputableMutable generateFastApproximation(ExhibitStaticAttr esa,
GenProps gp)
The value is immediately marked as stale (unless it is possible to compute the exact value fast), but is useful to generate something quickly if the system is busy, or at start-up for example.
esa - the exhibit to compute properties for; never nullgp - the system properties; never null
public static ExhibitPropsComputableMutable compute(ExhibitStaticAttr esa,
GenProps gp,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
ExhibitPropsComputableMutableVoteCacheIF voteCache,
ScorerCacheIF scorers)
Providing the supplied data source is non-null and functional, and the GenProps does not appear to be empty (zero timestamp) then the value will not become stale for at least half of MAX_AGE_MS, and will become stale in no more than MAX_AGE_MS ms.
If the data source is not fully available/functional then an approximation will be returned instead, and marked stale to allow reclaculation later.
esa - the exhibit to compute properties for; never nullgp - the system properties; never nullaep - the exhibit properties; can be nullvars - source of event data; can be nullvoteCache - vote cache; can be null
private static java.util.List<ExhibitPropsComputableMutable.Factor> calcCorrelationFactors(ExhibitStaticAttr esa,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
ExhibitPropsComputableMutableVoteCacheIF voteCache)
throws java.io.IOException
java.io.IOExceptionpublic boolean isStale()
It is possible for a item previously non-stale that then became 'stale' to become non-stale again for a limited time while the system is conserving energy in low-power mode, thus avoing the need for some expensive recomputation. Trivially-stale instances, ie that were never fully computed, never become non-stale again.
public boolean isTriviallyStale()
public final long bestBefore()
This value is useful to help schedule recomputations most-stale-first.
For trivially-stale instances this is always zero.
public int getGoodness()
public float getGoodnessAsFloat()
public java.lang.Boolean isGood()
This is based on the computed "goodness" score.
private static ExhibitPropsComputableMutable.Factor _computeRandomGoodnessFactor()
private static ExhibitPropsComputableMutable.Factor _computeNewnessBonusFactor(ExhibitStaticAttr esa)
This is not necessarily precisely aligned with the "isExhibitNew()" result, though except in race conditions they should be aligned.
esa - exhibit data; never null
private static ExhibitPropsComputableMutable.Factor _computeTotalGoodnessFactor(ExhibitStaticAttr esa,
GenProps gp,
AllExhibitProperties aep,
java.util.List<ExhibitPropsComputableMutable.Factor> initialComponents)
esa - exhibit data; never nullinitialComponents - initial set of (data-dependent) Factor elements;
possibly empty but never null
public static java.util.Collection<ExhibitPropsComputableMutable.Factor> calcAccessFactors(java.lang.String exhibitName,
AllExhibitProperties aep,
BasicVarMgrInterface vars)
throws java.io.IOException
The comment fields of the factors produced are the event names from which they were generated.
This is public to assist testing.
java.io.IOException - if this was unable to fetch some data required
public static ExhibitPropsComputableMutable.Factor calcVoteFactor(java.lang.String exhibitName,
AllExhibitProperties aep,
BasicVarMgrInterface vars,
long minNearMs)
throws java.io.IOException
If this cannot fetch some of the data it requires due to an IOException (not the same as fetching data successfully that has no entries) then the exception is propagated to the caller. (Normally this results in the EPCM item for which this is called being marked stale so that we can try again when the data is available.)
This is public to assist testing and computation of correlations.
The returned factor's goodness can range from -1 to +1, and confidence from 0 to +1; any scaling required will have to be applied elsewhere.
minNearMs - minimum interval (ms) at near end
to include all available samples for
java.io.IOException - if this was unable to fetch some data requiredprivate static java.util.BitSet _computeSampleBitSet(long minNearMs)
This includes:
minNearMs - if positive, the minimum number of recent ms that
the sampling should cover (else an internal minimum will be imposed)
private static void _chooseRandomSlot(java.util.Random rnd,
java.util.BitSet whichIntervals,
boolean forceNew)
It is possible (though may be expensive) to insist that a new (previously false) bit is set, but only if (much) less than SystemVariables.EVENT_SAMPLES_RETAINED bits are already true.
rnd - random number source; never nullwhichIntervals - the BitSet to set a random bit in; never nullforceNew - if true, ensure that we set a new bit ie one that was false
unless at least half of all possible bits have already been setprotected java.lang.Object readResolve()
NOTE: this may not always preserve all values as expected in future.
protected java.lang.Object writeReplace()
NOTE: this is effectively a LOSSY compression mechanism.
public void validateObject()
throws java.io.InvalidObjectException
Barf if something bad is found. (Maybe allow some extra info in debug version.)
validateObject in interface java.io.ObjectInputValidationjava.io.InvalidObjectException
|
DHD Multimedia Gallery V1.50.55 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||