|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.svrCore.AllExhibitImmutableData
public final class AllExhibitImmutableData
Immutable set of names and ExhibitStaticAttr for all exhibits. This provides a set of all exhibits, mapped from the full name to the static/immutable attributes for an exhibit (ie the parts that will not change unless the exhibit itself is changed).
Also provides a mapping from the final file component (short name) of an exhibit to its full name within the collection. All exhibits should be unique in this last component; if not then only the alphabetically first full-name value will be kept.
Also contains the time of last change to exhibit set when this snapshot was taken; this is verified simply to be non-negative and may for example be some combination of timestamp and hash over the exhibit content to best catch changes in the exhibit-set composition or it may be a pure hash. If a combination then usually the most significant bits would be those of the newest exhibit and the least significant would be the hash. If the exhibit set changes then this value should change, however the timestamp may not monotonically increase as new exhibits are added (or existing ones are altered).
Designed to be efficient `on-the-wire'; for serialisation we send a count and the ExhibitStaticAttr objects in sorted order by name instead of the map, which should be much less bulky than our internal representation (which is designed for lookup speed), and contains all the required information. On deserialising we simply reconstruct the map. We still let default serialisation deal with any other fields (the timestamp).
(It looks like HashMap's serialisation must be quite good since the saving in uncompressed size is only about 6%.)
The hashCode() is based on a hash of the timestamp, and equality is based on the sets of exhibits and global and per-exhibit attributes being equal.
TODO: lazily compute dups and short-to-full lookup, etc, when conserving resources.
| Field Summary | |
|---|---|
private java.util.List<Name.ExhibitFull> |
_cacheSR_getAllExhibitNamesListSorted
Cache for getAllExhibitNamesList() immutable content. |
private static boolean |
ATTEMPT_TO_RECOMPRESS_NAMES
If true, attempt to rebuild ESA names for better performance and/or reduced memory footprint. |
int |
length
Exhibit count, with lock-free access; non-negative. |
private ExhibitStaticAttr[] |
orderedEsa
In-order set of static-attribute instances; never null nor changed after construction/deserialisation. |
private java.util.SortedMap<java.lang.CharSequence,Name.ExhibitFull> |
pKeysToFull
Sorted immutable Map of short-name persistable keys to full names; never null. |
private static long |
serialVersionUID
Our serial version... |
private Name.ExhibitFull[] |
shortNameDups
Sorted logically-immutable array of full names with duplicate short names found by _buildShortToFull; never null. |
static java.util.Comparator<java.lang.CharSequence> |
SORT_ORDER
Sort order used for (full and short) exhibit names and static attrs containing them; non-null. |
long |
timestamp
Timestamp of last exhibit update when this snapshot was taken. |
private Name.ExhibitShort[] |
uniqueShortNames
Sorted logically-immutable set of unique short names; never null. |
| Constructor Summary | |
|---|---|
AllExhibitImmutableData()
Construct an empty, zero-timestamp snapshot. |
|
AllExhibitImmutableData(java.util.Set<ExhibitStaticAttr> staticAttrs,
long lastExhibitChangeTimestamp)
Construct a new snapshot. |
|
| Method Summary | |
|---|---|
private void |
_buildShortToFull()
Builds shortToFull and shortNameDups from orderedEsa. |
private void |
_computePKeys()
Computes mapping from persistable keys back to full name. |
private static void |
_optimiseESANames(ExhibitStaticAttr[] orderedESAs)
Attempt to optimise the ESA names to improve sharing and/or performance. |
long |
computeFileSpaceBytes(java.lang.String author)
Conservatively estimates filespace bytes required to store all exhibits. |
boolean |
equals(java.lang.Object obj)
Returns true when the timestamp and underlying set of exhibit names is the same. |
java.util.List<Name.ExhibitFull> |
getAllExhibitNamesSorted()
Gets an immutable sorted RandomAccess list of all full exhibit names; never null. |
Name.ExhibitShort[] |
getAllExhibitShortNamesArraySorted()
Gets (sorted) array of all short exhibit names; never null nor containing nulls but may be zero-length. |
java.util.List<ExhibitStaticAttr> |
getAllStaticAttrs()
Gets immutable (sorted) List of all static attrs; never null. |
Name.ExhibitFull |
getFullName(java.lang.CharSequence shortName)
Gets the full name of an exhibit from its (unique) file component, ie short name or persistable key; null if no exhibit IN THIS AEID has the specified short name/key. |
Name.ExhibitFull |
getFullNameFromPersistableKey(java.lang.CharSequence cs)
Gets the full name of an exhibit from its short-name persistable key; null if none. |
Name.ExhibitFull[] |
getFullNamesWithDuplicateShortNames()
Gets (sorted) array of full names that have duplicate short names; never null nor containing nulls but may be zero-length. |
ExhibitStaticAttr |
getStaticAttr(java.lang.CharSequence fullName)
Look up exhibit attributes by full exhibit name; null if not a valid exhibit in this set. |
ExhibitStaticAttr |
getStaticAttr(Name.ExhibitFull fullName)
Look up exhibit attributes by full exhibit name; null if not a valid exhibit in this set. |
int |
hashCode()
Returns a hash code value for the object derived from the timestamp. |
boolean |
isEmpty()
True iff zero/no exhibits. |
boolean |
isPresent(java.lang.CharSequence fullName)
Returns true iff the supplied full exhibit name is valid and is present in this collection. |
boolean |
isPresent(Name.ExhibitFull fullName)
Returns true iff the supplied full exhibit name is valid and is present in this collection. |
boolean |
isPresent(Name.ExhibitShort shortName)
Returns true iff the supplied short exhibit name is valid and is present in this collection. |
private void |
optionalEagerWarmup()
Can be called from constructor or at end of deserialisation. |
private void |
readObject(java.io.ObjectInputStream ois)
Deserialise. |
int |
size()
Get exhibit count; 0 if no exhibits. |
void |
validateObject()
Validate fields/state. |
private void |
writeObject(java.io.ObjectOutputStream oos)
Write out a less-redundant (and more compressible) form of our internal information. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.util.Comparator<java.lang.CharSequence> SORT_ORDER
private transient ExhibitStaticAttr[] orderedEsa
public final long timestamp
This information is accessible without holding any locks.
public final int length
This emulates the length field of an array while size() emulates the behaviour of collections...
This information is accessible without holding any locks.
private transient Name.ExhibitFull[] shortNameDups
private transient Name.ExhibitShort[] uniqueShortNames
Can be used to do look-up with other CharSequence implementations such as String.
private transient volatile java.util.SortedMap<java.lang.CharSequence,Name.ExhibitFull> pKeysToFull
Can be used to do look-up with other CharSequence implementations such as String, ie the Comparator works with generic CharSequence values.
Volatile for lock-free read access.
Write access is under the instance lock and this map is created on first use.
private transient volatile java.util.List<Name.ExhibitFull> _cacheSR_getAllExhibitNamesListSorted
Marked volatile for lock-free thread-safe access.
Marked transient as this is recomputable redundant state.
Not cleared once set so that the reference (and its identity hash) will be stable, suitable for use by AbstractFilterBean._select() for example.
private static final boolean ATTEMPT_TO_RECOMPRESS_NAMES
private static final long serialVersionUID
| Constructor Detail |
|---|
public AllExhibitImmutableData()
public AllExhibitImmutableData(java.util.Set<ExhibitStaticAttr> staticAttrs,
long lastExhibitChangeTimestamp)
throws java.lang.IllegalArgumentException
The timestamp must be zero if the map is empty, else it must be strictly positive.
java.lang.IllegalArgumentException - if the timestamp or input data
are found to be malformed.| Method Detail |
|---|
private void optionalEagerWarmup()
private void _buildShortToFull()
public Name.ExhibitFull[] getFullNamesWithDuplicateShortNames()
public Name.ExhibitShort[] getAllExhibitShortNamesArraySorted()
public Name.ExhibitFull getFullNameFromPersistableKey(java.lang.CharSequence cs)
private void _computePKeys()
public Name.ExhibitFull getFullName(java.lang.CharSequence shortName)
shortName - file component or persistable key; must not be null
public boolean isPresent(Name.ExhibitShort shortName)
shortName - putative short name of an exhibit
public boolean isPresent(Name.ExhibitFull fullName)
fullName - putative full name of an exhibit
public boolean isPresent(java.lang.CharSequence fullName)
fullName - putative full name of an exhibit
public ExhibitStaticAttr getStaticAttr(Name.ExhibitFull fullName)
May be slow if the argument is not a Name.ExhibitFillName, but especially in this case note that what is returned is the canonical internal ExhibitFull.
If the argument is null or invalid then this returns null rather than throwing an exception.
public ExhibitStaticAttr getStaticAttr(java.lang.CharSequence fullName)
May be slow if the argument is not a Name.ExhibitFillName, but especially in this case note that what is returned is the canonical internal ExhibitFull.
If the argument is null or invalid then this returns null rather than throwing an exception.
public int size()
public boolean isEmpty()
public java.util.List<Name.ExhibitFull> getAllExhibitNamesSorted()
public java.util.List<ExhibitStaticAttr> getAllStaticAttrs()
public final long computeFileSpaceBytes(java.lang.String author)
This is for the specific named author, unless author is null in which case it for all authors.
This separately rounds up each exhibit size and name size to an assume filesystem block size as per FileTools.roundUpToFSBlockSize().
java.lang.IllegalArgumentException - if author is not null and is not a
syntactically-valid author name (initials)public int hashCode()
hashCode in class java.lang.ObjectObject.equals(Object),
Hashtablepublic boolean equals(java.lang.Object obj)
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(),
Hashtable
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
java.io.IOException
java.lang.ClassNotFoundExceptionprivate static void _optimiseESANames(ExhibitStaticAttr[] orderedESAs)
orderedESAs - sorted (in natural order, ie by name) ESAs; may be empty but never null.
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.60.69 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||