Java Doc for Store.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » db » store » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » EJB Server resin 3.1.5 » resin » com.caucho.db.store 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.caucho.db.store.Store

All known Subclasses:   com.caucho.db.table.Table,
Store
public class Store (Code)
The store manages the block-based persistent store file. Each table will have its own store file, table.db. The store is block-based, where each block is 64k. Block allocation is tracked by a free block, block 0. Each block is represented as a two-byte value. The first byte is the allocation code: free, row, or used. The second byte is a fragment allocation mask. Since 64k stores 32k entries, the allocation block can handle a 2G database size. If the database is larger, another free block occurs at block 32k handling another 2G. The blocks are marked as free (00), row (01), used (10) or fragment(11). Row-blocks are table rows, so a table iterator will only look at the row blocks. Used blocks are for special blocks like the free list. Fragments are for blobs. Each store has a unique id in the database. The store id is merged with the block number in the store to create a unique block id. There are 64k allowed stores (and therefore 64k tables), leaving 64 - 16 = 48 bits for the blocks in a table, i.e. 2 ^ 48 blocks = 256T blocks. block index: the block number in the file. address: the address of a byte within the store, treating the file as a flat file. block id: the unique id of the block in the database.

Blobs and fragments

Fragments are stored in 8k chunks with a single byte prefix indicating its use.

Transactions

Fragments are not associated with transactions. The rollback is associated with a transaction.

Inner Class :static class RandomAccessWrapper

Field Summary
final public static  intALLOC_FRAGMENT
    
final public static  intALLOC_FREE
    
final public static  intALLOC_INDEX
    
final public static  intALLOC_MASK
    
final public static  intALLOC_MINI_FRAG
    
final public static  intALLOC_ROW
    
final public static  intALLOC_USED
    
final public static  intBLOCK_BITS
    
final public static  longBLOCK_INDEX_MASK
    
final public static  longBLOCK_MASK
    
final public static  longBLOCK_OFFSET_MASK
    
final public static  intBLOCK_SIZE
    
final public static  longDATA_START
    
final public static  intFRAGMENT_PER_BLOCK
    
final public static  intFRAGMENT_SIZE
    
final public static  intMINI_FRAG_ALLOC_OFFSET
    
final public static  intMINI_FRAG_PER_BLOCK
    
final public static  intMINI_FRAG_SIZE
    
final public static  intSTORE_CREATE_END
    
final protected  BlockManager_blockManager
    
final protected  Database_database
    

Constructor Summary
public  Store(Database database, String name, Lock tableLock)
    
public  Store(Database database, String name, Lock rowLock, Path path)
     Creates a new store.

Method Summary
final public  longaddressToBlockId(long address)
     Converts from the block index to the unique block id.
public  BlockallocateBlock()
     Allocates a new block for a non-row.
public  longallocateFragment(StoreTransaction xa)
     Allocates a new fragment.
public  BlockallocateIndexBlock()
    
public  longallocateMiniFragment(StoreTransaction xa)
     Allocates a new miniFragment.
public  BlockallocateRow()
     Allocates a new block for a row.
protected  voidassertStoreActive()
     Check that an allocated block is valid.
public static  longblockIdToAddress(long blockId)
     Converts from the block index to the unique block id.
public static  longblockIdToAddress(long blockId, int offset)
     Converts from the block index to the unique block id.
public  voidclose()
     Closes the store.
public static  StringcodeToName(int code)
     Debug names for the allocation.
public static  Storecreate(Path path)
     Creates an independent store.
public  voidcreate()
     Creates the store.
public  voiddeleteFragment(StoreTransaction xa, long fragmentAddress)
     Deletes a fragment.
public  voiddeleteMiniFragment(StoreTransaction xa, long fragmentAddress)
     Deletes a miniFragment.
public  longfirstBlock(long blockId, int type)
     Returns the first block id which contains a row.
public  longfirstFragment(long blockId)
     Returns the first block id which contains a fragment.
public  longfirstRow(long blockId)
     Returns the first block id which contains a row.
public  voidflush()
     Flush the store.
protected  voidfreeBlock(long blockId)
     Frees a block.
public  byte[]getAllocationTable()
     Returns a copy of the allocation table.
public  longgetBlockCount()
     Returns the block count.
public  BlockManagergetBlockManager()
     Returns the block manager.
public  longgetFileSize()
     Returns the file size.
public  intgetId()
     Returns the store's id.
public  LockgetLock()
     Returns the table's lock.
public  StringgetName()
     Returns the store's name.
public  longgetTotalFragmentSize()
     Returns the current number of fragments used.
public  voidinit()
    
public  booleanisClosed()
     True if destroyed.
public  booleanisFlushDirtyBlocksOnCommit()
     If true, dirty blocks are written at commit time.
public  booleanisIndexBlock(long blockAddress)
     Return true if the block is an index block.
public  booleanisRowBlock(long blockAddress)
     Return true if the block is a row block.
final public  BlockreadBlock(long blockAddress)
     Returns the matching block.
public  intreadBlock(long blockAddress, int blockOffset, byte[] buffer, int offset, int length)
     Reads a block.
public  intreadBlock(long blockAddress, int blockOffset, char[] buffer, int offset, int length)
     Reads a block for a clob.
public  voidreadBlock(long blockId, byte[] buffer, int offset, int length)
     Reads a block into the buffer.
public  longreadBlockLong(long blockAddress, int offset)
     Reads a long value from a block.
public  intreadFragment(long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length)
     Reads a fragment.
public  intreadFragment(long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length)
     Reads a fragment for a clob.
public  longreadFragmentLong(long fragmentAddress, int fragmentOffset)
     Reads a long value from a fragment.
public static  longreadLong(byte[] buffer, int offset)
     Reads the long.
public  intreadMiniFragment(long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length)
     Reads a fragment.
public  intreadMiniFragment(long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length)
     Reads a miniFragment for a clob.
public  longreadMiniFragmentLong(long fragmentAddress, int fragmentOffset)
     Reads a long value from a miniFragment.
public  voidremove()
    
 voidsaveAllocation()
     Sets the allocation for a block.
public  voidsetFlushDirtyBlocksOnCommit(boolean flushOnCommit)
     If true, dirty blocks are written at commit time.
public  StringtoString()
    
protected  voidvalidateBlockId(long blockId)
     Check that an allocated block is valid.
public  voidwriteBlock(StoreTransaction xa, long blockAddress, int blockOffset, byte[] buffer, int offset, int length)
     Writes a blockfragment.
public  voidwriteBlock(StoreTransaction xa, long blockAddress, int blockOffset, char[] buffer, int offset, int length)
    
public  voidwriteBlock(long blockAddress, byte[] buffer, int offset, int length)
     Saves the buffer to the database.
public  voidwriteBlockLong(StoreTransaction xa, long blockAddress, int offset, long value)
    
public  voidwriteFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length)
     Writes a fragment.
public  voidwriteFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length)
    
public  voidwriteFragmentLong(StoreTransaction xa, long fragmentAddress, int fragmentOffset, long value)
     Writes a long value to a fragment.
public static  voidwriteLong(byte[] buffer, int offset, long v)
     Writes the long.
public  voidwriteMiniFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length)
     Writes a miniFragment.
public  voidwriteMiniFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length)
    
public  voidwriteMiniFragmentLong(StoreTransaction xa, long fragmentAddress, int fragmentOffset, long value)
     Writes a long value to a miniFragment.

Field Detail
ALLOC_FRAGMENT
final public static int ALLOC_FRAGMENT(Code)



ALLOC_FREE
final public static int ALLOC_FREE(Code)



ALLOC_INDEX
final public static int ALLOC_INDEX(Code)



ALLOC_MASK
final public static int ALLOC_MASK(Code)



ALLOC_MINI_FRAG
final public static int ALLOC_MINI_FRAG(Code)



ALLOC_ROW
final public static int ALLOC_ROW(Code)



