ozone core API

org.ozoneDB.core.storage.gammaStore
Class FileStreamStorage

java.lang.Object
  extended byorg.ozoneDB.core.storage.gammaStore.AbstractStorage
      extended byorg.ozoneDB.core.storage.gammaStore.FileStreamStorage
All Implemented Interfaces:
Storage

public class FileStreamStorage
extends AbstractStorage

Version:
$Id $
Author:
Leo Mekenkamp (mind the anti sp@m)

Field Summary
private  java.io.File file
           
private  java.io.DataInputStream in
           
private  java.io.DataOutputStream out
           
 
Constructor Summary
(package private) FileStreamStorage(java.io.File file)
           
 
Method Summary
private  void checkForRead()
           
private  void checkForWrite()
           
 void close()
           
 long length()
           
 void readFully(byte[] b, int offset, int length)
          Read lenght bytes from b, starting at offset.
 int readInt()
           
 long readLong()
           
 void seek(long pos)
          Introduced because some implementing classes (based on FileOutputStream and FileInputStream for instance) might not support seek operations.
 void setLength(long length)
          Sets the maximum length.
 void write(byte[] b, int offset, int length)
          Write lenght bytes from b, starting at offset.
 void writeInt(int value)
           
 void writeLong(long value)
           
 
Methods inherited from class org.ozoneDB.core.storage.gammaStore.AbstractStorage
readFully, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

in

private java.io.DataInputStream in

out

private java.io.DataOutputStream out

file

private java.io.File file
Constructor Detail

FileStreamStorage

FileStreamStorage(java.io.File file)
            throws java.io.IOException
Method Detail

checkForWrite

private void checkForWrite()
                    throws java.io.IOException
Throws:
java.io.IOException

checkForRead

private void checkForRead()
                   throws java.io.IOException
Throws:
java.io.IOException

setLength

public void setLength(long length)
               throws java.io.IOException
Description copied from interface: Storage
Sets the maximum length.

Throws:
java.io.IOException

seek

public void seek(long pos)
          throws java.io.IOException
Description copied from interface: Storage

Introduced because some implementing classes (based on FileOutputStream and FileInputStream for instance) might not support seek operations. They may throw an UnsupportedOperationException here, but still support writing and reading.

Implementations of this interface are used in 2 different ways: the IndexManager does not perform any seek actions, and thus the storage implementation it uses can include stream based ones; the ClusterManager however does perform seek actions and thus cannot have a storage implementation with streams in it.

Throws:
java.io.IOException

readFully

public void readFully(byte[] b,
                      int offset,
                      int length)
               throws java.io.IOException
Description copied from interface: Storage
Read lenght bytes from b, starting at offset.

Throws:
java.io.IOException

write

public void write(byte[] b,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from interface: Storage
Write lenght bytes from b, starting at offset.

Throws:
java.io.IOException

readLong

public long readLong()
              throws java.io.IOException
Throws:
java.io.IOException

writeLong

public void writeLong(long value)
               throws java.io.IOException
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

length

public long length()
            throws java.io.IOException
Throws:
java.io.IOException

readInt

public int readInt()
            throws java.io.IOException
Throws:
java.io.IOException

writeInt

public void writeInt(int value)
              throws java.io.IOException
Throws:
java.io.IOException

ozone core API

Copyright (C) The Ozone Database Project - www.ozone-db.org. All rights reserved.