com.caucho.db.blob
Class Inode

java.lang.Object
  extended by com.caucho.db.blob.Inode

public class Inode
extends java.lang.Object

Represents the indexes for a BLOB or CLOB. The inode contains 16 long values

  0) length of the saved file
  1-14) direct fragment addresses (to 224k)
  15) pointer to the indirect block
 

Inline storage (120)

If the length of the blob is less than 120, the blob is stored directly in the inode.

mini fragment storage (3840)

If the length of the blob is less than 3840, the blob is stored in mini-fragments of size 256 pointed by the inode's addresses. The maximum wasted space for mini-fragment storage is 255 bytes.

direct block storage

The first 14 block pointers (224k)

indirect storage

The indirect block (a 16k block) itself is divided into sections:
  0-1023) single indirect fragment addresses (16M, 2^24)
  1024-1535) double indirect block addresses (16G, 2^34)
  1536-2047) triple indirect block addresses (to 8T, 2^43)
 


Field Summary
static int BLOCK_SIZE
           
static int DIRECT_BLOCKS
           
static long DIRECT_MAX
           
static int DOUBLE_INDIRECT_BLOCKS
           
static long DOUBLE_INDIRECT_MAX
           
static int INDIRECT_BLOCKS
           
static int INLINE_BLOB_SIZE
           
static long INLINE_MAX
           
static int INODE_SIZE
           
static int MINI_FRAG_BLOB_SIZE
           
static int MINI_FRAG_MAX
           
static int MINI_FRAG_SIZE
           
static int SINGLE_INDIRECT_BLOCKS
           
static long SINGLE_INDIRECT_MAX
           
static int TRIPLE_INDIRECT_BLOCKS
           
 
Constructor Summary
Inode()
           
Inode(BlockStore store)
           
Inode(BlockStore store, StoreTransaction xa)
           
 
Method Summary
 byte[] getBuffer()
          Returns the buffer.
 long getLength()
          Returns the length.
 BlockStore getStore()
          Returns the backing store.
 void init(BlockStore store, StoreTransaction xa, byte[] buffer, int offset)
           
static boolean isValid(BlockStore store, byte[] bytes, int offset)
          Deletes the inode
 java.io.InputStream openInputStream()
          Opens a read stream to the inode.
 java.io.OutputStream openOutputStream()
          Opens a byte output stream to the inode.
 java.io.Reader openReader()
          Opens a char reader to the inode.
 java.io.Writer openWriter()
          Opens a char writer to the inode.
static long readLong(byte[] buffer, int offset)
          Reads the long.
 void remove()
          Deletes the inode
static void writeLong(byte[] buffer, int offset, long v)
          Writes the long.
static int writeToStream(byte[] inode, int inodeOffset, BlockStore store, java.io.OutputStream os, long offset, long length)
          Writes the inode value to a stream.
 void writeToStream(java.io.OutputStream os, long offset, long length)
          Writes the inode value to a stream.
 void writeToStream(OutputStreamWithBuffer os)
          Writes the inode value to a stream.
 void writeToStreamOld(OutputStreamWithBuffer os, long offset, long length)
          Writes the inode value to a stream.
 void writeToWriter(java.io.Writer writer)
          Writes the inode value to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INODE_SIZE

public static final int INODE_SIZE
See Also:
Constant Field Values

INLINE_BLOB_SIZE

public static final int INLINE_BLOB_SIZE
See Also:
Constant Field Values

BLOCK_SIZE

public static final int BLOCK_SIZE
See Also:
Constant Field Values

MINI_FRAG_SIZE

public static final int MINI_FRAG_SIZE
See Also:
Constant Field Values

MINI_FRAG_BLOB_SIZE

public static final int MINI_FRAG_BLOB_SIZE
See Also:
Constant Field Values

INDIRECT_BLOCKS

public static final int INDIRECT_BLOCKS
See Also:
Constant Field Values

DIRECT_BLOCKS

public static final int DIRECT_BLOCKS
See Also:
Constant Field Values

SINGLE_INDIRECT_BLOCKS

public static final int SINGLE_INDIRECT_BLOCKS
See Also:
Constant Field Values

DOUBLE_INDIRECT_BLOCKS

public static final int DOUBLE_INDIRECT_BLOCKS
See Also:
Constant Field Values

TRIPLE_INDIRECT_BLOCKS

public static final int TRIPLE_INDIRECT_BLOCKS
See Also:
Constant Field Values

INLINE_MAX

public static final long INLINE_MAX
See Also:
Constant Field Values

MINI_FRAG_MAX

public static final int MINI_FRAG_MAX
See Also:
Constant Field Values

DIRECT_MAX

public static final long DIRECT_MAX
See Also:
Constant Field Values

SINGLE_INDIRECT_MAX

public static final long SINGLE_INDIRECT_MAX
See Also:
Constant Field Values

DOUBLE_INDIRECT_MAX

public static final long DOUBLE_INDIRECT_MAX
See Also:
Constant Field Values
Constructor Detail

Inode

public Inode()

Inode

public Inode(BlockStore store,
             StoreTransaction xa)

Inode

public Inode(BlockStore store)
Method Detail

getStore

public BlockStore getStore()
Returns the backing store.


getBuffer

public byte[] getBuffer()
Returns the buffer.


getLength

public long getLength()
Returns the length.


init

public void init(BlockStore store,
                 StoreTransaction xa,
                 byte[] buffer,
                 int offset)

openInputStream

public java.io.InputStream openInputStream()
Opens a read stream to the inode.


writeToStream

public void writeToStream(OutputStreamWithBuffer os)
                   throws java.io.IOException
Writes the inode value to a stream.

Throws:
java.io.IOException

writeToStreamOld

public void writeToStreamOld(OutputStreamWithBuffer os,
                             long offset,
                             long length)
                      throws java.io.IOException
Writes the inode value to a stream.

Throws:
java.io.IOException

writeToStream

public void writeToStream(java.io.OutputStream os,
                          long offset,
                          long length)
                   throws java.io.IOException
Writes the inode value to a stream.

Throws:
java.io.IOException

writeToStream

public static int writeToStream(byte[] inode,
                                int inodeOffset,
                                BlockStore store,
                                java.io.OutputStream os,
                                long offset,
                                long length)
                         throws java.io.IOException
Writes the inode value to a stream.

Throws:
java.io.IOException

writeToWriter

public void writeToWriter(java.io.Writer writer)
                   throws java.io.IOException
Writes the inode value to a stream.

Throws:
java.io.IOException

openOutputStream

public java.io.OutputStream openOutputStream()
Opens a byte output stream to the inode.


openReader

public java.io.Reader openReader()
Opens a char reader to the inode.


openWriter

public java.io.Writer openWriter()
Opens a char writer to the inode.


remove

public void remove()
Deletes the inode


isValid

public static boolean isValid(BlockStore store,
                              byte[] bytes,
                              int offset)
Deletes the inode


readLong

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


writeLong

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