| java.lang.Object com.quadcap.sql.file.BlockFile
BlockFile | public class BlockFile implements PageManager,SegmentManager(Code) | | This class is used to create, modify, or read a blocked file. The blocked
file is accessed as a number of fixed size blocks, which are accessed
through a cache of a size specified by the class user.
author: Stan Bailes |
Constructor Summary | |
public | BlockFile(String filename, String mode, Properties props, int blocksize, int cacheSize) Create a new BlockFile, attached to the specified file. |
Method Summary | |
public void | clearModified() | public void | close() Flush the cache and close the underlying file. | public void | dump() | final void | ensureLastBlock(long i) | final public void | flush(boolean fastSync) | public void | freePage(long ref) Add this block to the free list. | public void | freeSegment(long seg) | public void | freeStream(long page) Destroy the stream with the specified root page and free up the
storage it was using. | public Block | getBlock(long i) | public int | getBlockSize() | public byte[] | getBytes(long seg) | public RandomAccessInputStream | getInputStream(long block) Return a new input stream, reading from the region with the specified
root block. | public Object | getLock() | Log | getLog() | public String | getName() | public Object | getObject(long ref) | public RandomAccessOutputStream | getOutputStream(long block) Return a new output stream, writing to the region with the specified
root block. | public Page | getPage(long i) Locate the specified block and return the cache entry associated
with that block. | static long | getPageBlock(long ref) | public PageManager | getPageManager(int i) | public PageManager | getPageManagerForLen(long len) | public PageManager | getPageManagerForPage(long page) | static int | getPageOffset(PageManager pm, long ref) | final public int | getPageSize() Return the block size used in this file. | public long | getSize() | public RandomAccess | getStream(long blockRef) | public long | getUserBlock(int stream) | public static void | main(String[] args) | protected BlockStore | makeStore(Properties props, String filename, int blockSize, String mode) | public long | newPage() Return the head of the free list, or grow the tail of the file. | public long | putBytes(byte[] buf) | public long | putObject(Object obj) | public void | removeObject(long ref) | public void | restoreBlock(long b, byte[] buf, int off) | public void | revert() | public void | setLog(Log log) | public void | showCache(PrintWriter os) | public String | signature() | public String | toString() | public void | updateBytes(long seg, byte[] buf) Update a segment with new value bytes. | public void | updateObject(long seg, Object obj) Write a new version of a persistent object to the store. |
MAX_PAGESHIFT | final static int MAX_PAGESHIFT(Code) | | |
MAX_STREAM | final static int MAX_STREAM(Code) | | |
MIN_SUBPAGE | final static int MIN_SUBPAGE(Code) | | |
REF_SIZE | final static int REF_SIZE(Code) | | |
inMemory | boolean inMemory(Code) | | |
lastBlock | long lastBlock(Code) | | Cached copy of largest allocated block number.
|
maxPageShift | int maxPageShift(Code) | | |
memObjectCount | long memObjectCount(Code) | | |
memoryObjects | LongMap memoryObjects(Code) | | For main-memory mode, our objects
|
oBLOCKSIZE | final static int oBLOCKSIZE(Code) | | |
oFREELIST | final static int oFREELIST(Code) | | |
oHASH_PASSWD_len | final static int oHASH_PASSWD_len(Code) | | |
oHASH_PASSWD_start | final static int oHASH_PASSWD_start(Code) | | |
oHEADER_SIZE | final static int oHEADER_SIZE(Code) | | |
oLASTBLOCK | final static int oLASTBLOCK(Code) | | |
oSTREAM_START | final static int oSTREAM_START(Code) | | |
oSUBPAGE_ROOT | final static int oSUBPAGE_ROOT(Code) | | |
quick | final static boolean quick(Code) | | |
readOnly | boolean readOnly(Code) | | |
store | BlockStore store(Code) | | The underlying store used by the cache to access the file.
|
BlockFile | public BlockFile(String filename, String mode, Properties props, int blocksize, int cacheSize) throws IOException(Code) | | Create a new BlockFile, attached to the specified file. For
an existing BlockFile, use the blocksize with which the file was
created -- for a new file, use the specified blocksize.
Parameters: filename - the file to operate on. Parameters: blockSize - the block size to use if we're creating a new file. Parameters: mode - "r" (read only) or "rw" (read-write) access. |
close | public void close() throws IOException(Code) | | Flush the cache and close the underlying file.
|
freePage | public void freePage(long ref) throws IOException(Code) | | Add this block to the free list.
Parameters: ref - the number of the now free block. |
freeStream | public void freeStream(long page) throws IOException(Code) | | Destroy the stream with the specified root page and free up the
storage it was using.
Parameters: page - the root page of the region exception: IOException - if the page number isn't valid, or if anothererror is detected trying to access the region. |
getBlockSize | public int getBlockSize()(Code) | | |
getBytes | public byte[] getBytes(long seg) throws IOException(Code) | | Return the segment as a byte array
Parameters: seg - the segment id the value of the segment's bytes |
getInputStream | public RandomAccessInputStream getInputStream(long block) throws IOException(Code) | | Return a new input stream, reading from the region with the specified
root block.
Parameters: block - the root block of the region an InputStream bound to the region. exception: IOException - if the block number isn't valid, or if anothererror is detected trying to access the region. |
getObject | public Object getObject(long ref) throws IOException(Code) | | Return the specified persistent object from the store
Parameters: ref - the block number of the object's root the object exception: IOException - may be thrown |
getOutputStream | public RandomAccessOutputStream getOutputStream(long block) throws IOException(Code) | | Return a new output stream, writing to the region with the specified
root block.
Parameters: block - the root block of the region an OutputStream bound to the region. exception: IOException - if the block number isn't valid, or if anothererror is detected trying to access the region. |
getPage | public Page getPage(long i) throws IOException(Code) | | Locate the specified block and return the cache entry associated
with that block. It needs to be the case that the cache entry is
"locked" while this returned object is active, so maybe the
Block class needs a finalize() routine.
Parameters: i - the block number the cache-handle of the block. |
getPageBlock | static long getPageBlock(long ref)(Code) | | |
getPageSize | final public int getPageSize()(Code) | | Return the block size used in this file.
|
getSize | public long getSize()(Code) | | |
newPage | public long newPage() throws IOException(Code) | | Return the head of the free list, or grow the tail of the file.
the number of an available block. |
putBytes | public long putBytes(byte[] buf) throws IOException(Code) | | Create a new segment with the specified bytes value and return
its reference
Parameters: buf - the value to write to the new segment the segment id |
putObject | public long putObject(Object obj) throws IOException(Code) | | Write a new object to the store and return its reference
Parameters: obj - the object the block number of the object's root exception: IOException - may be thrown |
removeObject | public void removeObject(long ref) throws IOException(Code) | | Remove an object from the store
Parameters: ref - the block number of the object's root exception: IOException - may be thrown |
restoreBlock | public void restoreBlock(long b, byte[] buf, int off) throws IOException(Code) | | |
updateBytes | public void updateBytes(long seg, byte[] buf) throws IOException(Code) | | Update a segment with new value bytes.
Parameters: buf - the value to write to the segment Parameters: seg - the segment id |
updateObject | public void updateObject(long seg, Object obj) throws IOException(Code) | | Write a new version of a persistent object to the store.
Parameters: blockNum - the address of the object's root page in the store Parameters: obj - the new object value exception: IOException - may be thrown |
|
|