RDF::T...erator(3pm)

πŸ“¦
version 1.019 Β· 7 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– RDF::Trine::Iterator β€” the iterator class for SPARQL query results πŸ’–

okay bestie, so this is RDF::Trine::Iterator, a Perl module (manual page RDF::Trine::Iterator(3pm)), and honestly? she's giving stream energy. She hands you SPARQL query results one at a time and she does it beautifully. no cap.


✨ VERSION ✨

This document describes RDF::Trine::Iterator version 1.019. yes, she's a real one.


🌸 SYNOPSIS 🌸

use RDF::Trine::Iterator;
my $iterator = RDF::Trine::Iterator->new( \&data, 'bindings', \@names );
while (my $row = $iterator->next) {
    my @vars        = keys %$row;
    # do something with @vars
}

like. look at her. loop, grab a row, do something with @vars, periodt. πŸ’…


πŸ¦‹ METHODS πŸ¦‹

  • new ( \@results, $type, \@names, %args )
  • new ( \&results, $type, \@names, %args ) β€” bestie, this is the glow-up moment: she returns a brand new SPARQL Result iterator object πŸŽ€. Your results have to be either a reference to an array holding the results or a CODE reference that acts as an iterator β€” it hands you successive items every time it's called, and returns undef once the iterator is exhausted. that's the deal. And $type should be one of: bindings, boolean, graph.
  • type β€” tells you the underlying result type (boolean, graph, bindings). the vibe check of result types.
  • is_boolean β€” returns true if the underlying result is a boolean value. is she a yes-or-no girlie? πŸ’œ
  • is_bindings β€” returns true if the underlying result is a set of variable bindings.
  • is_graph β€” returns true if the underlying result is an RDF graph.
  • to_string ( $format ) β€” returns a string representation of the stream data in whatever $format you specified ✨. If $format is missing, it defaults to XML serialization. Other options are:
  • from_string ( $xml ) β€” returns a new iterator built from the XML string you hand her, in the SPARQL XML Results format. give her a string, get a stream 🫢
  • from_bytes ( $xml ) β€” same energy, but returns a new iterator from the supplied XML byte sequence (and okay listen: not character data, bestie, bytes, I said what I said) in the SPARQL XML Results format.
  • from_json ( $json )
  • next_result
  • next β€” returns the next item in the stream. that's it, that's the whole job, and she eats every time πŸ”₯
  • peek β€” returns the next value from the iterator without consuming it πŸ‘€. The value stays in the queue until the next call to next. lowkey the politest method here.
  • current β€” returns the current item in the stream. where we at right now.
  • end
  • finished β€” returns true if the end of the stream has been reached, false otherwise. is it over? 😭
  • open β€” returns true if the first element of the stream has been retrieved, false otherwise.
  • close β€” closes the stream πŸšͺ. Any future attempts to retrieve data from the stream will act as if the stream had been exhausted. she's done, don't come back.
  • concat ( $stream ) β€” returns a new stream resulting from the concatenation of the referant and the argument streams 🧚. The new stream uses the stream type, and optional binding names and "<%args"> from the referant stream. (yes, that's exactly how it's written, no I will not be fixing it, the facts stay facts.)
  • seen_count β€” returns the count of elements that have been returned by this iterator at the point of invocation. a little tally of how many she's given you so far πŸ’–
  • get_boolean β€” returns the boolean value of the first item in the stream.
  • get_all β€” returns an array containing all the items in the stream. the whole haul, no crumbs left 🌈
  • construct_args β€” returns the arguments necessary to pass to a stream constructor to re-create this stream (assuming the same closure as the first argument). she can rebuild herself, iconic behavior.
  • each ( \&callback ) β€” Calls the callback function once for each item in the iterator, passing the item as an argument to the function. Any arguments to each beyond the callback function will be passed as supplemental arguments to the callback function. so like, each says "here's your item, and also here's your extra lil args" πŸŽ€

πŸ‘‘ FUNCTIONS πŸ‘‘

  • sgrep { COND } $stream
  • smap { EXPR } $stream
  • swatch { EXPR } $stream

πŸ“ DEPENDENCIES πŸ“

  • JSON
  • Scalar::Util
  • XML::SAX

πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests to through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. (and yes, "to through" β€” she said it, I'm not editing her, respect the original πŸ™ˆ)


⭐ AUTHOR ⭐

Gregory Todd Williams "<gwilliams@cpan.org>"


Copyright (c) 2006-2012 Gregory Todd Williams. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


πŸ’Œ and that's the whole page bestie!! this one came from perl v5.38.2, dated 2024-01-13, and it's the RDF::T...erator(3pm) manual β€” go forth and iterate, you absolute main character πŸ¦‹πŸ’œβœ¨
πŸ“¦ where this page comes from