View Source erlfdb_range_iterator (erlfdb v0.3.4)

An iterator interface over GetRange and GetMappedRange.

The iterator is an alternative implmentation to erlfdb:get_range/4 and erlfdb:wait_for_all_interleaving/3. The database mechanics are equivalent, but the iterator allows you to control when each wait actually happens.

Remember that FoundationDB transaction execution time is limited to 5 seconds, so you must take care not to delay your iteration.

To use the iterator,

  1. erlfdb_range_iterator:start/4: Sends the first GetRange request to the database server.
  2. erlfdb_iterator.next/1: Waits for the result of the GetRange request. Then issues another GetRange request to the database server.
  3. erlfdb_iterator.stop/1: Cancels the active future, if one exists.

Summary

Functions

Gets the active future from the iterator's internal state.

Starts the iterator.

Types

-type page() :: [erlfdb:kv()] | [erlfdb:mapped_kv()].
-type state() ::
          #state{tx :: term(),
                 start_key :: term(),
                 end_key :: term(),
                 mapper :: term(),
                 limit :: term(),
                 target_bytes :: term(),
                 streaming_mode :: term(),
                 iteration :: term(),
                 snapshot :: term(),
                 reverse :: term(),
                 future :: term()}.

Functions

-spec get_future(state()) -> undefined | erlfdb:future().

Gets the active future from the iterator's internal state.

You needn't call this function for normal use of the iterator.

-spec handle_next(state()) -> {halt, state()} | {cont, [page()], state()}.
-spec handle_stop(state()) -> ok.
Link to this function

start(Tx, StartKey, EndKey)

View Source

Starts the iterator.

Equivalent to start(Tx, StartKey, EndKey, []).

Link to this function

start(Tx, StartKey, EndKey, Options)

View Source

Starts the iterator.

Sends the first GetRange request to the database server.