private static final int HISTORY_FILE_MAGIC_NUMBER = 0x05FFA900;
- /**
+ /*
* File format version. Increment minor on backwards-compatible changes.
* Increment major + set minor back to 0 when breaking compatibility.
*/
private static final int MAJOR_VERSION = 3;
private static final byte MINOR_VERSION = 0;
- /**
- * Tree-specific configuration
- */
- /* Container for all the configuration constants */
+ // ------------------------------------------------------------------------
+ // Tree-specific configuration
+ // ------------------------------------------------------------------------
+
+ /** Container for all the configuration constants */
protected final HTConfig config;
- /* Reader/writer object */
+ /** Reader/writer object */
private final HT_IO treeIO;
- /**
- * Variable Fields (will change throughout the existance of the SHT)
- */
- /* Latest timestamp found in the tree (at any given moment) */
+ // ------------------------------------------------------------------------
+ // Variable Fields (will change throughout the existance of the SHT)
+ // ------------------------------------------------------------------------
+
+ /** Latest timestamp found in the tree (at any given moment) */
private long treeEnd;
- /* How many nodes exist in this tree, total */
+ /** How many nodes exist in this tree, total */
private int nodeCount;
- /* "Cache" to keep the active nodes in memory */
+ /** "Cache" to keep the active nodes in memory */
protected Vector<CoreNode> latestBranch;
+ // ------------------------------------------------------------------------
+ // Constructors/"Destructors"
+ // ------------------------------------------------------------------------
+
/**
* Create a new State History from scratch, using a SHTConfig object for
* configuration
- *
- * @param conf
- * @throws IOException
*/
private HistoryTree(HTConfig conf) throws IOException {
/*
- * Simple assertion to make sure we have enough place in the 0th block
+ * Simple check to make sure we have enough place in the 0th block
* for the tree configuration
*/
- assert (conf.blockSize >= getTreeHeaderSize());
+ if (conf.blockSize < getTreeHeaderSize()) {
+ throw new IllegalArgumentException();
+ }
config = conf;
treeEnd = conf.treeStart;
}
/**
- * "New State History" constructor, which doesn't use SHTConfig but the
+ * "New State History" constructor, which doesn't use HTConfig but the
* individual values separately. Kept for now for backwards compatibility,
* but you should definitely consider using SHTConfig instead (since its
* contents can then change without directly affecting SHT's API).
*/
+ @Deprecated
HistoryTree(File newStateFile, int blockSize, int maxChildren,
long startTime) throws IOException {
this(new HTConfig(newStateFile, blockSize, maxChildren, startTime));
return;
}
- /**
- * @name Accessors
- */
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
long getTreeStart() {
return config.treeStart;
return treeIO;
}
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
/**
* Rebuild the latestBranch "cache" object by reading the nodes from disk
* (When we are opening an existing file on disk and want to append to it,