|
Berkeley DB version 4.2.52 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sleepycat.db.Dbt
This information describes the specific details of the Dbt class, used to encode keys and data items in a database.
Storage and retrieval for the Db
access methods are based on key/data pairs. Both key and data items are represented by Dbt objects. Key and data byte strings may refer to strings of zero length up to strings of essentially unlimited length. See Database limits for more information.
The Dbt class provides simple access to an underlying data structure, whose elements can be examined or changed using the usual set or get methods. Dbt can be subclassed, providing a way to associate with it additional data or references to other structures.
The constructors set all elements of the underlying structure to zero. The constructor with one parameter has the effect of setting all elements to zero except for the data and size elements. The constructor with three parameters has the effect of setting all elements to zero except for the data, size and offset elements.
In the case where the flags structure element is set to 0, when being provided a key or data item by the application, the Berkeley DB package expects the data object to be set to a byte array of size bytes. When returning a key/data item to the application, the Berkeley DB package will store into the data object a byte array of size bytes. During a get operation, if none of the Db.DB_DBT_MALLOC, Db.DB_DBT_REALLOC or Db.DB_DBT_USERMEM flags are specified, the operation occurs as if Db.DB_DBT_MALLOC was used.
Access to Dbt objects is not re-entrant. In particular, if multiple threads simultaneously access the same Dbt object using Db
API calls, the results are undefined, and may result in a crash. One easy way to avoid problems is to use Dbt objects that are created as local variables and not shared among threads.
Constructor Summary | |
Dbt()
Construct an empty Dbt. |
|
Dbt(byte[] data)
Construct a Dbt where the data is the contents of the array and the Dbt's length is set to the length of the array. |
|
Dbt(byte[] data,
int off,
int len)
Construct a Dbt from len bytes from the array, starting at off. |
|
Dbt(Object serialobj)
Construct a Dbt where the data is the serialized form of the Object. |
Method Summary | |
byte[] |
get_data()
Deprecated. As of Berkeley DB 4.2, replaced by getData() |
int |
get_dlen()
Deprecated. As of Berkeley DB 4.2, replaced by getPartialLength() |
int |
get_doff()
Deprecated. As of Berkeley DB 4.2, replaced by getPartialOffset() |
int |
get_flags()
Deprecated. As of Berkeley DB 4.2, replaced by getFlags() |
Object |
get_object()
Deprecated. As of Berkeley DB 4.2, replaced by getObject() |
int |
get_offset()
Deprecated. As of Berkeley DB 4.2, replaced by getOffset() |
int |
get_recno_key_data()
Deprecated. As of Berkeley DB 4.2, replaced by getRecordNumber() |
int |
get_size()
Deprecated. As of Berkeley DB 4.2, replaced by getSize() |
int |
get_ulen()
Deprecated. As of Berkeley DB 4.2, replaced by getUserBufferLength() |
byte[] |
getData()
Return the data array. |
int |
getFlags()
Return the object flag value. |
Object |
getObject()
Return an object from the data array, encoding the object using the Java serialization API. |
int |
getOffset()
Return the byte offset into the data array. |
int |
getPartialLength()
Return the length of the partial record, in bytes. |
int |
getPartialOffset()
Return the offset of the partial record, in bytes. |
int |
getRecordNumber()
Return an object from the data array, expecting that data to be a logical record number. |
int |
getSize()
Return the data array size. |
int |
getUserBufferLength()
Return the length in bytes of the user-specified buffer. |
void |
set_data(byte[] data)
Deprecated. As of Berkeley DB 4.2, replaced by setData(byte[]) |
void |
set_dlen(int dlen)
Deprecated. As of Berkeley DB 4.2, replaced by setPartialLength(int) |
void |
set_doff(int doff)
Deprecated. As of Berkeley DB 4.2, replaced by setPartialOffset(int) |
void |
set_flags(int flags)
Deprecated. As of Berkeley DB 4.2, replaced by setFlags(int) |
void |
set_object(Object serialobj)
Deprecated. As of Berkeley DB 4.2, replaced by setObject(Object) |
void |
set_offset(int offset)
Deprecated. As of Berkeley DB 4.2, replaced by setOffset(int) |
void |
set_recno_key_data(int recno)
Deprecated. As of Berkeley DB 4.2, replaced by setRecordNumber(int) |
void |
set_size(int size)
Deprecated. As of Berkeley DB 4.2, replaced by setSize(int) |
void |
set_ulen(int ulen)
Deprecated. As of Berkeley DB 4.2, replaced by setUserBufferLength(int) |
void |
setData(byte[] data)
Set the data array. |
void |
setFlags(int flags)
Set the object flag value. |
void |
setObject(Object serialobj)
Initialize the data array from a serialized object, encoding the object using the Java serialization API. |
void |
setOffset(int offset)
Set the byte offset into the data array. |
void |
setPartialLength(int dlen)
Set the byte length of the partial record being read or written by the application, in bytes. |
void |
setPartialOffset(int doff)
Set the offset of the partial record being read or written by the application, in bytes. |
void |
setRecordNumber(int recno)
Initialize the data array from a logical record number. |
void |
setSize(int size)
Set the byte size of the data array. |
void |
setUserBufferLength(int ulen)
Set the byte size of the user-specified buffer. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Dbt()
public Dbt(byte[] data)
data
- the array to which the Dbt's data is set.public Dbt(byte[] data, int off, int len)
data
- the array from which the Dbt's data is set.len
- the length of the data in bytes.off
- starting byte offset of the data in the array.public Dbt(Object serialobj) throws IOException
serialobj
- the serialized form to which the Dbt's data is set.
IOException
- If there is an error while serializing the object.Method Detail |
public void setData(byte[] data)
data
- an array of bytes to be used to set the content for the Dbt.public void setFlags(int flags)
DbMemoryException
.
flags
- Dbt flag value.public void setObject(Object serialobj) throws IOException
serialobj
- the object to be serialized.
IOException
- If there is an error while de-serializing the object.public void setOffset(int offset)
The number of bytes offset into the data array determine the portion of the array actually used. This element is accessed using Dbt.getOffset and Dbt.setOffset. Although Java normally maintains proper alignment of byte arrays, the set_offset method can be used to specify unaligned addresses. Unaligned address accesses that are not supported by the underlying hardware may be reported as an exception, or may stop the running Java program.
offset
- the byte offset into the data array.public void setPartialLength(int dlen)
dlen
- the length of the partial record in bytes.public void setPartialOffset(int doff)
doff
- the offset of the partial record.public void setRecordNumber(int recno)
recno
- The recno parameter logical record number used to initialize the data array.public void setSize(int size)
size
- the size of the data array in bytes.public void setUserBufferLength(int ulen)
Note that applications can determine the length of a record by setting the ulen to 0 and checking the return value found in size. See the Db.DB_DBT_USERMEM flag for more information.
ulen
- The ulen parameter the size of the data array in bytes.public void set_data(byte[] data)
setData(byte[])
public void set_dlen(int dlen)
setPartialLength(int)
public void set_doff(int doff)
setPartialOffset(int)
public void set_flags(int flags)
setFlags(int)
public void set_object(Object serialobj) throws IOException
setObject(Object)
IOException
public void set_offset(int offset)
setOffset(int)
public void set_recno_key_data(int recno)
setRecordNumber(int)
public void set_size(int size)
setSize(int)
public void set_ulen(int ulen)
setUserBufferLength(int)
public byte[] getData()
public int getFlags()
public Object getObject() throws IOException, ClassNotFoundException
IOException
- If there is an error while de-serializing the object.
ClassNotFoundException
- If the stream contains a class not found by the runtime while de-serializing.public int getOffset()
public int getPartialLength()
public int getPartialOffset()
public int getRecordNumber()
public int getSize()
public int getUserBufferLength()
public byte[] get_data()
getData()
public int get_dlen()
getPartialLength()
public int get_doff()
getPartialOffset()
public int get_flags()
getFlags()
public Object get_object() throws IOException, ClassNotFoundException
getObject()
IOException
ClassNotFoundException
public int get_offset()
getOffset()
public int get_recno_key_data()
getRecordNumber()
public int get_size()
getSize()
public int get_ulen()
getUserBufferLength()
|
Berkeley DB version 4.2.52 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |