|
|||||||||
| 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 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.
| Field Summary | |
|---|---|
private java.util.List<java.lang.String> |
_cache_getAllExhibitNamesList
Cache for getAllExhibitNamesList() immutable content. |
private java.lang.String[] |
_cache_getAllExhibitNamesSorted
Cache for getAllExhibitNamesSorted(). |
int |
length
Exhibit count, with lock-free access; non-negative. |
private java.util.Map<java.lang.String,ExhibitStaticAttr> |
m
Map from name to static attr; never null once construction/deserialisation is complete. |
private static long |
serialVersionUID
Our serial version... |
private java.lang.String[] |
shortNameDups
List of duplicates found by _buildShortToFull; never null. |
private java.util.Map<java.lang.String,java.lang.String> |
shortToFull
Immutable Map from final file component (ie short name) to full name; never null. |
long |
timestamp
Timestamp of last exhibit update when this snapshot was taken. |
| Constructor Summary | |
|---|---|
AllExhibitImmutableData()
Construct an empty, zero-timestamp snapshot. |
|
AllExhibitImmutableData(java.util.Map<java.lang.String,ExhibitStaticAttr> nameToStaticAttr,
long lastExhibitChangeTimestamp)
Construct a new snapshot. |
|
| Method Summary | |
|---|---|
private void |
_buildShortToFull()
Builds shortToFull (and shortNameDups) from m if required. |
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 underlying set of exhibits and attributes is the same. |
java.util.List<java.lang.String> |
getAllExhibitNamesList()
Gets an immutable RandomAccess list of all raw exhibit names which is probably not sorted; never null. |
java.util.Set<java.lang.String> |
getAllExhibitNamesSet()
Gets a Set of all (String) raw (full) exhibit names. |
java.lang.String[] |
getAllExhibitNamesSorted()
Gets an array of all raw exhibit names; sorted by raw name. |
java.util.Set<java.lang.String> |
getAllExhibitShortNamesSet()
Gets a Set of all short exhibit names. |
java.util.Set<ExhibitStaticAttr> |
getAllStaticAttrs()
Gets Set of all static attrs unsorted. |
java.util.SortedSet<ExhibitStaticAttr> |
getAllStaticAttrsSorted()
Gets SortedSet of all static attrs; sorted by raw name. |
java.lang.String |
getFullName(java.lang.String shortName)
Gets the full name of an exhibit from its (unique) file component; null if no exhibit has the specified short name. |
java.lang.String[] |
getFullNamesWithDuplicateShortNames()
Gets (sorted) list of full names that have duplicate short names; zero-length if none. |
java.lang.String |
getPooledExhibitName(java.lang.String name)
Canonicalise exhibit name String. |
java.util.Map<java.lang.String,java.lang.String> |
getShortToFullMap()
Gets the immutable Map from short to full name; null if no exhibit has the short name. |
ExhibitStaticAttr |
getStaticAttr(java.lang.String name)
Get exhibit attributes; if result non-null the exhibit is valid. |
int |
hashCode()
Returns a hash code value for the object derived from the timestamp. |
boolean |
isEmpty()
True if zero/no exhibits. |
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 compressable) form of our internal information. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public final long timestamp
This information is accessable 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 accessable without holding any locks.
private transient java.util.Map<java.lang.String,ExhibitStaticAttr> m
Custom serialisation means that this map has to be mutable, so cannot be given out to a caller as-is.
private transient java.util.Map<java.lang.String,java.lang.String> shortToFull
private transient java.lang.String[] shortNameDups
private transient volatile java.util.List<java.lang.String> _cache_getAllExhibitNamesList
Marked volatile for lock-free thread-safe access.
Marked transient as this is recomputable redundant state.
private transient volatile java.lang.String[] _cache_getAllExhibitNamesSorted
Marked volatile for lock-free thread-safe access.
Marked transient as this is recomputable redundant state.
private static final long serialVersionUID
| Constructor Detail |
|---|
public AllExhibitImmutableData()
public AllExhibitImmutableData(java.util.Map<java.lang.String,ExhibitStaticAttr> nameToStaticAttr,
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 Map are
found to be malformed.| Method Detail |
|---|
private void _buildShortToFull()
public java.lang.String[] getFullNamesWithDuplicateShortNames()
public java.util.Set<java.lang.String> getAllExhibitShortNamesSet()
public java.lang.String getFullName(java.lang.String shortName)
shortName - must not be null
public java.util.Map<java.lang.String,java.lang.String> getShortToFullMap()
public ExhibitStaticAttr getStaticAttr(java.lang.String name)
public int size()
public boolean isEmpty()
public java.util.Set<java.lang.String> getAllExhibitNamesSet()
Should be relatively efficient.
public java.util.List<java.lang.String> getAllExhibitNamesList()
public java.lang.String[] getAllExhibitNamesSorted()
This returns a private array.
public java.util.Set<ExhibitStaticAttr> getAllStaticAttrs()
public java.util.SortedSet<ExhibitStaticAttr> getAllStaticAttrsSorted()
public java.lang.String getPooledExhibitName(java.lang.String name)
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.ClassNotFoundException
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 | ||||||||