Skip to content

Commit 25b3214

Browse files
committed
Reformat output of the data-loading process - much improved
1 parent 7ab3b8e commit 25b3214

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

run/fill-db

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,52 @@ echo "Setting up the DB in '$db_dir' (temp dir: '$tmp_db_dir') ..."
163163

164164
rm -Rf "$tmp_db_dir"
165165
mkdir -p "$tmp_db_dir"
166+
echo "Loading data into the DB ..."
166167
time find \
167168
"$ontology_ttls_root" \
168169
"$data_ttls_root" \
169170
-name "*.ttl" \
170171
-print0 \
171172
| xargs -0 "$jena_db_data_injector" \
172173
--loc "$tmp_db_dir" \
173-
--syntax turtle
174+
--syntax turtle \
175+
2>&1 | awk -v ORS='' \
176+
'
177+
# This AWK script only serves to reformat the output
178+
# of the loading procedure into a less spammy
179+
# and more informative one.
180+
BEGIN {
181+
files_total = 0;
182+
tuples_total = 0;
183+
}
184+
/Start:/ { printf("\n%s\n", $0); }
185+
/End file:/ { printf("."); }
186+
/Finished:/ {
187+
printf("\n%s\n", $0)
188+
189+
vals = $0
190+
gsub(/.* Finished: /, "", vals)
191+
192+
files_batch = vals
193+
gsub(/ files: .*/, "", files_batch)
194+
gsub(/,/, "", files_batch)
195+
files_total = files_total + (files_batch + 0)
196+
197+
tuples_batch = vals
198+
gsub(/.* files: /, "", tuples_batch)
199+
gsub(/ .*/, "", tuples_batch)
200+
gsub(/,/, "", tuples_batch)
201+
tuples_total = tuples_total + (tuples_batch + 0);
202+
203+
printf("Files total: %d\n", files_total);
204+
printf("Tuples total: %d\n", tuples_total);
205+
}
206+
END {
207+
print("\nTotal loading time:");
208+
# ... is printed by the CLi command "time"
209+
}
210+
'
211+
echo
174212
if [ -e "$db_dir" ]
175213
then
176214
rm -Rf "$bak_db_dir"

0 commit comments

Comments
 (0)