The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ElasticSearchX::Sequence::Iterator - Fast integer ID sequences with ElasticSearch

VERSION

version 0.01

SYNOPSIS

    my $it = $seq->sequence('mail_id');
    say  $it->next;
    # 1

    $mail_id->set(1000);
    say $it->next
    # 1000

DESCRIPTION

ElasticSearchX::Sequence::Iterators are returned by ElasticSearchX::Sequence, which is the "controller class". An Iterator is a "named sequence" and the IDs it returns will be unique.

METHODS

new()

    my $it = ElasticSearchX::Sequence::Iterator->new(
        sequence => $seq,       # ElasticSearchX::Sequence instance, required
        name     => 'mail_id',  # name of iterator, required
        size     => 100,        # number of IDs to reserve at a time, default 100
    );

new() returns a new instance of ElasticSearchX::Sequence::Iterator.

Normally, you would never need to call this method directly, but instead you would use "sequence()" in ElasticSearchX::Sequence.

IDs are reserved in blocks of size (default 100).

next()

    $id = $it->next;

Returns the next ID in the sequence.

release()

    $id = $it->release($id);

Returns $id to allow it to be reused.

NOTE: You must be certain that the ID hasn't already been used by your application. Also, there is no guarantee that your released ID will be reused. It is "released" only to the current iterator - this is not application wide.

set()

    $it->set($new_id)

This can be used to set a new HIGHER ID for this iterator. You cannot reset the iterator to a lower number without deleting the index.

name()

    $name = $it->name()

Read-only getter for the iterator name.

sequence()

    $seq = $it->sequence();

Read-only getter for the associated ElasticSearchX::Sequence instance.

SEE ALSO

ElasticSearchX::Sequence, ElasticSearch, http://www.elasticsearch.org

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Clinton Gormley.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.