org.galagosearch.core.index
Class CompressedByteBuffer

java.lang.Object
  extended by org.galagosearch.core.index.CompressedByteBuffer

public class CompressedByteBuffer
extends java.lang.Object

Stores lists of integers in vbyte compressed form. This is useful for buffering data that will be stored compressed on disk.


Constructor Summary
CompressedByteBuffer()
           
 
Method Summary
 void add(CompressedByteBuffer other)
          Copies the entire contents of another compressed buffer to the end of this one.
 void add(long i)
          Adds a single number to the buffer.
 void addFloat(float value)
          Adds a floating point value, (4 bytes) to the buffer.
 void addRaw(int value)
          Add a single byte to the buffer.
 void clear()
          Erases the contents of this buffer and sets its length to zero.
 byte[] getBytes()
          Returns a byte array containing the contents of this buffer.
 int length()
          Returns the length of the data stored in this buffer.
 void write(java.io.OutputStream stream)
          Writes the contents of this buffer to a stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompressedByteBuffer

public CompressedByteBuffer()
Method Detail

addRaw

public void addRaw(int value)
Add a single byte to the buffer. This byte is written directly to the buffer without compression.

Parameters:
value - The byte value to add.

add

public void add(long i)
Adds a single number to the buffer. This number is converted to compressed form before it is stored.


addFloat

public void addFloat(float value)
Adds a floating point value, (4 bytes) to the buffer. This is an uncompressed value.


add

public void add(CompressedByteBuffer other)
Copies the entire contents of another compressed buffer to the end of this one.

Parameters:
other - The buffer to copy.

clear

public void clear()
Erases the contents of this buffer and sets its length to zero.


getBytes

public byte[] getBytes()
Returns a byte array containing the contents of this buffer. The array returned may be larger than the actual length of the stored data. Use the length method to determine the true data length.


length

public int length()
Returns the length of the data stored in this buffer.


write

public void write(java.io.OutputStream stream)
           throws java.io.IOException
Writes the contents of this buffer to a stream.

Throws:
java.io.IOException


Copyright © 2009. All Rights Reserved.