com.sleepycat.je.log
Class LogUtils

java.lang.Object
  extended by com.sleepycat.je.log.LogUtils

public class LogUtils
extends Object

This class holds convenience methods for marshalling internal JE data to and from the log.


Nested Class Summary
static class LogUtils.XidImpl
           
 
Field Summary
static int INT_BYTES
           
static int LONG_BYTES
           
static int SHORT_BYTES
           
static int UNSIGNED_INT_BYTES
           
 
Constructor Summary
LogUtils()
           
 
Method Summary
static boolean dumpBoolean(ByteBuffer itemBuffer, StringBuffer sb, String tag)
           
static int getBooleanLogSize()
           
static int getByteArrayLogSize(byte[] b)
           
static int getIntLogSize()
           
static int getLongLogSize()
           
static int getStringLogSize(String s)
           
static int getTimestampLogSize()
           
static long getUnsignedInt(ByteBuffer buf)
          Unmarshall the next four bytes which hold an unsigned int into a long.
static int getXidSize(Xid xid)
          The byte[]'s in Xid's are known to be 255 or less in length.
static void putUnsignedInt(ByteBuffer buf, long value)
          Marshall a long into the next 4 bytes in this buffer.
static boolean readBoolean(ByteBuffer logBuf)
          Read a boolean from the log.
static byte[] readByteArray(ByteBuffer logBuf)
          Read a byte array from the log.
static int readInt(ByteBuffer logBuf)
          Read a int from the log.
static int readIntMSB(ByteBuffer logBuf)
          Read a int from the log in MSB order.
static long readLong(ByteBuffer logBuf)
          Read a long from the log.
static short readShort(ByteBuffer logBuf)
          Read a short from the log.
static String readString(ByteBuffer logBuf)
          Read a string from the log.
static Timestamp readTimestamp(ByteBuffer logBuf)
          Read a timestamp from the log.
static Xid readXid(ByteBuffer logBuf)
           
static void writeBoolean(ByteBuffer logBuf, boolean bool)
          Write a boolean into the log.
static void writeByteArray(ByteBuffer logBuf, byte[] b)
          Write a byte array into the log.
static void writeInt(ByteBuffer logBuf, int i)
          Write an int into the log.
static void writeIntMSB(ByteBuffer logBuf, int i)
          Write an int into the log in MSB order.
static void writeLong(ByteBuffer logBuf, long l)
          Write a long into the log.
static void writeShort(ByteBuffer logBuf, short i)
          Write a short into the log.
static void writeString(ByteBuffer logBuf, String stringVal)
          Write a string into the log.
static void writeTimestamp(ByteBuffer logBuf, Timestamp time)
          Write a timestamp into the log.
static void writeUnsignedInt(ByteBuffer logBuf, long value)
          Write a long as an unsigned int.
static void writeXid(ByteBuffer logBuf, Xid xid)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORT_BYTES

public static final int SHORT_BYTES
See Also:
Constant Field Values

INT_BYTES

public static final int INT_BYTES
See Also:
Constant Field Values

LONG_BYTES

public static final int LONG_BYTES
See Also:
Constant Field Values

UNSIGNED_INT_BYTES

public static final int UNSIGNED_INT_BYTES
See Also:
Constant Field Values
Constructor Detail

LogUtils

public LogUtils()
Method Detail

putUnsignedInt

public static void putUnsignedInt(ByteBuffer buf,
                                  long value)
Marshall a long into the next 4 bytes in this buffer. Necessary when the long is used to hold an unsigned int.


writeUnsignedInt

public static void writeUnsignedInt(ByteBuffer logBuf,
                                    long value)
Write a long as an unsigned int.


getUnsignedInt

public static long getUnsignedInt(ByteBuffer buf)
Unmarshall the next four bytes which hold an unsigned int into a long.


writeShort

public static void writeShort(ByteBuffer logBuf,
                              short i)
Write a short into the log.


readShort

public static short readShort(ByteBuffer logBuf)
Read a short from the log.


writeInt

public static void writeInt(ByteBuffer logBuf,
                            int i)
Write an int into the log.


readInt

public static int readInt(ByteBuffer logBuf)
Read a int from the log.


getIntLogSize

public static int getIntLogSize()
Returns:
log storage size for a byteArray.

writeIntMSB

public static void writeIntMSB(ByteBuffer logBuf,
                               int i)
Write an int into the log in MSB order. Used for ordered keys.


readIntMSB

public static int readIntMSB(ByteBuffer logBuf)
Read a int from the log in MSB order. Used for ordered keys.


writeLong

public static void writeLong(ByteBuffer logBuf,
                             long l)
Write a long into the log.


readLong

public static long readLong(ByteBuffer logBuf)
Read a long from the log.


getLongLogSize

public static int getLongLogSize()
Returns:
log storage size for a byteArray.

writeByteArray

public static void writeByteArray(ByteBuffer logBuf,
                                  byte[] b)
Write a byte array into the log. The size is stored first as an integer.


readByteArray

public static byte[] readByteArray(ByteBuffer logBuf)
Read a byte array from the log. The size is stored first as an integer.


getByteArrayLogSize

public static int getByteArrayLogSize(byte[] b)
Returns:
log storage size for a byteArray

writeString

public static void writeString(ByteBuffer logBuf,
                               String stringVal)
Write a string into the log. The size is stored first as an integer.


readString

public static String readString(ByteBuffer logBuf)
Read a string from the log. The size is stored first as an integer.


getStringLogSize

public static int getStringLogSize(String s)
Returns:
log storage size for a string

writeTimestamp

public static void writeTimestamp(ByteBuffer logBuf,
                                  Timestamp time)
Write a timestamp into the log.


readTimestamp

public static Timestamp readTimestamp(ByteBuffer logBuf)
Read a timestamp from the log.


getTimestampLogSize

public static int getTimestampLogSize()
Returns:
log storage size for a timestamp

writeBoolean

public static void writeBoolean(ByteBuffer logBuf,
                                boolean bool)
Write a boolean into the log.


readBoolean

public static boolean readBoolean(ByteBuffer logBuf)
Read a boolean from the log.


getBooleanLogSize

public static int getBooleanLogSize()
Returns:
log storage size for a boolean.

dumpBoolean

public static boolean dumpBoolean(ByteBuffer itemBuffer,
                                  StringBuffer sb,
                                  String tag)

getXidSize

public static int getXidSize(Xid xid)
The byte[]'s in Xid's are known to be 255 or less in length. So instead of using read/writeByteArray(), we can save 6 bytes per record by making the byte[] length be 1 byte instead of 4.


writeXid

public static void writeXid(ByteBuffer logBuf,
                            Xid xid)

readXid

public static Xid readXid(ByteBuffer logBuf)


Copyright 2004-2005 Sleepycat, Inc. All Rights Reserved.