|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.labs.minion.util.buffer.StdBufferImpl
com.sun.labs.minion.util.buffer.NIOBuffer
public class NIOBuffer
A buffer that uses java.nio buffers as the backing store.
This implementation is suitable for use in postings types.
Postings| Field Summary | |
|---|---|
protected java.nio.ByteBuffer |
units
A buffer backing our data. |
| Fields inherited from class com.sun.labs.minion.util.buffer.StdBufferImpl |
|---|
masks, maxBEValues, maxValues, nBits |
| Constructor Summary | |
|---|---|
protected |
NIOBuffer()
Creates a buffer that can be used when duplicating or slicing. |
|
NIOBuffer(java.nio.ByteBuffer units)
Creates a buffer using the given buffer. |
|
NIOBuffer(int n)
Creates a buffer with the given initial capacity. |
|
NIOBuffer(int n,
boolean direct)
Creates a buffer with the given initial capacity. |
| Method Summary | |
|---|---|
WriteableBuffer |
append(ReadableBuffer b,
int n)
Appends a given number of bytes from a readable buffer onto this buffer. |
protected byte[] |
array()
Gets an array of bytes from the units. |
int |
byteDecode()
Decodes an integer stored using the 7 bit encoding. |
WriteableBuffer |
capacity(int n)
Sets the capacity of the buffer to the given amount. |
protected void |
checkBounds(int p)
Checks whether the given position is outside our array bounds. |
ReadableBuffer |
duplicate()
Duplicates this buffer, so that it can be used safely by other readers. |
byte |
get()
Gets a byte from this buffer. |
byte |
get(int i)
Gets a byte from this buffer at the given position. |
ReadableBuffer |
getReadableBuffer()
Gets a readable buffer from this writeable one. |
int |
limit()
Gets the limit of this buffer, i.e., the last readable position. |
void |
limit(int l)
Sets the limit of this buffer, i.e., the last readable position. |
static void |
main(java.lang.String[] args)
A main program to test encoding and decoding of integers. |
WriteableBuffer |
or(ReadableBuffer b)
Computes the logical OR of this buffer and another. |
int |
position()
Gets the position in the buffer. |
void |
position(int position)
Sets the position in the buffer. |
WriteableBuffer |
put(byte b)
Puts a single byte onto this buffer. |
WriteableBuffer |
put(int p,
byte b)
Puts a single byte onto this buffer at the given position. |
int |
remaining()
Gets the amount of space remaining in the buffer. |
ReadableBuffer |
slice(int p,
int l)
Slices this buffer so that a sub-buffer can be used. |
void |
write(java.nio.ByteBuffer b)
Write the buffer to a new IO buffer. |
void |
write(java.io.DataOutput o)
Write the buffer to a data output. |
void |
write(java.io.OutputStream os)
Write the buffer to a stream. |
void |
write(java.nio.channels.WritableByteChannel chan)
Write the buffer to a channel. |
WriteableBuffer |
xor(ReadableBuffer b)
Computes the logical XOR of this buffer and another. |
| Methods inherited from class com.sun.labs.minion.util.buffer.StdBufferImpl |
|---|
append, byteDecode, byteDecode, byteDecodeLong, byteDecodeLong, byteDecodeLong, byteEncode, byteEncode, byteEncode, bytesRequired, byteToBinaryString, clear, countBits, countBits, decodeFloat, encode, encode, getString, set, sizeUTF8, skipByteEncoded, test, toString, toString, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.nio.ByteBuffer units
| Constructor Detail |
|---|
protected NIOBuffer()
public NIOBuffer(int n)
n - The initial capacity of the buffer.public NIOBuffer(java.nio.ByteBuffer units)
units - The buffer to duplicate and use as our internal representation.
public NIOBuffer(int n,
boolean direct)
n - The initial capacity.direct - If true, the buffer should be allocated as a direct
buffer.| Method Detail |
|---|
protected void checkBounds(int p)
p - The position which we want to check.public int position()
public void position(int position)
position - The point to which the buffer's position should be
set.public int remaining()
public WriteableBuffer capacity(int n)
n - The number of bytes that the buffer must be able to store.
public WriteableBuffer put(byte b)
b - The byte to put on the buffer
public WriteableBuffer put(int p,
byte b)
p - The position where the byte should be put.b - The byte to put on the buffer
public WriteableBuffer append(ReadableBuffer b,
int n)
append in interface WriteableBufferappend in class StdBufferImplb - The buffer that we want to append to this buffer.n - The number of bytes to append onto this buffer.
public WriteableBuffer or(ReadableBuffer b)
b - The buffer to or with this one.
public WriteableBuffer xor(ReadableBuffer b)
b - The buffer to or with this one.
public void write(java.nio.ByteBuffer b)
b - The buffer to which we will write our data.
public void write(java.nio.channels.WritableByteChannel chan)
throws java.io.IOException
chan - The channel to which the buffer should be written.
java.io.IOException - If there is any error during writing.protected byte[] array()
public void write(java.io.DataOutput o)
throws java.io.IOException
o - The output to which the buffer should be written.
java.io.IOException - If there is any error writing the buffer.
public void write(java.io.OutputStream os)
throws java.io.IOException
os - The stream to which the buffer should be written.
java.io.IOException - If there is any error writing the data.public ReadableBuffer getReadableBuffer()
public ReadableBuffer duplicate()
public ReadableBuffer slice(int p,
int l)
l - The number of bytes in the sliced buffer.p - The position at which the buffer should be sliced.
public int limit()
public void limit(int l)
l - The limit for the buffer.public byte get()
public byte get(int i)
i - The position from which we wish to get a byte.
public int byteDecode()
byteDecode in interface ReadableBufferbyteDecode in class StdBufferImplStdBufferImpl.byteEncode(long, int)
public static void main(java.lang.String[] args)
throws java.lang.Exception
args - The arguments
java.lang.Exception - If there is any problem.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||