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

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

πŸ’– 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 ) and new ( \&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 returns undef once 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 $outer iterator should be used to determine the result ordering. πŸ‘‘
  • If one iterator is much smaller than the other, it should likely be used as the $inner iterator, 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 a RDF::Trine::Iterator::Graph with the statements of the stream. Two whole modes, bestie:
    • If $pattern, an RDF::Trine::Pattern object, is given as an argument, each of its triples are instantiated with variable bindings from each row of the iterator, and returned as RDF::Trine::Statement objects from a new RDF::Trine::Iterator::Graph iterator.
    • If 3 variable @names are supplied, their corresponding variable bindings in each row of the iterator are used (in order) as the subject, predicate, and object of new RDF::Trine::Statement objects and returned from a new RDF::Trine::Iterator::Graph iterator.
  • 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 _new to re-create this stream (assuming the same closure as the first argument). Re-create the whole girl from scratch. 🧚

🫢 DEPENDENCIES 🫢

  • JSON
  • Scalar::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 (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