ALLOC_USED
final public static int ALLOC_USED(Code)



BLOCK_BITS
final public static int BLOCK_BITS(Code)



BLOCK_INDEX_MASK
final public static long BLOCK_INDEX_MASK(Code)



BLOCK_MASK
final public static long BLOCK_MASK(Code)



BLOCK_OFFSET_MASK
final public static long BLOCK_OFFSET_MASK(Code)



BLOCK_SIZE
final public static int BLOCK_SIZE(Code)



DATA_START
final public static long DATA_START(Code)



FRAGMENT_PER_BLOCK
final public static int FRAGMENT_PER_BLOCK(Code)



FRAGMENT_SIZE
final public static int FRAGMENT_SIZE(Code)



MINI_FRAG_ALLOC_OFFSET
final public static int MINI_FRAG_ALLOC_OFFSET(Code)



MINI_FRAG_PER_BLOCK
final public static int MINI_FRAG_PER_BLOCK(Code)



MINI_FRAG_SIZE
final public static int MINI_FRAG_SIZE(Code)



STORE_CREATE_END
final public static int STORE_CREATE_END(Code)



_blockManager
final protected BlockManager _blockManager(Code)



_database
final protected Database _database(Code)




Constructor Detail
Store
public Store(Database database, String name, Lock tableLock)(Code)



Store
public Store(Database database, String name, Lock rowLock, Path path)(Code)
Creates a new store.
Parameters:
  database - the owning database.
Parameters:
  name - the store name
Parameters:
  lock - the table lock
Parameters:
  path - the path to the files




Method Detail
addressToBlockId
final public long addressToBlockId(long address)(Code)
Converts from the block index to the unique block id.



allocateBlock
public Block allocateBlock() throws IOException(Code)
Allocates a new block for a non-row. the block id of the allocated block.



allocateFragment
public long allocateFragment(StoreTransaction xa) throws IOException(Code)
Allocates a new fragment. the fragment address



allocateIndexBlock
public Block allocateIndexBlock() throws IOException(Code)
Allocates a new block for an index the block id of the allocated block.



allocateMiniFragment
public long allocateMiniFragment(StoreTransaction xa) throws IOException(Code)
Allocates a new miniFragment. the fragment address



allocateRow
public Block allocateRow() throws IOException(Code)
Allocates a new block for a row. the block id of the allocated block.



assertStoreActive
protected void assertStoreActive() throws IllegalStateException(Code)
Check that an allocated block is valid.



blockIdToAddress
public static long blockIdToAddress(long blockId)(Code)
Converts from the block index to the unique block id.



blockIdToAddress
public static long blockIdToAddress(long blockId, int offset)(Code)
Converts from the block index to the unique block id.



close
public void close()(Code)
Closes the store.



codeToName
public static String codeToName(int code)(Code)
Debug names for the allocation.



create
public static Store create(Path path) throws IOException, SQLException(Code)
Creates an independent store.



create
public void create() throws IOException, SQLException(Code)
Creates the store.



deleteFragment
public void deleteFragment(StoreTransaction xa, long fragmentAddress) throws IOException(Code)
Deletes a fragment.



deleteMiniFragment
public void deleteMiniFragment(StoreTransaction xa, long fragmentAddress) throws IOException(Code)
Deletes a miniFragment.



firstBlock
public long firstBlock(long blockId, int type) throws IOException(Code)
Returns the first block id which contains a row. the block id of the first row block



firstFragment
public long firstFragment(long blockId) throws IOException(Code)
Returns the first block id which contains a fragment. the block id of the first row block



firstRow
public long firstRow(long blockId) throws IOException(Code)
Returns the first block id which contains a row. the block id of the first row block



flush
public void flush()(Code)
Flush the store.



freeBlock
protected void freeBlock(long blockId) throws IOException(Code)
Frees a block. the block id of the allocated block.



getAllocationTable
public byte[] getAllocationTable()(Code)
Returns a copy of the allocation table.



getBlockCount
public long getBlockCount()(Code)
Returns the block count.



getBlockManager
public BlockManager getBlockManager()(Code)
Returns the block manager.



getFileSize
public long getFileSize()(Code)
Returns the file size.



getId
public int getId()(Code)
Returns the store's id.



getLock
public Lock getLock()(Code)
Returns the table's lock.



getName
public String getName()(Code)
Returns the store's name.



getTotalFragmentSize
public long getTotalFragmentSize()(Code)
Returns the current number of fragments used.



init
public void init() throws IOException(Code)



isClosed
public boolean isClosed()(Code)
True if destroyed.



isFlushDirtyBlocksOnCommit
public boolean isFlushDirtyBlocksOnCommit()(Code)
If true, dirty blocks are written at commit time.



isIndexBlock
public boolean isIndexBlock(long blockAddress)(Code)
Return true if the block is an index block.



isRowBlock
public boolean isRowBlock(long blockAddress)(Code)
Return true if the block is a row block.



readBlock
final public Block readBlock(long blockAddress) throws IOException(Code)
Returns the matching block.



readBlock
public int readBlock(long blockAddress, int blockOffset, byte[] buffer, int offset, int length) throws IOException(Code)
Reads a block.
Parameters:
  blockAddress - the address of the block
Parameters:
  blockOffset - the offset inside the block to start reading
Parameters:
  buffer - the result buffer
Parameters:
  offset - offset into the result buffer
Parameters:
  length - the number of bytes to read the number of bytes read



readBlock
public int readBlock(long blockAddress, int blockOffset, char[] buffer, int offset, int length) throws IOException(Code)
Reads a block for a clob.
Parameters:
  blockAddress - the address of the block
Parameters:
  blockOffset - the offset inside the block to start reading
Parameters:
  buffer - the result buffer
Parameters:
  offset - offset into the result buffer
Parameters:
  length - the length of the block in characters the number of characters read



readBlock
public void readBlock(long blockId, byte[] buffer, int offset, int length) throws IOException(Code)
Reads a block into the buffer.



readBlockLong
public long readBlockLong(long blockAddress, int offset) throws IOException(Code)
Reads a long value from a block. the long value



readFragment
public int readFragment(long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length) throws IOException(Code)
Reads a fragment.
Parameters:
  fragmentAddress - the address of the fragment
Parameters:
  fragmentOffset - the offset inside the fragment to start reading
Parameters:
  buffer - the result buffer
Parameters:
  offset - offset into the result buffer
Parameters:
  length - the number of bytes to read the number of bytes read



readFragment
public int readFragment(long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length) throws IOException(Code)
Reads a fragment for a clob.
Parameters:
  fragmentAddress - the address of the fragment
Parameters:
  fragmentOffset - the offset inside the fragment to start reading
Parameters:
  buffer - the result buffer
Parameters:
  offset - offset into the result buffer
Parameters:
  length - the length of the fragment in characters the number of characters read



readFragmentLong
public long readFragmentLong(long fragmentAddress, int fragmentOffset) throws IOException(Code)
Reads a long value from a fragment. the long value



readLong
public static long readLong(byte[] buffer, int offset)(Code)
Reads the long.



readMiniFragment
public int readMiniFragment(long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length) throws IOException(Code)
Reads a fragment.
Parameters:
  fragmentAddress - the address of the fragment
Parameters:
  fragmentOffset - the offset inside the fragment to start reading
Parameters:
  buffer - the result buffer
Parameters:
  offset - offset into the result buffer
Parameters:
  length - the number of bytes to read the number of bytes read



readMiniFragment
public int readMiniFragment(long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length) throws IOException(Code)
Reads a miniFragment for a clob.
Parameters:
  fragmentAddress - the address of the fragment
Parameters:
  fragmentOffset - the offset inside the fragment to start reading
Parameters:
  buffer - the result buffer
Parameters:
  offset - offset into the result buffer
Parameters:
  length - the length of the fragment in characters the number of characters read



