RDF::T...erator(3pm)
π 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 aCODEreference that acts as an iterator β it hands you successive items every time it's called, and returnsundefonce the iterator is exhausted. that's the deal. And$typeshould 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$formatyou specified β¨. If$formatis 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_resultnextβ 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 tonext. lowkey the politest method here.currentβ returns the current item in the stream. where we at right now.endfinishedβ 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 toeachbeyond the callback function will be passed as supplemental arguments to the callback function. so like,eachsays "here's your item, and also here's your extra lil args" π
π FUNCTIONS π
sgrep { COND } $streamsmap { EXPR } $streamswatch { EXPR } $stream
π DEPENDENCIES π
JSONScalar::UtilXML::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 π
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 fromperl v5.38.2, dated2024-01-13, and it's theRDF::T...erator(3pm)manual β go forth and iterate, you absolute main character π¦πβ¨
π¦ where this page comes from
- debian trixie: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librdf-trine-perl 1.019-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms