org.apache.cassandra.io
Class SequenceFile.Writer

java.lang.Object
  extended by org.apache.cassandra.io.SequenceFile.AbstractWriter
      extended by org.apache.cassandra.io.SequenceFile.Writer
All Implemented Interfaces:
IFileWriter
Direct Known Subclasses:
SequenceFile.BufferWriter, SequenceFile.ChecksumWriter
Enclosing class:
SequenceFile

public static class SequenceFile.Writer
extends SequenceFile.AbstractWriter


Field Summary
protected  java.io.RandomAccessFile file_
           
 
Fields inherited from class org.apache.cassandra.io.SequenceFile.AbstractWriter
filename_
 
Method Summary
 void append(DataOutputBuffer buffer)
          Appends the buffer to the the underlying SequenceFile.
 void append(DataOutputBuffer keyBuffer, DataOutputBuffer buffer)
          Appends the key and the value to the the underlying SequenceFile.
 void append(java.lang.String key, byte[] value)
          Appends the key and the value to the the underlying SequenceFile.
 void append(java.lang.String key, DataOutputBuffer buffer)
          Appends the key and the value to the the underlying SequenceFile.
 void append(java.lang.String key, long value)
          Appends the key and the long value to the the underlying SequenceFile.
 void close()
          Close the file which is being used for the write.
 void close(byte[] footer, int size)
          Close the file after appending the passed in footer information.
 long getCurrentPosition()
          Get the current position of the file pointer.
 java.lang.String getFileName()
           
 long getFileSize()
           
protected  void init(java.lang.String filename)
           
protected  void init(java.lang.String filename, int size)
           
 void seek(long position)
          Seeks the file pointer to the specified position.
 long writeDirect(byte[] bytes)
          Be extremely careful while using this API.
 void writeLong(long value)
          Write a long into the underlying sub system.
 
Methods inherited from class org.apache.cassandra.io.SequenceFile.AbstractWriter
lastModified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file_

protected java.io.RandomAccessFile file_
Method Detail

init

protected void init(java.lang.String filename)
             throws java.io.IOException
Throws:
java.io.IOException

init

protected void init(java.lang.String filename,
                    int size)
             throws java.io.IOException
Throws:
java.io.IOException

getCurrentPosition

public long getCurrentPosition()
                        throws java.io.IOException
Description copied from interface: IFileWriter
Get the current position of the file pointer.

Returns:
current file pointer position
Throws:
java.io.IOException

seek

public void seek(long position)
          throws java.io.IOException
Description copied from interface: IFileWriter
Seeks the file pointer to the specified position.

Parameters:
position - position within the file to seek to.
Throws:
java.io.IOException

append

public void append(DataOutputBuffer buffer)
            throws java.io.IOException
Description copied from interface: IFileWriter
Appends the buffer to the the underlying SequenceFile.

Parameters:
buffer - buffer which contains the serialized data.
Throws:
java.io.IOException

append

public void append(DataOutputBuffer keyBuffer,
                   DataOutputBuffer buffer)
            throws java.io.IOException
Description copied from interface: IFileWriter
Appends the key and the value to the the underlying SequenceFile.

Parameters:
keyBuffer - buffer which contains the serialized key.
buffer - buffer which contains the serialized data.
Throws:
java.io.IOException

append

public void append(java.lang.String key,
                   DataOutputBuffer buffer)
            throws java.io.IOException
Description copied from interface: IFileWriter
Appends the key and the value to the the underlying SequenceFile.

Parameters:
key - key associated with this peice of data.
buffer - buffer containing the serialized data.
Throws:
java.io.IOException

append

public void append(java.lang.String key,
                   byte[] value)
            throws java.io.IOException
Description copied from interface: IFileWriter
Appends the key and the value to the the underlying SequenceFile.

Parameters:
key - key associated with this peice of data.
value - byte array containing the serialized data.
Throws:
java.io.IOException

append

public void append(java.lang.String key,
                   long value)
            throws java.io.IOException
Description copied from interface: IFileWriter
Appends the key and the long value to the the underlying SequenceFile. This is used in the contruction of the index file associated with a SSTable.

Parameters:
key - key associated with this peice of data.
value - value associated with this key.
Throws:
java.io.IOException

writeDirect

public long writeDirect(byte[] bytes)
                 throws java.io.IOException
Be extremely careful while using this API. This currently used to write the commit log header in the commit logs. If not used carefully it could completely screw up reads of other key/value pairs that are written.

Parameters:
bytes - the bytes to write
Throws:
java.io.IOException

writeLong

public void writeLong(long value)
               throws java.io.IOException
Description copied from interface: IFileWriter
Write a long into the underlying sub system.

Parameters:
value - long to be written
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Description copied from interface: IFileWriter
Close the file which is being used for the write.

Throws:
java.io.IOException

close

public void close(byte[] footer,
                  int size)
           throws java.io.IOException
Description copied from interface: IFileWriter
Close the file after appending the passed in footer information.

Parameters:
footer - footer information.
size - size of the footer.
Throws:
java.io.IOException

getFileName

public java.lang.String getFileName()
Specified by:
getFileName in interface IFileWriter
Overrides:
getFileName in class SequenceFile.AbstractWriter
Returns:
the name of the file.

getFileSize

public long getFileSize()
                 throws java.io.IOException
Returns:
the size of the file.
Throws:
java.io.IOException


Copyright © 2009 The Apache Software Foundation