|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.electric.database.geometry.btree.PageStorage com.sun.electric.database.geometry.btree.CachingPageStorage com.sun.electric.database.geometry.btree.CachingPageStorageWrapper
public class CachingPageStorageWrapper
A wrapper around PageStorage that makes it a CachingPageStorage
.
This class is thread-safe; overlapped read/write and write/write
pairs may produce undefined data, but are otherwise safe.
Nested Class Summary | |
---|---|
class |
CachingPageStorageWrapper.CachedPageImpl
A page which is currently in the cache. |
Nested classes/interfaces inherited from class com.sun.electric.database.geometry.btree.CachingPageStorage |
---|
CachingPageStorage.CachedPage |
Constructor Summary | |
---|---|
CachingPageStorageWrapper(PageStorage ps,
int cacheSize,
boolean asyncFlush)
An evicted page will be freed from memory (garbage collected) if the user of this class has not retained a reference to it; otherwise it simply no longer counts towards the maximum cache size. |
Method Summary | |
---|---|
void |
close()
close the PageStorage; invocation of any other methods after close() has undefined results |
int |
createPage()
creates a new page with undefined contents; returns its pageid |
void |
fsync()
ensure that the all pages are written to nonvolatile storage |
void |
fsync(int pageid)
ensure that the designated page is written to nonvolatile storage |
int |
getNumPages()
returns the number of pages; all pageids strictly less than this are valid |
CachingPageStorage.CachedPage |
getPage(int pageid,
boolean readBytes)
Creates space in the cache for pageid, but only actually reads the bytes if readBytes is true. |
void |
readPage(int pageid,
byte[] buf,
int ofs)
reads a page |
void |
setCacheSize(int cacheSize)
Sets the cache size, evicting pages if necessary. |
void |
writePage(int pageid,
byte[] buf,
int ofs)
Write a page through the cache to nonvolatile storage |
Methods inherited from class com.sun.electric.database.geometry.btree.PageStorage |
---|
getPageSize |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CachingPageStorageWrapper(PageStorage ps, int cacheSize, boolean asyncFlush)
cacheSize
- the maximum number of non-evicted PAGES in
the cache. Note that the total number of pages (evicted and
non-evicted) may exceed this number; this class simply ensures
that once a page is evicted its reference to the page is
weak. If the client application still holds a
reference to that page it will not be garbage collected.asyncFlush
- if true, a background thread will make a
best-effort attempt to flush dirty pages even before a flush()
is explicitly requested.Method Detail |
---|
public int createPage()
PageStorage
createPage
in class PageStorage
public int getNumPages()
PageStorage
getNumPages
in class PageStorage
public CachingPageStorage.CachedPage getPage(int pageid, boolean readBytes)
getPage
in class CachingPageStorage
public void writePage(int pageid, byte[] buf, int ofs)
CachingPageStorage
writePage
in class CachingPageStorage
public void readPage(int pageid, byte[] buf, int ofs)
PageStorage
readPage
in class PageStorage
public void setCacheSize(int cacheSize)
public void fsync(int pageid)
PageStorage
fsync
in class PageStorage
public void fsync()
PageStorage
fsync
in class PageStorage
public void close()
PageStorage
close
in class PageStorage
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |