RDF::T...ndings(3pm)
π RDF::Trine::Iterator::Bindings β the bindings iterator, bestie edition β¨
Okay so welcome to RDF::Trine::Iterator::Bindings(3pm) from the User Contributed Perl Documentation, and honestly? She's a whole vibe. This class is the Iterator class for bindings query results β like, SPARQL results but make it a stream. π
πΈ VERSION πΈ
This document describes RDF::Trine::Iterator::Bindings version 1.019. Yes, we're on 1.019, no cap. π
β¨ SYNOPSIS β¨
Here's the whole moment, copy it exactly, don't be shy:
use RDF::Trine::Iterator::Bindings;
my $iterator = RDF::Trine::Iterator::Bindings->new( \&data, \@names );
while (my $row = $iterator->next) {
# $row is a HASHref containing variable name -> RDF Term bindings
my @vars = keys %$row;
print $row->{ 'var' }->as_string;
}
Like, you make the iterator, you next through the rows, each $row is a HASHref mapping variable name β RDF Term bindings, and you can pull the vars out with keys. That's it, that's the whole plot. π¦
π METHODS π
So beyond the methods documented right here below, this class inherits methods from the RDF::Trine::Iterator class. Family tree moment. π³
new ( \@results, \@names, %args )andnew ( \&results, \@names, %args )β returns a new SPARQL Result iterator object, periodt. The results you hand over have to be either a reference to an array containing results, or a CODE reference that acts as an iterator β it returns successive items every time you call it, and returnsundefonce the iterator is exhausted. That's the contract, bestie. π€materializeβ returns a materialized version of the current binding iterator. Heads up though: the materialization process will leave this iterator empty, so the materialized iterator you get back is the one you should use for any future need for the iterator's data. She gave everything she had and now she's β¨emptyβ¨. πproject ( @columns )β returns a new stream that projects the current bindings to only the given columns. Filtering, but make it structural. π₯join_streams ( $stream, $stream )β performs a natural, nested loop join of the two streams, returning a new stream of joined results. Two streams walk into a join... πnested_loop_join ( $outer, $inner )β also performs a natural, nested loop join of the two streams, returning a new stream of joined results. Same energy, but this one comes with receipts. π
Note that the values from the $inner iterator are fully materialized for this join, and the results of the join are in the order of values from the $outer iterator. Which lowkey suggests:
- If sorting needs to be preserved, the
$outeriterator should be used to determine the result ordering. π - If one iterator is much smaller than the other, it should likely be used as the
$inneriterator, since materialization will require less total memory. π§
sorted_byβ the manpage gives this one no description at all. She's mysterious, she's giving main character energy, and we simply do not elaborate. πbinding_value_by_name ( $name )β returns the binding of the named variable in the current result.binding_value ( $i )β returns the binding of the$i-th variable in the current result.binding_valuesβ returns a list of the binding values from the current result.binding_namesβ returns a list of the binding names.binding_name ( $i )β returns the name of the$i-th result column.bindings_countβ returns the number of variable bindings in the current result.is_bindingsβ returns true if the underlying result is a set of variable bindings. Vibe check passed. βas_json ( $max_size )β returns a JSON serialization of the stream data.as_xml ( $max_size )β returns an XML serialization of the stream data.as_string ( $max_size [, \$count] )β returns a string table serialization of the stream data.as_statements ( $pattern | @names )β returns aRDF::Trine::Iterator::Graphwith the statements of the stream. Two whole modes, bestie:- If
$pattern, anRDF::Trine::Patternobject, is given as an argument, each of its triples are instantiated with variable bindings from each row of the iterator, and returned asRDF::Trine::Statementobjects from a newRDF::Trine::Iterator::Graphiterator. - If 3 variable
@namesare supplied, their corresponding variable bindings in each row of the iterator are used (in order) as the subject, predicate, and object of newRDF::Trine::Statementobjects and returned from a newRDF::Trine::Iterator::Graphiterator.
- If
print_xml ( $fh, $max_size )β prints an XML serialization of the stream data to the filehandle$fh.construct_argsβ returns the arguments necessary to pass to the stream constructor_newto re-create this stream (assuming the same closure as the first argument). Re-create the whole girl from scratch. π§
π«Ά DEPENDENCIES π«Ά
JSONScalar::Util
Her ride-or-dies. Can't run without 'em. π
π BUGS π
Please report any bugs or feature requests to through the GitHub web interface at <https://github.com/kasei/perlrdf/issues>. Not me begging you to file an issue... actually yes, that's exactly what this is. π
π AUTHOR π
Gregory Todd Williams <gwilliams@cpan.org> β the icon, the legend, the moment. π
π 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. Free software, free as a butterfly. π¦
And that's the whole page, bestie β this doc ships with perl v5.38.2 and is dated 2024-01-13. Slay, go write some iterators, and remember: materialize responsibly. π
β¨πΈ
π¦ 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