1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-->
<refentry id="fn_http_ttl_triple">
<refmeta>
<refentrytitle>http_ttl_triple</refentrytitle>
<refmiscinfo>rdf</refmiscinfo>
</refmeta>
<refnamediv>
<refname>http_ttl_triple</refname>
<refpurpose>outputs next triple to ses in TTL serialization.</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_http_ttl_triple">
<funcprototype id="fproto_http_ttl_triple">
<funcdef><function>http_ttl_triple</function></funcdef>
<paramdef>in <parameter>env</parameter> any</paramdef>
<paramdef>in <parameter>arg1</parameter> any</paramdef>
<paramdef>in <parameter>arg2</parameter> any</paramdef>
<paramdef>in <parameter>arg3</parameter> any</paramdef>
<paramdef>in <parameter>ses </parameter> any</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_http_ttl_triple">
<title>Description</title>
<para>Outputs next triple to ses in TTL serialization. This function does not terminate the printed
triple in hope that the next triple will has same "s" or pair of "s" and "p". So "intermediate"
semicolon or comma can be used instead of "trailing" dot.</para>
</refsect1>
<refsect1 id="params_http_ttl_triple">
<title>Parameters</title>
<refsect2><title>env</title>
<para>An array of special format:</para>
<programlisting><![CDATA[
# vector (dict_new (some big size), 0, '', '', '', 0, 0, 0, 0), for ex.:
vector (dict_new (16000), 0, '', '', '', 0, 0, 0, 0);
]]></programlisting>
<para>The first item of the vector is dictionary of declared namespaces. Its size should be big
enough, but not greater than 16000 because the function will never try to create more than
8000 of namespaces for S and O and more than 8000 of namespaces for P and types. Thus
16000 max is possible grand total for all four.
</para>
</refsect2>
<refsect2><title>arg1</title>
<para>Triple subject.</para>
</refsect2>
<refsect2><title>arg2</title>
<para>Triple predicate.</para>
</refsect2>
<refsect2><title>arg3</title>
<para>Triple object.</para>
</refsect2>
<refsect2><title>ses</title>
<para>Session output.</para>
</refsect2>
</refsect1>
<refsect1 id="ret_http_ttl_triple"><title>Return Types</title>
<para>Any</para>
</refsect1>
<refsect1 id="examples_http_ttl_triple">
<title>Examples</title>
<example id="ex_http_ttl_triple">
<para><emphasis>Example 1</emphasis></para>
<programlisting><![CDATA[
CREATE PROCEDURE dump_one_graph
( IN srcgraph VARCHAR ,
IN out_file VARCHAR ,
IN file_length_limit INTEGER := 1000000000
)
{
DECLARE file_name varchar;
DECLARE env, ses any;
DECLARE ses_len,
max_ses_len,
file_len,
file_idx integer;
SET ISOLATION = 'uncommitted';
max_ses_len := 10000000;
file_len := 0;
file_idx := 1;
file_name := sprintf ('%s%06d.ttl', out_file, file_idx);
string_to_file ( file_name || '.graph',
srcgraph,
-2
);
string_to_file ( file_name,
sprintf ( '# Dump of graph <%s>, as of %s\n',
srcgraph,
CAST (NOW() AS VARCHAR)
),
-2
);
env := vector (dict_new (16000), 0, '', '', '', 0, 0, 0, 0);
ses := string_output ();
FOR (SELECT * FROM ( SPARQL DEFINE input:storage ""
SELECT ?s ?p ?o { GRAPH `iri(?:srcgraph)` { ?s ?p ?o } }
) AS sub OPTION (LOOP)) DO
{
http_ttl_triple (env, "s", "p", "o", ses);
ses_len := length (ses);
IF (ses_len > max_ses_len)
{
file_len := file_len + ses_len;
IF (file_len > file_length_limit)
{
http (' .\n', ses);
string_to_file (file_name, ses, -1);
file_len := 0;
file_idx := file_idx + 1;
file_name := sprintf ('%s%06d.ttl', out_file, file_idx);
string_to_file ( file_name,
sprintf ( '# Dump of graph <%s>, as of %s (part %d)\n',
srcgraph,
CAST (NOW() AS VARCHAR),
file_idx),
-2
);
env := vector (dict_new (16000), 0, '', '', '', 0, 0, 0, 0);
}
ELSE
string_to_file (file_name, ses, -1);
ses := string_output ();
}
}
IF (LENGTH (ses))
{
http (' .\n', ses);
string_to_file (file_name, ses, -1);
}
}
;
]]></programlisting>
<para><emphasis>Example 2</emphasis></para>
<programlisting><![CDATA[
create procedure dump_rdftriples_to_ttl(inout triples any, inout ses any)
{
declare env any;
declare tcount, tctr integer;
tcount := length (triples);
if (0 = tcount)
{
http ('# Empty TURTLE\n', ses);
return;
}
env := vector (dict_new (__min (tcount, 16000)), 0, '', '', '', 0, 0, 0, 0);
{ whenever sqlstate '*' goto end_pred_sort;
rowvector_subj_sort (triples, 1, 1);
end_pred_sort: ;
}
{ whenever sqlstate '*' goto end_subj_sort;
rowvector_subj_sort (triples, 0, 1);
end_subj_sort: ;
}
for (tctr := 0; tctr < tcount; tctr := tctr + 1)
{
http_ttl_triple (env, triples[tctr][0], triples[tctr][1], triples[tctr][2], ses);
}
http (' .', ses);
}
;
]]></programlisting>
</example>
</refsect1>
<refsect1 id="seealso_http_ttl_triple">
<title>See Also</title>
<para><link linkend="fn_http_nt_triple"><function>http_nt_triple()</function></link></para>
<para><link linkend="fn_rdf_audit_metadata"><function>DB.DBA.RDF_AUDIT_METADATA()</function></link></para>
<para><link linkend="fn_rdf_backup_metadata"><function>DB.DBA.RDF_BACKUP_METADATA()</function></link></para>
<para><link linkend="fn_rdf_load_rdfxml"><function>DB.DBA.RDF_LOAD_RDFXML()</function></link></para>
<para><link linkend="fn_rdf_load_rdfxml_mt"><function>DB.DBA.RDF_LOAD_RDFXML_MT()</function></link></para>
<para><link linkend="fn_ttlp_mt"><function>TTLP_MT()</function></link></para>
<para><link linkend="fn_ttlp_mt_local_file"><function>TTLP_MT_LOCAL_FILE()</function></link></para>
</refsect1>
</refentry>
|