line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
AtteanX::Serializer::SPARQLTSV - SPARQL Results TSV Serializer |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 VERSION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This document describes AtteanX::Serializer::SPARQLTSV version 0.032 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Attean; |
12
|
|
|
|
|
|
|
my $s = Attean->get_serializer('SPARQLTSV')->new(); |
13
|
|
|
|
|
|
|
$s->serialize_iter_to_io( $fh, $iter ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
... |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=over 4 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=item C<< canonical_media_type >> |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=item C<< file_extensions >> |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=back |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over 4 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
3
|
|
7636
|
use v5.14; |
|
3
|
|
|
|
|
11
|
|
36
|
3
|
|
|
3
|
|
24
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
120
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use Moo; |
39
|
3
|
|
|
3
|
|
17
|
use Types::Standard qw(Str ArrayRef); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
24
|
|
40
|
3
|
|
|
3
|
|
990
|
use Encode qw(encode); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
30
|
|
41
|
3
|
|
|
3
|
|
1753
|
use Scalar::Util qw(blessed); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
147
|
|
42
|
3
|
|
|
3
|
|
20
|
use Attean::ListIterator; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
129
|
|
43
|
3
|
|
|
3
|
|
17
|
use List::MoreUtils qw(any); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
86
|
|
44
|
3
|
|
|
3
|
|
15
|
use namespace::clean; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
25
|
|
45
|
3
|
|
|
3
|
|
2768
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
28
|
|
46
|
|
|
|
|
|
|
has 'canonical_media_type' => (is => 'ro', isa => Str, init_arg => undef, default => 'text/tab-separated-values'); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item C<< media_types >> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Returns a list of media types that identify the format produced by this serializer. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return [qw(text/tab-separated-values)]; |
55
|
|
|
|
|
|
|
} |
56
|
9
|
|
|
9
|
1
|
44
|
|
57
|
|
|
|
|
|
|
=item C<< file_extensions >> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns a list of file extensions associated with the serialized format. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item C<< serialize_iter_to_io( $fh, $iterator ) >> |
65
|
6
|
|
|
6
|
1
|
26
|
|
66
|
|
|
|
|
|
|
Serializes the L<Attean::API::Binding> objects from C<< $iterator >> to the |
67
|
|
|
|
|
|
|
L<IO::Handle> object C<< $fh >>. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $self = shift; |
72
|
|
|
|
|
|
|
my $io = shift; |
73
|
|
|
|
|
|
|
my $iter = shift; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my @vars = @{ $iter->variables }; |
76
|
|
|
|
|
|
|
$io->print(join("\t", map { "?$_" } @vars) . "\n"); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
while (my $t = $iter->next()) { |
79
|
|
|
|
|
|
|
my @strings = map { blessed($_) ? $_->ntriples_string : '' } map { $t->value($_) } @vars; |
80
|
|
|
|
|
|
|
$io->print(join("\t", @strings) . "\n"); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
return; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item C<< serialize_iter_to_bytes( $iterator ) >> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Serializes the L<Attean::API::Binding> objects from C<< $iterator >> |
88
|
|
|
|
|
|
|
and returns the serialization as a UTF-8 encoded byte string. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $self = shift; |
93
|
|
|
|
|
|
|
my $iter = shift; |
94
|
|
|
|
|
|
|
my $data = ''; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my @vars = @{ $iter->variables }; |
97
|
|
|
|
|
|
|
$data .= join("\t", map { "?$_" } @vars) . "\n"; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
while (my $t = $iter->next()) { |
100
|
|
|
|
|
|
|
my @strings = map { blessed($_) ? $_->ntriples_string : '' } map { $t->value($_) } @vars; |
101
|
|
|
|
|
|
|
my $str = join("\t", @strings); |
102
|
|
|
|
|
|
|
$data .= $str . "\n"; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
return encode('UTF-8', $data); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
with 'Attean::API::ResultSerializer', 'Attean::API::AppendableSerializer'; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 BUGS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
118
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf/issues>. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 COPYRIGHT |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. This |
127
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
128
|
|
|
|
|
|
|
the same terms as Perl itself. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |