storage.intermediateStorage
Class IntermediateStorageManager

java.lang.Object
  extended bystorage.intermediateStorage.IntermediateStorageManager

public final class IntermediateStorageManager
extends java.lang.Object

This class is used to manage the operatios of the intermediate storage component. The intermediate storage component controls operations of higer level than primitive storage, partial writing or reading from pages is provided. Intermediate storage manager also uses a little buffer for improving the massive I/O instructions over the same page.


Constructor Summary
IntermediateStorageManager(PrimitiveStorageManager psm)
          Constructs an intermediate storage manager from a primitive storage manager.
 
Method Summary
 PrimitiveStorageManager getPrimitiveStorageManager()
          Returns the underlying primitive storage manager.
 void read(int chunkNumber, long pageNumber, int pageOffset, byte[] b, int off, int length)
          Reads partially a page starting from an offset and reading a specific length of bytes.
 boolean readBit(int chunkNumber, long pageNumber, long bitNumber)
          Reads a specific bit from a page.
 long readLong(int chunkNumber, long pageNumber, int pageOffset)
          Reads a java 8-byte long from a page.
 void readPage(int chunkNumber, long pageNumber, byte[] b, int off)
          Reads fully a page.
 void synchronize()
          Syncronizes the local buffer with the underlying primitive storage manager.
 void synchronizeAndTransfer()
          Syncronizes itself and the underlying primitive storage manager with secundary storage.
 void synchronizeTransferAndClear()
          Syncronizes itself and the underlying primitive storage manager with secundary storage, also crear the buffer.
 void write(int chunkNumber, long pageNumber, int pageOffset, byte[] b, int off, int length)
          Writes partially a page starting from an offset and writing a specific length of bytes.
 void writeBit(int chunkNumber, long pageNumber, long bitNumber, boolean value)
          Writes a specific bit to a page.
 void writeLong(int chunkNumber, long pageNumber, int pageOffset, long number)
          Write a java 8-byte long to a page.
 void writePage(int chunkNumber, long pageNumber, byte[] b, int off)
          Writes partially a page starting from an offset and writing a specific length of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntermediateStorageManager

public IntermediateStorageManager(PrimitiveStorageManager psm)
Constructs an intermediate storage manager from a primitive storage manager.

Method Detail

getPrimitiveStorageManager

public PrimitiveStorageManager getPrimitiveStorageManager()
Returns the underlying primitive storage manager.


synchronize

public void synchronize()
                 throws java.io.IOException
Syncronizes the local buffer with the underlying primitive storage manager.

Throws:
java.io.IOException

synchronizeAndTransfer

public void synchronizeAndTransfer()
                            throws java.io.IOException
Syncronizes itself and the underlying primitive storage manager with secundary storage.

Throws:
java.io.IOException

synchronizeTransferAndClear

public void synchronizeTransferAndClear()
                                 throws java.io.IOException
Syncronizes itself and the underlying primitive storage manager with secundary storage, also crear the buffer.

Throws:
java.io.IOException

read

public void read(int chunkNumber,
                 long pageNumber,
                 int pageOffset,
                 byte[] b,
                 int off,
                 int length)
          throws PrimitiveStorageException,
                 InvalidPageOffsetException,
                 OutOfPageException,
                 java.io.IOException
Reads partially a page starting from an offset and reading a specific length of bytes.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
pageOffset - The position of the page from which the reading starts.
b - The byte array which the content of the readed page will be stored.
off - The offset of b from which the readed content will be stored.
length - The number of bytes to be readed.
Throws:
PrimitiveStorageException
InvalidPageOffsetException
OutOfPageException
java.io.IOException

write

public void write(int chunkNumber,
                  long pageNumber,
                  int pageOffset,
                  byte[] b,
                  int off,
                  int length)
           throws PrimitiveStorageException,
                  InvalidPageOffsetException,
                  OutOfPageException,
                  java.io.IOException
Writes partially a page starting from an offset and writing a specific length of bytes.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
pageOffset - The position of the page from which the writing starts.
b - The byte array from which the page's content will be get.
off - The offset of b from which the page's content will be get.
length - The number of bytes to be wrote.
Throws:
PrimitiveStorageException
InvalidPageOffsetException
OutOfPageException
java.io.IOException

readPage

public void readPage(int chunkNumber,
                     long pageNumber,
                     byte[] b,
                     int off)
              throws PrimitiveStorageException,
                     java.io.IOException
Reads fully a page.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
b - The byte array which the content of the readed page will be stored.
off - The offset of b from which the readed content will be stored.
Throws:
PrimitiveStorageException
java.io.IOException

writePage

public void writePage(int chunkNumber,
                      long pageNumber,
                      byte[] b,
                      int off)
               throws PrimitiveStorageException,
                      java.io.IOException
Writes partially a page starting from an offset and writing a specific length of bytes.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
b - The byte array from which the page's content will be get.
off - The offset of b from which the page's content will be get.
Throws:
PrimitiveStorageException
java.io.IOException

readBit

public boolean readBit(int chunkNumber,
                       long pageNumber,
                       long bitNumber)
                throws PrimitiveStorageException,
                       OutOfPageException,
                       java.io.IOException
Reads a specific bit from a page.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
bitNumber - The position of the bit inside the page. There are 8*pageSize available positions.
Returns:
true If the bit value is 1, false If the bit value is 0.
Throws:
PrimitiveStorageException
OutOfPageException
java.io.IOException

writeBit

public void writeBit(int chunkNumber,
                     long pageNumber,
                     long bitNumber,
                     boolean value)
              throws PrimitiveStorageException,
                     OutOfPageException,
                     java.io.IOException
Writes a specific bit to a page.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
bitNumber - The position of the bit inside the page. There are 8*pageSize available positions.
value - If value is true writes 1, if it is false writes 0.
Throws:
PrimitiveStorageException
OutOfPageException
java.io.IOException

readLong

public long readLong(int chunkNumber,
                     long pageNumber,
                     int pageOffset)
              throws PrimitiveStorageException,
                     InvalidPageOffsetException,
                     OutOfPageException,
                     java.io.IOException
Reads a java 8-byte long from a page.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
pageOffset - The position of the page from which the reading starts.
Returns:
The readed 8 bytes as a long.
Throws:
PrimitiveStorageException
InvalidPageOffsetException
OutOfPageException
java.io.IOException

writeLong

public void writeLong(int chunkNumber,
                      long pageNumber,
                      int pageOffset,
                      long number)
               throws PrimitiveStorageException,
                      InvalidPageOffsetException,
                      OutOfPageException,
                      java.io.IOException
Write a java 8-byte long to a page.

Parameters:
chunkNumber - The number of the chunk.
pageNumber - The number of the page inside the chunk.
pageOffset - The position of the page from which the writing starts.
number - The readed 8 bytes as a long to be wrote in the page.
Throws:
PrimitiveStorageException
InvalidPageOffsetException
OutOfPageException
java.io.IOException