Version 2.3.1
com.wiredtiger.db.Cursor Class Reference

A WT_CURSOR handle is the interface to a cursor. More...

Public Member Functions

synchronized void delete ()
 
String getKeyFormat ()
 Retrieve the format string for this cursor's key.
 
String getValueFormat ()
 Retrieve the format string for this cursor's value.
 
Cursor putKeyByte (byte value) throws WiredTigerPackingException
 Append a byte to the cursor's key. More...
 
Cursor putKeyByteArray (byte[] value) throws WiredTigerPackingException
 Append a byte array to the cursor's key. More...
 
Cursor putKeyByteArray (byte[] value, int off, int len) throws WiredTigerPackingException
 Append a byte array to the cursor's key. More...
 
Cursor putKeyInt (int value) throws WiredTigerPackingException
 Append an integer to the cursor's key. More...
 
Cursor putKeyLong (long value) throws WiredTigerPackingException
 Append a long to the cursor's key. More...
 
Cursor putKeyShort (short value) throws WiredTigerPackingException
 Append a short integer to the cursor's key. More...
 
Cursor putKeyString (String value) throws WiredTigerPackingException
 Append a string to the cursor's key. More...
 
Cursor putValueByte (byte value) throws WiredTigerPackingException
 Append a byte to the cursor's value. More...
 
Cursor putValueByteArray (byte[] value) throws WiredTigerPackingException
 Append a byte array to the cursor's value. More...
 
Cursor putValueByteArray (byte[] value, int off, int len) throws WiredTigerPackingException
 Append a byte array to the cursor's value. More...
 
Cursor putValueInt (int value) throws WiredTigerPackingException
 Append an integer to the cursor's value. More...
 
Cursor putValueLong (long value) throws WiredTigerPackingException
 Append a long to the cursor's value. More...
 
Cursor putValueShort (short value) throws WiredTigerPackingException
 Append a short integer to the cursor's value. More...
 
Cursor putValueString (String value) throws WiredTigerPackingException
 Append a string to the cursor's value. More...
 
byte getKeyByte () throws WiredTigerPackingException
 Retrieve a byte from the cursor's key. More...
 
void getKeyByteArray (byte[] output) throws WiredTigerPackingException
 Retrieve a byte array from the cursor's key. More...
 
void getKeyByteArray (byte[] output, int off, int len) throws WiredTigerPackingException
 Retrieve a byte array from the cursor's key. More...
 
byte[] getKeyByteArray () throws WiredTigerPackingException
 Retrieve a byte array from the cursor's key. More...
 
int getKeyInt () throws WiredTigerPackingException
 Retrieve an integer from the cursor's key. More...
 
long getKeyLong () throws WiredTigerPackingException
 Retrieve a long from the cursor's key. More...
 
short getKeyShort () throws WiredTigerPackingException
 Retrieve a short integer from the cursor's key. More...
 
String getKeyString () throws WiredTigerPackingException
 Retrieve a string from the cursor's key. More...
 
byte getValueByte () throws WiredTigerPackingException
 Retrieve a byte from the cursor's value. More...
 
void getValueByteArray (byte[] output) throws WiredTigerPackingException
 Retrieve a byte array from the cursor's value. More...
 
void getValueByteArray (byte[] output, int off, int len) throws WiredTigerPackingException
 Retrieve a byte array from the cursor's value. More...
 
byte[] getValueByteArray () throws WiredTigerPackingException
 Retrieve a byte array from the cursor's value. More...
 
int getValueInt () throws WiredTigerPackingException
 Retrieve an integer from the cursor's value. More...
 
long getValueLong () throws WiredTigerPackingException
 Retrieve a long from the cursor's value. More...
 
short getValueShort () throws WiredTigerPackingException
 Retrieve a short integer from the cursor's value. More...
 
String getValueString () throws WiredTigerPackingException
 Retrieve a string from the cursor's value. More...
 
int insert () throws WiredTigerException
 Insert the cursor's current key/value into the table. More...
 
int update () throws WiredTigerException
 Update the cursor's current key/value into the table. More...
 
int remove () throws WiredTigerException
 Remove the cursor's current key/value into the table. More...
 
int compare (Cursor other) throws WiredTigerException
 Compare this cursor's position to another Cursor. More...
 
int next () throws WiredTigerException
 Retrieve the next item in the table. More...
 
int prev () throws WiredTigerException
 Retrieve the previous item in the table. More...
 
int search () throws WiredTigerException
 Search for an item in the table. More...
 
SearchStatus search_near () throws WiredTigerException
 Search for an item in the table. More...
 
Session getSession ()
 
String getUri ()
 
int reset () throws com.wiredtiger.db.WiredTigerException
 Reset the position of the cursor. More...
 
int close () throws com.wiredtiger.db.WiredTigerException
 Close the cursor. More...
 
int compare_wrap (Cursor other)
 

Protected Member Functions

 Cursor (long cPtr, boolean cMemoryOwn)
 
String getKey_format ()
 
String getValue_format ()
 
int next_wrap () throws com.wiredtiger.db.WiredTigerException
 
int prev_wrap () throws com.wiredtiger.db.WiredTigerException
 
byte[] get_key_wrap ()
 
byte[] get_value_wrap ()
 
int insert_wrap (byte[] k, byte[] v)
 
int remove_wrap (byte[] k)
 
int search_wrap (byte[] k)
 
SearchStatus search_near_wrap (byte[] k)
 
int update_wrap (byte[] k, byte[] v)
 
int java_init (Object jcursor)
 

Static Protected Member Functions

static long getCPtr (Cursor obj)
 

Protected Attributes

boolean swigCMemOwn
 
String keyFormat
 
String valueFormat
 
PackOutputStream keyPacker
 
PackOutputStream valuePacker
 
PackInputStream keyUnpacker
 
PackInputStream valueUnpacker
 

Detailed Description

A WT_CURSOR handle is the interface to a cursor.

Cursors allow data to be searched, iterated and modified, implementing the CRUD (create, read, update and delete) operations. Cursors are opened in the context of a session. If a transaction is started, cursors operate in the context of the transaction until the transaction is resolved.

Raw data is represented by key/value pairs of WT_ITEM structures, but cursors can also provide access to fields within the key and value if the formats are described in the WT_SESSION::create method.

In the common case, a cursor is used to access records in a table. However, cursors can be used on subsets of tables (such as a single column or a projection of multiple columns), as an interface to statistics, configuration data or application-specific data sources. See WT_SESSION::open_cursor for more information.

Thread safety: A WT_CURSOR handle is not usually shared between threads, see Multithreading for more information.

Member Function Documentation

int com.wiredtiger.db.Cursor.close ( ) throws com.wiredtiger.db.WiredTigerException

Close the cursor.

This releases the resources associated with the cursor handle. Cursors are closed implicitly by ending the enclosing connection or closing the session in which they were opened.

ret = cursor->close(cursor);
Parameters
cursorthe cursor handle
Returns
zero on success and a non-zero error code on failure. See Error Returns for details.
int com.wiredtiger.db.Cursor.compare ( Cursor  other) throws WiredTigerException

Compare this cursor's position to another Cursor.

Returns
The result of the comparison.
byte com.wiredtiger.db.Cursor.getKeyByte ( ) throws WiredTigerPackingException

Retrieve a byte from the cursor's key.

Returns
The requested value.
void com.wiredtiger.db.Cursor.getKeyByteArray ( byte[]  output) throws WiredTigerPackingException

Retrieve a byte array from the cursor's key.

Parameters
outputThe byte array where the returned value will be stored. The array should be large enough to store the entire data item, if not a truncated value will be returned.
void com.wiredtiger.db.Cursor.getKeyByteArray ( byte[]  output,
int  off,
int  len 
) throws WiredTigerPackingException

Retrieve a byte array from the cursor's key.

Parameters
outputThe byte array where the returned value will be stored.
offOffset into the destination buffer to start copying into.
lenThe length should be large enough to store the entire data item, if not a truncated value will be returned.
byte [] com.wiredtiger.db.Cursor.getKeyByteArray ( ) throws WiredTigerPackingException

Retrieve a byte array from the cursor's key.

Returns
The requested value.
int com.wiredtiger.db.Cursor.getKeyInt ( ) throws WiredTigerPackingException

Retrieve an integer from the cursor's key.

Returns
The requested value.
long com.wiredtiger.db.Cursor.getKeyLong ( ) throws WiredTigerPackingException

Retrieve a long from the cursor's key.

Returns
The requested value.
short com.wiredtiger.db.Cursor.getKeyShort ( ) throws WiredTigerPackingException

Retrieve a short integer from the cursor's key.

Returns
The requested value.
String com.wiredtiger.db.Cursor.getKeyString ( ) throws WiredTigerPackingException

Retrieve a string from the cursor's key.

Returns
The requested value.
byte com.wiredtiger.db.Cursor.getValueByte ( ) throws WiredTigerPackingException

Retrieve a byte from the cursor's value.

Returns
The requested value.
void com.wiredtiger.db.Cursor.getValueByteArray ( byte[]  output) throws WiredTigerPackingException

Retrieve a byte array from the cursor's value.

Parameters
outputThe byte array where the returned value will be stored. The array should be large enough to store the entire data item, if not a truncated value will be returned.
void com.wiredtiger.db.Cursor.getValueByteArray ( byte[]  output,
int  off,
int  len 
) throws WiredTigerPackingException

Retrieve a byte array from the cursor's value.

Parameters
outputThe byte array where the returned value will be stored.
offOffset into the destination buffer to start copying into.
lenThe length should be large enough to store the entire data item, if not a truncated value will be returned.
byte [] com.wiredtiger.db.Cursor.getValueByteArray ( ) throws WiredTigerPackingException

Retrieve a byte array from the cursor's value.

Returns
The requested value.
int com.wiredtiger.db.Cursor.getValueInt ( ) throws WiredTigerPackingException

Retrieve an integer from the cursor's value.

Returns
The requested value.
long com.wiredtiger.db.Cursor.getValueLong ( ) throws WiredTigerPackingException

Retrieve a long from the cursor's value.

Returns
The requested value.
short com.wiredtiger.db.Cursor.getValueShort ( ) throws WiredTigerPackingException

Retrieve a short integer from the cursor's value.

Returns
The requested value.
String com.wiredtiger.db.Cursor.getValueString ( ) throws WiredTigerPackingException

Retrieve a string from the cursor's value.

Returns
The requested value.
int com.wiredtiger.db.Cursor.insert ( ) throws WiredTigerException

Insert the cursor's current key/value into the table.

Returns
The status of the operation.
int com.wiredtiger.db.Cursor.next ( ) throws WiredTigerException

Retrieve the next item in the table.

Returns
The result of the comparison.
int com.wiredtiger.db.Cursor.prev ( ) throws WiredTigerException

Retrieve the previous item in the table.

Returns
The result of the comparison.
Cursor com.wiredtiger.db.Cursor.putKeyByte ( byte  value) throws WiredTigerPackingException

Append a byte to the cursor's key.

Parameters
valueThe value to append.
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putKeyByteArray ( byte[]  value) throws WiredTigerPackingException

Append a byte array to the cursor's key.

Parameters
valueThe value to append.
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putKeyByteArray ( byte[]  value,
int  off,
int  len 
) throws WiredTigerPackingException

Append a byte array to the cursor's key.

Parameters
valueThe value to append.
offThe offset into value at which to start.
lenThe length of the byte array.
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putKeyInt ( int  value) throws WiredTigerPackingException

Append an integer to the cursor's key.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putKeyLong ( long  value) throws WiredTigerPackingException

Append a long to the cursor's key.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putKeyShort ( short  value) throws WiredTigerPackingException

Append a short integer to the cursor's key.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putKeyString ( String  value) throws WiredTigerPackingException

Append a string to the cursor's key.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putValueByte ( byte  value) throws WiredTigerPackingException

Append a byte to the cursor's value.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putValueByteArray ( byte[]  value) throws WiredTigerPackingException

Append a byte array to the cursor's value.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putValueByteArray ( byte[]  value,
int  off,
int  len 
) throws WiredTigerPackingException

Append a byte array to the cursor's value.

Parameters
valueThe value to append
offThe offset into value at which to start.
lenThe length of the byte array.
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putValueInt ( int  value) throws WiredTigerPackingException

Append an integer to the cursor's value.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putValueLong ( long  value) throws WiredTigerPackingException

Append a long to the cursor's value.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putValueShort ( short  value) throws WiredTigerPackingException

Append a short integer to the cursor's value.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
Cursor com.wiredtiger.db.Cursor.putValueString ( String  value) throws WiredTigerPackingException

Append a string to the cursor's value.

Parameters
valueThe value to append
Returns
This cursor object, so put calls can be chained.
int com.wiredtiger.db.Cursor.remove ( ) throws WiredTigerException

Remove the cursor's current key/value into the table.

Returns
The status of the operation.
int com.wiredtiger.db.Cursor.reset ( ) throws com.wiredtiger.db.WiredTigerException

Reset the position of the cursor.

Any resources held by the cursor are released, and the cursor's key and position are no longer valid. A subsequent iteration with WT_CURSOR::next will move to the first record, or with WT_CURSOR::prev will move to the last record.

ret = cursor->reset(cursor);
Parameters
cursorthe cursor handle
Returns
zero on success and a non-zero error code on failure. See Error Returns for details.
int com.wiredtiger.db.Cursor.search ( ) throws WiredTigerException

Search for an item in the table.

Returns
The result of the comparison.
SearchStatus com.wiredtiger.db.Cursor.search_near ( ) throws WiredTigerException

Search for an item in the table.

Returns
The result of the comparison.
int com.wiredtiger.db.Cursor.update ( ) throws WiredTigerException

Update the cursor's current key/value into the table.

Returns
The status of the operation.