kyotocabinet.Cursor

Module kyotocabinet :: Class Cursor |
[frames] | no frames]

# Class Cursor

Interface of cursor to indicate a record.

Instance Methods
disable(self) Disable the cursor. |
accept(self, visitor, writable=True, step=False) Accept a visitor to the current record. |
set_value(self, value, step=False) Set the value of the current record. |
remove(self) Remove the current record. |
get_key(self, step=False) Get the key of the current record. |
get_key_str(self, step=False) Get the key of the current record. |
get_value(self, step=False) Get the value of the current record. |
get_value_str(self, step=False) Get the value of the current record. |
get(self, step=False) Get a pair of the key and the value of the current record. |
get_str(self, step=False) Get a pair of the key and the value of the current record. |
seize(self) Get a pair of the key and the value of the current record and remove it atomically. |
seize_str(self) Get a pair of the key and the value of the current record and remove it atomically. |
jump(self, key=None) Jump the cursor to a record for forward scan. |
jump_back(self, key=None) Jump the cursor to a record for backward scan. |
step(self) Step the cursor to the next record. |
step_back(self) Step the cursor to the previous record. |
db(self) Get the database object. |
error(self) Get the last happened error. |
__repr__(self) Get the representing expression. |
__str__(self) Get the string expression. |
__next__(self) Get the next key. |

Method Details

### disable(self) |
Disable the cursor. Returns: always None. Note: This method should be called explicitly when the cursor is no longer in use.

### accept(self, visitor, writable=True, step=False) |
Accept a visitor to the current record. Parameters: `visitor` - a visitor object which implements the Visitor interface, or a function object which receives the key and the value. `writable` - true for writable operation, or false for read-only operation. `step` - true to move the cursor to the next record, or false for no move. Returns: true on success, or false on failure. Note: The operation for each record is performed atomically and other threads accessing the same record are blocked. To avoid deadlock, any explicit database operation must not be performed in this method.

### set_value(self, value, step=False) |
Set the value of the current record. Parameters: `value` - the value. `step` - true to move the cursor to the next record, Returns: true on success, or false on failure.

### remove(self) |
Remove the current record. Returns: true on success, or false on failure. Note: If no record corresponds to the key, false is returned. The cursor is moved to the next record implicitly.

### get_key(self, step=False) |
Get the key of the current record. Parameters: `step` - true to move the cursor to the next record, or false for no move. Returns: the key of the current record, or None on failure. Note: If the cursor is invalidated, None is returned.

### get_key_str(self, step=False) |
Get the key of the current record. Note: Equal to the original Cursor::get_key method except that the return value is string.

### get_value(self, step=False) |
Get the value of the current record. Parameters: `step` - true to move the cursor to the next record, or false for no move. Returns: the value of the current record, or None on failure. Note: If the cursor is invalidated, None is returned.

### get_value_str(self, step=False) |
Get the value of the current record. Note: Equal to the original Cursor::get_value method except that the return value is string.

### get(self, step=False) |
Get a pair of the key and the value of the current record. Parameters: `step` - true to move the cursor to the next record, or false for no move. Returns: a pair of the key and the value of the current record, or None on failure. Note: If the cursor is invalidated, None is returned.

### get_str(self, step=False) |
Get a pair of the key and the value of the current record. Note: Equal to the original Cursor::get method except that the return value is string.

### seize(self) |
Get a pair of the key and the value of the current record and remove it atomically. Returns: a pair of the key and the value of the current record, or None on failure. Note: If the cursor is invalidated, None is returned. The cursor is moved to the next record implicitly.

### seize_str(self) |
Get a pair of the key and the value of the current record and remove it atomically. Note: Equal to the original Cursor::seize method except that the return value is string.

### jump(self, key=None) |
Jump the cursor to a record for forward scan. Parameters: `key` - the key of the destination record. If it is None, the destination is the first record. Returns: true on success, or false on failure.

### jump_back(self, key=None) |
Jump the cursor to a record for backward scan. Parameters: `key` - the key of the destination record. If it is None, the destination is the last record. Returns: true on success, or false on failure. Note: This method is dedicated to tree databases. Some database types, especially hash databases, will provide a dummy implementation.

### step(self) |
Step the cursor to the next record. Returns: true on success, or false on failure.

### step_back(self) |
Step the cursor to the previous record. Returns: true on success, or false on failure. Note: This method is dedicated to tree databases. Some database types, especially hash databases, may provide a dummy implementation.

### db(self) |
Get the database object. Returns: the database object.

### error(self) |
Get the last happened error. Returns: the last happened error.

### __repr__(self) (Representation operator) |
Get the representing expression. Returns: the representing expression.

### __str__(self) (Informal representation operator) |
Get the string expression. Returns: the string expression.

### __next__(self) |
Get the next key. Returns: the next key, or None on failure.