|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.AllExhibitProperties
public final class AllExhibitProperties
Set of all exhibit names and properties. This includes AllExhibitImmutableData and all other loadable and calculatable exhibit properties, including emergent statistical properties computed across the entire exhibit set.
This maintains a hash over all the loaded/static properties and the exhibit set so that changes should be easily caught. Computed state is excluded since it can be computed on demand, adds no extra information and/or includes contingent information and noise such as hints from system settings.
Designed to be efficient `on-the-wire' and in memory.
This object is logically immutable except that:
In particular, EPCM values will be (re)computed dynamically as needed.
This holds per-exhibit information such as timestamp, x/y dimensions, etc, and whole-collection data such as hot/cold lists, location maps, etc.
The hashCode() and equals() methods are implemented, based on the underlying data.
| Nested Class Summary | |
|---|---|
static interface |
AllExhibitProperties.AEPFilter
Filter class for exhibits in AEP. |
static class |
AllExhibitProperties.ExhibitDataSource
Class that provides data source to get at exhibit data semi-random access or as a sequential stream. |
| Field Summary | |
|---|---|
private java.lang.Object |
_exhibitsByAttribute_lock
Private lock for manipulating exhibitsByAttribute; must use construction to create correctly. |
private java.lang.Object |
_mainWords_lock
Private lock for manipulating mainWords; must use constructor to get set up correctly. |
private ExhibitPropsComputableMutableVoteCacheIF |
_vcCache
Private vote/correlation cache; never null after construction/deserialisation. |
AllExhibitImmutableData |
aeid
The immutable exhibit data; never null. |
private java.util.Map<java.lang.String,java.lang.Integer> |
authorExhibitCounts
Map from author initials (String) to exhibit count for that author (Integer). |
private java.util.Map<java.lang.String,java.lang.Integer> |
categoryExhibitCounts
Map from category [top-level directory] (String) to exhibit count for that category (Integer). |
private static boolean |
COMPUTE_FULL_EPCM_RESULT_SPECULATIVELY_IN_BG
If true, then we may speculatively spin off threads to compute full EPCM values even when stale ones OK. |
private java.util.Map<java.lang.String,ExhibitPropsComputable> |
computedProps
Map from exhibit name (String) to ExhibitPropsComputable properties; never null. |
private long |
constructedAt
The time that this object was constructed. |
private java.util.Map<java.lang.String,java.lang.Integer> |
dottedExtensionExhibitCounts
Map from dotted-file-extension (String) to exhibit count for that extension (Integer). |
private java.util.concurrent.ConcurrentMap<java.lang.String,ExhibitPropsComputableMutable> |
epcmMap
Private cache; Map from full exhibit name to ExhibitPropsComputableMutable. |
ExhibitPropsGlobalImmutable |
epgi
The immutable global exhibit properties; never null. |
private long |
exhibitBytes
Total size in bytes of all exhibits. |
private java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
exhibitsByAttribute
A Map from attribute (String word) to a Set of full names of all exhibits with each attribute. |
static float |
GOODBAD_LIMIT
Limit of goodness*correlation to consider something (eg category) significantly good or bad. |
private java.util.Set<java.lang.String> |
hashMD5Err
Immutable Set of all exhibits with duplicate or missing MD5 hashes; null until computed on first use. |
private java.util.Map<ROByteArray,java.lang.String> |
hashMD5ToName
Immutable map from MD5 hash to exhibit full name; null until computed on first use. |
long |
hashNotChangedSince
Time since which we claim that the exhibit set/data has not changed; guaranteed non-negative. |
private java.util.Map<java.lang.String,ExhibitPropsLoadable> |
loadedProps
Logically immutable map from exhibit name (String) to loadable props (ExhibitPropsLoadable); never null. |
long |
longHash
The hash of all the data held; guaranteed non-negative. |
private java.util.Set<java.lang.String> |
mainWords
Case-sensitive immutable cache (transient, possibly memory-sensitive) of Set of all exhibit main words. |
private static java.lang.Integer |
ONE
Frequently-used value instance Integer(1). |
private static long |
serialVersionUID
Our serial version... |
| Constructor Summary | |
|---|---|
AllExhibitProperties()
Construct a default (empty) AllExhibitProperties object with zero timestamp. |
|
AllExhibitProperties(AllExhibitProperties old,
ExhibitPropsGlobalImmutable _epgi,
AllExhibitImmutableData _aeid,
java.util.Map<java.lang.String,ExhibitPropsLoadable> _loadedProps,
java.util.Map<java.lang.String,ExhibitPropsComputable> _computedProps,
long unchangedSince)
Build a new AllExhibitProperties object, preserving any computed state possible from the old one. |
|
AllExhibitProperties(ExhibitPropsGlobalImmutable _epgi,
AllExhibitImmutableData _aeid,
java.util.Map<java.lang.String,ExhibitPropsLoadable> _loadedProps,
java.util.Map<java.lang.String,ExhibitPropsComputable> _computedProps)
Construct a new AllExhibitProperties object from scratch, checking for consistency and validity. |
|
| Method Summary | |
|---|---|
private static java.util.concurrent.ConcurrentHashMap<java.lang.String,ExhibitPropsComputableMutable> |
_createNewEpcmMap(int capacity)
Create new epcmMap. |
static AllExhibitProperties |
canonicalise(AllExhibitProperties in)
Canonicalise AEP, ie reconstruct new instance from old data; null only if input is. |
void |
compact()
Compact the internal representation of this instance (and its sub-objects) if possible. |
boolean |
equals(java.lang.Object obj)
Indicates whether some other object is "equal to" this one; the underlying data is the same if true. |
java.util.Map<java.lang.String,java.lang.Integer> |
getAuthorExhibitCounts()
Get a map from author initials (String) to exhibit count for that author (Integer); never null. |
java.util.Map<java.lang.String,java.lang.Integer> |
getCategoryExhibitCounts()
Get a map from category [top-level directory] (String) to exhibit count for that category (Integer); never null. |
java.util.Map<java.lang.String,java.lang.Integer> |
getDottedExtensionExhibitCounts()
Get a map from dotted-file-extension (String) to exhibit count for that author (Integer); never null. |
ExhibitPropsComputable |
getExhibitPropsComputable(java.lang.String exhibitName)
Get computable (immutable) props for exhibit; if none available then returns null. |
java.util.Map<java.lang.String,ExhibitPropsComputable> |
getExhibitPropsComputableMap()
Get immutable map from full exhibit name to ExhibitPropsComputable; never null. |
ExhibitPropsComputableMutable |
getExhibitPropsComputableMutable(java.lang.String exhibitName)
Get ExhibitPropsComputableMutable for specified exhibit; null if no such exhibit or no result yet computed. |
ExhibitPropsComputableMutable |
getExhibitPropsComputableMutable(java.lang.String exhibitName,
boolean allowStale,
GenProps gp,
SimpleExhibitPipelineIF dataSource,
ScorerCacheIF scorers)
Get ExhibitPropsComputableMutable for specified exhibit; null if no such exhibit else never null. |
ExhibitPropsComputableMutable |
getExhibitPropsComputableMutable(java.lang.String exhibitName,
boolean allowStale,
GenProps gp,
SimpleExhibitPipelineIF dataSource,
ScorerCacheIF scorers,
long maxTimeMs)
Get ExhibitPropsComputableMutable for specified exhibit within given time; null if no such exhibit or out of time. |
ExhibitPropsLoadable |
getExhibitPropsLoadable(java.lang.String exhibitName)
Get loadable props for exhibit; never null. |
java.util.Map<java.lang.String,ExhibitPropsLoadable> |
getExhibitPropsLoadableMap()
Get immutable map from full exhibit name to ExhibitPropsLoadable; never null. |
java.util.Map<java.lang.String,java.util.Set<java.lang.String>> |
getExhibitsByAttribute()
Returns a Map from attribute (String word) to a Set of full names of all exhibits with each attribute; never null. |
java.util.Set<java.lang.String> |
getHashMD5Err()
Get immutable Set of all exhibits with duplicate or missing MD5 hashes; never null. |
java.util.Map<ROByteArray,java.lang.String> |
getHashMD5ToName()
Get immutable map from MD5 hash to valid exhibit full name; never null. |
static java.lang.String[] |
getLegalSuffixes()
Returns set of available extensions, sorted case insensitively. |
Location.Base |
getLocation(java.lang.String exhibitName)
Get exhibit Location information, specific or generic, if any; Location.NONE if none, never null. |
java.util.Set<java.lang.String> |
getMainWords()
Get case-sensitive Set of all main words (String values) in extant exhibits; never null. |
long |
getTotalExhibitBytes()
Get total size in bytes of all exhibits. |
int |
hashCode()
Returns a hash code value for the object; derived from the longHash. |
java.lang.Boolean |
isCategoryGood(java.lang.String categoryDir,
BasicVarMgrInterface vars,
boolean force)
Find out if a category is rated "good"/popular or not. |
protected java.lang.Object |
readResolve()
Deserialise: use constructor for validation, defensive copying, renormalisation, etc. |
void |
recoverOldExhibitPropsComputableMutableData(AllExhibitProperties oldAEP,
SimpleLoggerIF logger)
Recover EPCM (and possibly other details) from old AEP. |
java.lang.String[] |
select(AllExhibitProperties.AEPFilter f,
java.lang.String[] initialNames,
int stopAfter)
Filter results optionally starting with an input set of exhibit names; never null. |
java.lang.String |
toString()
Generate human-readable summary of this instance's internal state. |
void |
updateVoteCache(SimpleVariablePipelineIF vars,
boolean noTimeLimit)
Bring up-to-date any vote/correlation data. |
void |
validateObject()
Validate fields/state. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final ExhibitPropsGlobalImmutable epgi
public final AllExhibitImmutableData aeid
private final java.util.Map<java.lang.String,ExhibitPropsLoadable> loadedProps
The keys here are canonicalised against aeid so that we don't have duplicate String values knocking about.
private final java.util.Map<java.lang.String,ExhibitPropsComputable> computedProps
An instance of ExhibitPropsComputable is created on first demand and posted to the map. No lock is held while the computation is done, so redundant computations are possible, but a high degree of concurrency is available in return.
Entries are never removed from this map, and null is never posted as a value.
Defensively copied during deserialisation.
public final long longHash
Is guaranteed to be zero if the exhibit set is empty, and strictly positive otherwise.
Computable data (and hashNotChangedSince) is excluded from the hash since it is derived from other data that is included in the hash.
private final long constructedAt
We keep this private.
public final long hashNotChangedSince
If a new AllExhibitProperties object is constructed from scratch each time then this will be the time that the object was constructed, and so we can regard this as a an `exhibits have not changed since' time.
Strictly positive unless there are no exhibits, in which case this is zero (to prompt early recomputation!).
private static final java.lang.Integer ONE
private transient volatile java.util.Map<java.lang.String,java.lang.Integer> authorExhibitCounts
This map is immutable, and is computed on first use.
This map is transient (ie not stored in the persistent state).
private transient volatile java.util.Map<java.lang.String,java.lang.Integer> categoryExhibitCounts
This map is immutable, and is computed on first use.
This map is transient (ie not stored in the persistent state), and volatile for thread-safe lockless access.
public static final float GOODBAD_LIMIT
private transient volatile java.util.Map<java.lang.String,java.lang.Integer> dottedExtensionExhibitCounts
This map is immutable, and is computed on first use.
This map is transient (ie not stored in the persistent state), and volatile for thread-safe lockless access.
private transient volatile long exhibitBytes
This is transient since it can be recalculated on demand.
This is volatile to allow safe lock-free access.
private transient java.util.Map<java.lang.String,java.util.Set<java.lang.String>> exhibitsByAttribute
This is immutable, and is transient and recomputed on first use, being entirely derived from other information in object.
We hold a private lock while recomputing this information to allow other processing to continue in parallel with this possibly slow task.
private final transient java.lang.Object _exhibitsByAttribute_lock
private transient java.util.Set<java.lang.String> mainWords
Accessed under the _mainWords_lock.
Used, for example, by the upload routines to warn of possibly-misspelt words.
private final transient java.lang.Object _mainWords_lock
private final transient java.util.concurrent.ConcurrentMap<java.lang.String,ExhibitPropsComputableMutable> epcmMap
A thread-safe Map implementation is used; one that allows decent concurrency, especially without locking.
private static final boolean COMPUTE_FULL_EPCM_RESULT_SPECULATIVELY_IN_BG
private final transient ExhibitPropsComputableMutableVoteCacheIF _vcCache
This is thread-safe.
private transient volatile java.util.Map<ROByteArray,java.lang.String> hashMD5ToName
Transient; (re)computed on demand after deserialisation.
private transient volatile java.util.Set<java.lang.String> hashMD5Err
Volatile for lock-free thread-safe access.
Transient; (re)computed on demand after deserialisation.
private static final long serialVersionUID
| Constructor Detail |
|---|
public AllExhibitProperties()
The hash of this object is 0, as is the timestamp.
public AllExhibitProperties(ExhibitPropsGlobalImmutable _epgi,
AllExhibitImmutableData _aeid,
java.util.Map<java.lang.String,ExhibitPropsLoadable> _loadedProps,
java.util.Map<java.lang.String,ExhibitPropsComputable> _computedProps)
public AllExhibitProperties(AllExhibitProperties old,
ExhibitPropsGlobalImmutable _epgi,
AllExhibitImmutableData _aeid,
java.util.Map<java.lang.String,ExhibitPropsLoadable> _loadedProps,
java.util.Map<java.lang.String,ExhibitPropsComputable> _computedProps,
long unchangedSince)
If old is null, the object is built from scratch.
_aeid - immutable core exhibit data_loadedProps - map from exhibit name (String) to loaded properties
(ExhibitPropsLoadable);
not all exhibits need have a mapping
(in which case they are assumed no have no properties)unchangedSince - if non-zero, the hashNotChangedSince value is set from this| Method Detail |
|---|
public static AllExhibitProperties canonicalise(AllExhibitProperties in)
public ExhibitPropsLoadable getExhibitPropsLoadable(java.lang.String exhibitName)
public java.util.Map<java.lang.String,ExhibitPropsLoadable> getExhibitPropsLoadableMap()
public ExhibitPropsComputable getExhibitPropsComputable(java.lang.String exhibitName)
public java.util.Map<java.lang.String,ExhibitPropsComputable> getExhibitPropsComputableMap()
public final java.util.Map<java.lang.String,java.lang.Integer> getAuthorExhibitCounts()
This map is transient (ie not stored in the persistent state), and volatile for thread-safe lockless access.
public final java.util.Map<java.lang.String,java.lang.Integer> getCategoryExhibitCounts()
This map is immutable, and is computed on first use.
public java.lang.Boolean isCategoryGood(java.lang.String categoryDir,
BasicVarMgrInterface vars,
boolean force)
throws java.io.IOException
categoryDir - the initial directory component of an extant exhibitforce - if true may force (expensive) computation to give
a more accurate answer,
else may return a more approximate or stale answer,
or none at all (null)
java.io.IOExceptionpublic final java.util.Map<java.lang.String,java.lang.Integer> getDottedExtensionExhibitCounts()
This map is immutable, and is computed on first use.
public static java.lang.String[] getLegalSuffixes()
These are suffixes starting with `.' eg ``.jpg''.
Never returns null.
public long getTotalExhibitBytes()
public java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getExhibitsByAttribute()
The returned value is immutable (and the keys and values are immutable) and is never null.
Attributes which no exhibits have are present in the Map with an empty Set as the mapped-to value.
public java.util.Set<java.lang.String> getMainWords()
Computed on first use under a private lock as this may be slow and we do not want to waste CPU time on redundant computations.
public void recoverOldExhibitPropsComputableMutableData(AllExhibitProperties oldAEP,
SimpleLoggerIF logger)
Will only use details from old AEP:
This should not be called once threads other than the caller have access to this AEP since after performing our initial checks there is a danger of races that might leave old data in place.
This does not compute any new entries.
public ExhibitPropsComputableMutable getExhibitPropsComputableMutable(java.lang.String exhibitName)
exhibitName - full name of exhibit for which data is desired; never null
public ExhibitPropsComputableMutable getExhibitPropsComputableMutable(java.lang.String exhibitName,
boolean allowStale,
GenProps gp,
SimpleExhibitPipelineIF dataSource,
ScorerCacheIF scorers,
long maxTimeMs)
Equally, if the "allowStale" flag is true, there may be a non-stale value cached that can be returned.
So the "allowStale" parameter should be regarded as a strong hint at most.
This will spend up to the specified amount of time attempting to (re)compute the value if needed, else will return what (if anything) is already available. If there is a shortage of resources (eg threads) then this may not succeed in (re)calculation.
exhibitName - full name of exhibit for which data is desired; never nullallowStale - allows "approximate" or "stale" version to be returned
if need be, ie does not force re-computation of new value,
useful if site is busy or time is shortgp - system properties;
never null and not default/empty for non-stale resultdataSource - source of event and exhibit (meta) data;
must not be null if a non-stale result is desiredscorers - source of exhibit-content based scoring;
must not be null if a non-stale result is desiredmaxTimeMs - maximum time (ms) to spend computing result;
strictly positive
public ExhibitPropsComputableMutable getExhibitPropsComputableMutable(java.lang.String exhibitName,
boolean allowStale,
GenProps gp,
SimpleExhibitPipelineIF dataSource,
ScorerCacheIF scorers)
Equally, if the "allowStale" flag is true, there may be a non-stale value cached that can be returned.
So the "allowStale" parameter should be regarded as a strong hint at most.
exhibitName - full name of exhibit for which data is desired; never nullallowStale - allows "approximate" or "stale" version to be returned
if need be, ie does not force re-computation of new value,
useful if site is busy or time is shortgp - system properties;
never null and not default/empty for non-stale resultdataSource - source of event and exhibit (meta) data;
must not be null if a non-stale result is desiredscorers - source of exhibit-content based scoring;
must not be null if a non-stale result is desired
public void updateVoteCache(SimpleVariablePipelineIF vars,
boolean noTimeLimit)
throws java.io.IOException
vars - non-null handle on system variablesnoTimeLimit - if true, this will try to complete the work in one go
java.io.IOExceptionprivate static java.util.concurrent.ConcurrentHashMap<java.lang.String,ExhibitPropsComputableMutable> _createNewEpcmMap(int capacity)
We use a concurrency-friendly, lock-free Map for lookup and update speed. We don't expect lots of concurrent writes, so a few segments (fewer than say 10) should be OK.
public Location.Base getLocation(java.lang.String exhibitName)
exhibitName - the full name of the exhibit; must not be null
public java.util.Map<ROByteArray,java.lang.String> getHashMD5ToName()
Sets internal hashMD5ToName and hashMD5Err on first use as a side-effect.
public java.util.Set<java.lang.String> getHashMD5Err()
public java.lang.String[] select(AllExhibitProperties.AEPFilter f,
java.lang.String[] initialNames,
int stopAfter)
This search may be parallelised.
Note that is its up to the filters to decide whether to call getExhibitPropsComputable() to guarantee correct answers or getExhibitPropsComputableIfPresent() to guarantee fast answers.
If the stopAfter parameter is greater than zero, then this routine will stop as soon as possible after stopAfter results, and will then truncate to exactly stopAfter results.
The results array is sorted in a `smart'ish way.
The filter argument must not be null.
f - filter to apply; never nullinitialNames - initial set of names in non-null, else all namesstopAfter - +ve number of results to stop after, or zero for no limit
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.ObjectObject.equals(Object),
Hashtablepublic boolean equals(java.lang.Object obj)
Loaded data is included in this notion of equality; computed/derived data is excluded. The construction time and "unchanged since" values are also excluded.
This routine is likely to be very slow, especially to return a "true" result, ie fully verify that two instances are identical in all significant aspects.
equals in class java.lang.Objectobj - the reference object with which to compare.
true if this object is the same as the obj
argument; false otherwise.Boolean.hashCode(),
Hashtablepublic void compact()
This may be able to convert some state to a more memory-efficient representation after construction or deserialisation, and is suitable to call in a background thread.
We don't prevent multiple concurrent calls to this routine, since they are at worst wasteful of CPU but not unsafe.
compact in interface MemoryTools.Compactableprotected java.lang.Object readResolve()
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 | ||||||||