From c866719063311ab69751a788633c273ae3d03328 Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Fri, 10 May 2024 19:48:54 +0200 Subject: [PATCH 1/2] fix append_triples_no_bnodes in the case of ttl to not chunk it. --- lib/goo/sparql/client.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/goo/sparql/client.rb b/lib/goo/sparql/client.rb index 8f7ad9e1..beec3f05 100644 --- a/lib/goo/sparql/client.rb +++ b/lib/goo/sparql/client.rb @@ -81,26 +81,27 @@ def delete_data_graph(graph) end def append_triples_no_bnodes(graph,file_path,mime_type_in) - bnodes_filter = nil dir = nil response = nil if file_path.end_with?('ttl') bnodes_filter = file_path + file = File.foreach(bnodes_filter) + response = execute_append_request graph, file, mime_type_in else bnodes_filter, dir = bnodes_filter_file(file_path, mime_type_in) - end - chunk_lines = 500_000 # number of line - file = File.foreach(bnodes_filter) - lines = [] - file.each_entry do |line| - lines << line - if lines.size == chunk_lines - response = execute_append_request graph, lines.join, mime_type_in - lines.clear + chunk_lines = 500_000 # number of line + file = File.foreach(bnodes_filter) + lines = [] + file.each_entry do |line| + lines << line + if lines.size == chunk_lines + response = execute_append_request graph, lines.join, mime_type_in + lines.clear + end end + response = execute_append_request graph, lines.join, mime_type_in unless lines.empty? end - response = execute_append_request graph, lines.join, mime_type_in unless lines.empty? unless dir.nil? From 2db3f71967a1e0326ba92b4b3a750f27c35b16c8 Mon Sep 17 00:00:00 2001 From: Syphax bouazzouni Date: Mon, 13 May 2024 14:30:22 +0200 Subject: [PATCH 2/2] use read instead of readlines in the ttl appending to triples store --- lib/goo/sparql/client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/goo/sparql/client.rb b/lib/goo/sparql/client.rb index beec3f05..6e78e65f 100644 --- a/lib/goo/sparql/client.rb +++ b/lib/goo/sparql/client.rb @@ -85,7 +85,7 @@ def append_triples_no_bnodes(graph,file_path,mime_type_in) response = nil if file_path.end_with?('ttl') bnodes_filter = file_path - file = File.foreach(bnodes_filter) + file = File.read(bnodes_filter) response = execute_append_request graph, file, mime_type_in else bnodes_filter, dir = bnodes_filter_file(file_path, mime_type_in)