logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Stone::Cursor - Traverse tags and values of a Stone

Author

       Lincoln D. Stein <lstein@cshl.org>.

Description

       Boulder::Cursor is a utility class that allows you to create one or more iterators across a Stone object.
       This is used for traversing large Stone objects in order to identify or modify portions of the record.

   CLASSMETHODS
       Boulder::Cursor->new($stone)
           Return  a  new  Boulder::Cursor  over  the  specified Stone object.  This will return an error if the
           object is not a Stone or a descendent. This  method  is  usually  not  called  directly,  but  rather
           indirectly via the Stone cursor() method:

             my $cursor = $stone->cursor;

   OBJECTMETHODS
       $cursor->each()
           Iterate  over  the  attached Stone.  Each iteration will return a two-valued list consisting of a tag
           path and a value.  The tag path is of a form that can be used with Stone::index() (in fact, a  cursor
           is  used  internally  to  implement  the Stone::dump() method.  When the end of the Stone is reached,
           "each()" will return an empty list, after which it will start over again from the beginning.  If  you
           attempt  to  insert or delete from the stone while iterating over it, all attached cursors will reset
           to the beginnning.

           For example:

                   $cursor = $s->cursor;
                   while (($key,$value) = $cursor->each) {
                      print "$value: BOW WOW!\n" if $key=~/pet/;
                   }

       $cursor->reset()
           This resets the cursor back to the beginning of the associated Stone.

Name

       Stone::Cursor - Traverse tags and values of a Stone

See Also

       Boulder, Stone

perl v5.34.0                                       2022-06-08                                 Stone::Cursor(3pm)

Synopsis

        use Boulder::Store;
       $store = Boulder::Store->new('./soccer_teams');

        my $stone = $store->get(28);
        $cursor = $stone->cursor;
        while (my ($key,$value) = $cursor->each) {
          print "$value: Go Bluejays!\n" if $key eq 'State' and $value eq 'Katonah';
        }

See Also