readMiniFragmentLong
public long readMiniFragmentLong(long fragmentAddress, int fragmentOffset) throws IOException(Code)
Reads a long value from a miniFragment. the long value



remove
public void remove() throws SQLException(Code)



saveAllocation
void saveAllocation() throws IOException(Code)
Sets the allocation for a block.



setFlushDirtyBlocksOnCommit
public void setFlushDirtyBlocksOnCommit(boolean flushOnCommit)(Code)
If true, dirty blocks are written at commit time.



toString
public String toString()(Code)



validateBlockId
protected void validateBlockId(long blockId) throws IllegalArgumentException, IllegalStateException(Code)
Check that an allocated block is valid.



writeBlock
public void writeBlock(StoreTransaction xa, long blockAddress, int blockOffset, byte[] buffer, int offset, int length) throws IOException(Code)
Writes a blockfragment.
Parameters:
  xa - the owning transaction
Parameters:
  blockAddress - the block to write
Parameters:
  blockOffset - the offset into the block
Parameters:
  buffer - the write buffer
Parameters:
  offset - offset into the write buffer
Parameters:
  length - the number of bytes to write the fragment id



writeBlock
public void writeBlock(StoreTransaction xa, long blockAddress, int blockOffset, char[] buffer, int offset, int length) throws IOException(Code)
Writes a character based block
Parameters:
  blockAddress - the fragment to write
Parameters:
  blockOffset - the offset into the fragment
Parameters:
  buffer - the write buffer
Parameters:
  offset - offset into the write buffer
Parameters:
  length - the number of bytes to write



writeBlock
public void writeBlock(long blockAddress, byte[] buffer, int offset, int length) throws IOException(Code)
Saves the buffer to the database.



writeBlockLong
public void writeBlockLong(StoreTransaction xa, long blockAddress, int offset, long value) throws IOException(Code)
Writes a long value to a block the long value



writeFragment
public void writeFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length) throws IOException(Code)
Writes a fragment.
Parameters:
  xa - the owning transaction
Parameters:
  fragmentAddress - the fragment to write
Parameters:
  fragmentOffset - the offset into the fragment
Parameters:
  buffer - the write buffer
Parameters:
  offset - offset into the write buffer
Parameters:
  length - the number of bytes to write the fragment id



writeFragment
public void writeFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length) throws IOException(Code)
Writes a character based
Parameters:
  fragmentAddress - the fragment to write
Parameters:
  fragmentOffset - the offset into the fragment
Parameters:
  buffer - the write buffer
Parameters:
  offset - offset into the write buffer
Parameters:
  length - the number of bytes to write



writeFragmentLong
public void writeFragmentLong(StoreTransaction xa, long fragmentAddress, int fragmentOffset, long value) throws IOException(Code)
Writes a long value to a fragment. the long value



writeLong
public static void writeLong(byte[] buffer, int offset, long v)(Code)
Writes the long.



writeMiniFragment
public void writeMiniFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, byte[] buffer, int offset, int length) throws IOException(Code)
Writes a miniFragment.
Parameters:
  xa - the owning transaction
Parameters:
  fragmentAddress - the fragment to write
Parameters:
  fragmentOffset - the offset into the fragment
Parameters:
  buffer - the write buffer
Parameters:
  offset - offset into the write buffer
Parameters:
  length - the number of bytes to write the fragment id



writeMiniFragment
public void writeMiniFragment(StoreTransaction xa, long fragmentAddress, int fragmentOffset, char[] buffer, int offset, int length) throws IOException(Code)
Writes a character based
Parameters:
  miniFragmentAddress - the fragment to write
Parameters:
  fragmentOffset - the offset into the fragment
Parameters:
  buffer - the write buffer
Parameters:
  offset - offset into the write buffer
Parameters:
  length - the number of bytes to write



writeMiniFragmentLong
public void writeMiniFragmentLong(StoreTransaction xa, long fragmentAddress, int fragmentOffset, long value) throws IOException(Code)
Writes a long value to a miniFragment. the long value



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.