DirCache.
The different update strategies extend this class to provide their own unique services to applications.
| Modifier and Type | Field and Description |
|---|---|
| protected DirCache | |
| protected DirCacheEntry[] | |
| protected int | entryCnt
Total number of valid entries in |
| Access | Constructor and Description |
|---|---|
| protected | BaseDirCacheEditor(DirCache
the cache this editor will eventually update. dc, int estimated number of entries the editor will have upon
completion. This sizes the initial entry table. ecnt)Construct a new editor. |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public boolean | Returns: true if the commit was successful and the file contains the new data; false if the commit failed and the file remains with the old data.Finish, write, commit this change, and release the index lock. |
| protected void | |
| protected void | fastKeep(int
first entry to copy from the destination cache. pos, int number of entries to copy. cnt)Add a range of existing entries from the destination cache. |
| public abstract void | |
| public DirCache | |
| private static int | |
| private static int | |
| protected void | |
| private static boolean |
| cache | back to summary |
|---|---|
protected DirCache cache
| |
| entries | back to summary |
|---|---|
protected DirCacheEntry[] entries
| |
| entryCnt | back to summary |
|---|---|
| protected int entryCnt Total number of valid entries in | |
| BaseDirCacheEditor | back to summary |
|---|---|
| protected BaseDirCacheEditor(DirCache dc, int ecnt) Construct a new editor.
| |
| checkNameConflicts | back to summary |
|---|---|
| private void checkNameConflicts() | |
| commit | back to summary |
|---|---|
| public boolean commit() throws IOException Finish, write, commit this change, and release the index lock. If this method fails (returns false) the lock is still released. This is a utility method for applications as the finish-write-commit pattern is very common after using a builder to update entries.
| |
| fastAdd | back to summary |
|---|---|
| protected void fastAdd(DirCacheEntry newEntry) Append one entry into the resulting entry list. The entry is placed at the end of the entry list. The caller is responsible for making sure the final table is correctly sorted.
The
| |
| fastKeep | back to summary |
|---|---|
| protected void fastKeep(int pos, int cnt) Add a range of existing entries from the destination cache. The entries are placed at the end of the entry list, preserving their current order. The caller is responsible for making sure the final table is correctly sorted. This method copies from the destination cache, which has not yet been updated with this editor's new table. So all offsets into the destination cache are not affected by any updates that may be currently taking place in this editor.
The
| |
| finish | back to summary |
|---|---|
| public abstract void finish() Finish this builder and update the destination
When this method completes this builder instance is no longer usable by the calling application. A new builder must be created to make additional changes to the index entries.
After completion the DirCache returned by
Note to implementors: Make sure | |
| getDirCache | back to summary |
|---|---|
| public DirCache getDirCache() Get the | |
| lastSlash | back to summary |
|---|---|
| private static int lastSlash(byte[] path) | |
| nextSlash | back to summary |
|---|---|
| private static int nextSlash(byte[] b, int p) | |
| replace | back to summary |
|---|---|
| protected void replace() Update the DirCache with the contents of
This method should be invoked only during an implementation of
| |
| startsWith | back to summary |
|---|---|
| private static boolean startsWith(byte[] a, byte[] b, int n) | |