View Source erlfdb_iterator behaviour (erlfdb v0.3.4)

A generic iterator behaviour, useful for streaming results from the database.

Summary

Functions

Executes a handle_call on the iterator.

Identifies the module and the specific state of the iterator implementation.

Creates an iterator.

Progresses the iterator one step.

Runs all iterators to completion.

Runs the iterator to completion.

Stops the iterator.

Types

-type iterator() :: {module(), state()}.
-type result() :: term().
-type state() :: term().

Callbacks

Link to this callback

handle_call/3

View Source (optional)
-callback handle_call(term(), term(), state()) -> {reply, term(), state()}.
-callback handle_next(state()) ->
                         {cont, [result()], state()} | {halt, [result()], state()} | {halt, state()}.
-callback handle_stop(state()) -> ok.

Functions

-spec call(iterator(), term()) -> {term(), iterator()}.

Executes a handle_call on the iterator.

-spec module_state(iterator()) -> {module(), state()}.

Identifies the module and the specific state of the iterator implementation.

-spec new(module(), state()) -> iterator().

Creates an iterator.

-spec next(iterator()) ->
              {cont, [result()], iterator()} | {halt, [result()], iterator()} | {halt, iterator()}.

Progresses the iterator one step.

-spec pipeline([iterator()]) -> [{[result()], iterator()}].

Runs all iterators to completion.

Caller must call stop/1 to terminate the iterators.

-spec run(iterator()) -> {[result()], iterator()}.

Runs the iterator to completion.

Returns the list of results and the state of the iterator.

Caller must call stop/1 to terminate the iterator.

-spec stop(iterator()) -> ok.

Stops the iterator.