Jiro Nishiguchi > RocksDB-0.02 > RocksDB::Iterator

Download:
RocksDB-0.02.tar.gz

Annotate this POD

Website

View/Report Bugs
Source   Latest Release: RocksDB-0.03

NAME ^

RocksDB::Iterator - rocksdb::Iterator object

SYNOPSIS ^

  use RocksDB;

  my $db = RocksDB->new('/path/to/db');
  my $iter = $db->new_iterator->seek_to_first;
  while (my ($key, $value) = $iter->each) {
      printf "%s: %s\n", $key, $value;
  }
  # in reverse order
  $iter->seek_to_last;
  while (my ($key, $value) = $iter->reverse_each) {
      printf "%s: %s\n", $key, $value;
  }

  # low-level interface
  for ($iter->seek_to_first; $iter->valid; $iter->next) {
      printf "%s: %s\n", $iter->key, $iter->value;
  }
  for ($iter->seek_to_last; $iter->valid; $iter->prev) {
      printf "%s: %s\n", $iter->key, $iter->value;
  }
  $iter->seek('key');

DESCRIPTION ^

RocksDB::Iterator is a rocksdb::Iterator object.

METHODS ^

$iter->valid() :Bool

An iterator is either positioned at a key/value pair, or not valid. This method returns true iff the iterator is valid.

$iter->seek_to_first() :LevelDB::Iterator

Position at the first key in the source. The iterator is valid() after this call iff the source is not empty. Return $self. It's useful for method chain as below.

  my $iter = $db->new_iterator->seek_to_first;

$iter->seek_to_last() :LevelDB::Iterator

Position at the last key in the source. The iterator is valid() after this call iff the source is not empty.

$iter->seek($key :Str) :RocksDB::Iterator

Position at the first key in the source that at or past target The iterator is valid() after this call iff the source contains an entry that comes at or past target.

$iter->next() :Undef

Moves to the next entry in the source. After this call, valid() is true iff the iterator was not positioned at the last entry in the source. Raise error if the iterator is not valid().

$iter->prev() :Undef

Moves to the previous entry in the source. After this call, Valid() is true iff the iterator was not positioned at the first entry in source. Raise error if the iterator is not valid().

$iter->key() :Str

Return the key for the current entry. The underlying storage for the returned slice is valid only until the next modification of the iterator. Return undef if the iterator is not valid().

$iter->value() :Str

Return the value for the current entry. The underlying storage for the returned slice is valid only until the next modification of the iterator. Return undef if the iterator is not valid().

$iter->each() :(Str, Str)

If the iterator is valid(), return key-value pair and call next(). Otherwise return empty list.

$iter->reverse_each() :(Str, Str)

If the iterator is valid(), return key-value pair and call prev(). Otherwise return empty list.

SEE ALSO ^

RocksDB

AUTHOR ^

Jiro Nishiguchi <jiro@cpan.org>

syntax highlighting: