-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoxigraph-count.mk
115 lines (89 loc) · 4.53 KB
/
oxigraph-count.mk
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
#
# Some basic SPARQL statements generating all sorts of counts or metrics for the OxiGraph database in this project.
#
ifndef _MK_OXIGRAPH_COUNT_MK_
_MK_OXIGRAPH_COUNT_MK_ := 1
#$(info ---> .make/oxigraph-count.mk)
ifndef GIT_ROOT
GIT_ROOT := $(shell git rev-parse --show-toplevel 2>/dev/null)
endif
ifndef MK_DIR
MK_DIR := $(GIT_ROOT)/.make
endif
include $(MK_DIR)/jq.mk
include $(MK_DIR)/oxigraph.mk
include $(MK_DIR)/oxigraph-load.mk
OXIGRAPH_MINIMUM_NUMBER_OF_SUBJECTS := 125
OXIGRAPH_SPARQL_COUNT_ROOT := $(GIT_ROOT)/sparql/count
SPARQL_COUNT_TESTS := $(wildcard $(OXIGRAPH_SPARQL_COUNT_ROOT)/count-*.sparql)
SPARQL_COUNT_RESULT_FILES1 := $(SPARQL_COUNT_TESTS:.sparql=-before-transformation.tmp.csv)
SPARQL_COUNT_RESULT_FILES2 := $(SPARQL_COUNT_TESTS:.sparql=-after-transformation.tmp.csv)
OXIGRAPH_COUNTS_REPORT1 := $(TEST_TMP)/report-counts-before-transformation.csv
OXIGRAPH_COUNTS_REPORT2 := $(TEST_TMP)/report-counts-after-transformation.csv
count%-before-transformation.tmp.csv: count%.sparql
@file="$$(echo $? | sed 's@$(GIT_ROOT)/@@g')" ; printf "Counting: $(green)$${file}$(normal)\n"
@$(OXIGRAPH_BIN) --location $(OXIGRAPH_LOCATION) query --query-file $? --results-file $@
count%-after-transformation.tmp.csv: count%.sparql
@file="$$(echo $? | sed 's@$(GIT_ROOT)/@@g')" ; printf "Counting: $(green)$${file}$(normal)\n"
@$(OXIGRAPH_BIN) --location $(OXIGRAPH_LOCATION) query --query-file $? --results-file $@
.PHONY: oxigraph-count-clean
oxigraph-count-clean: _oxigraph-count1-clean _oxigraph-count2-clean
@rm -f $(OXIGRAPH_SPARQL_COUNT_ROOT)/*.tmp.csv
.PHONY: _oxigraph-count1-clean
_oxigraph-count1-clean:
# @echo "Cleaning up count1 flag files"
@rm -f $(OXIGRAPH_COUNTS_REPORT1) $(SPARQL_COUNT_RESULT_FILES1) >/dev/null 2>&1 || true
.PHONY: _oxigraph-count2-clean
_oxigraph-count2-clean:
# @echo "Cleaning up count2 flag files"
@rm -f $(OXIGRAPH_COUNTS_REPORT2) $(SPARQL_COUNT_RESULT_FILES2) >/dev/null 2>&1 || true
#.INTERMEDIATE: $(OXIGRAPH_COUNTS_REPORT1)
$(OXIGRAPH_COUNTS_REPORT1): $(TEST_TMP) $(SPARQL_COUNT_RESULT_FILES1)
@#echo "Generating report: $@"
@rm -f $@ >/dev/null 2>&1 || true
@for result_file in $(SPARQL_COUNT_RESULT_FILES1) ; do \
result="$$(cat $${result_file} | tr -d '\015' | xargs)" ; \
IFS=\ read -r counter count <<< $${result} ; \
file_name="$$(basename $${result_file})" ; \
file_name="$${file_name/-before-transformation.tmp.csv/}" ; \
printf "%10s: $(bold)%-30s$(normal) = $(green)$(bold)%-10d$(normal)\n" "$${file_name:0:10}" "$${counter}" "$${count}" >> $@ ; \
done
#.INTERMEDIATE: $(OXIGRAPH_COUNTS_REPORT2)
$(OXIGRAPH_COUNTS_REPORT2): $(TEST_TMP) $(SPARQL_COUNT_RESULT_FILES2)
@#echo "Generating report: $@"
@rm -f $@ >/dev/null 2>&1 || true
@for result_file in $(SPARQL_COUNT_RESULT_FILES2) ; do \
result="$$(cat $${result_file} | tr -d '\015' | xargs)" ; \
IFS=\ read -r counter count <<< $${result} ; \
file_name="$$(basename $${result_file})" ; \
file_name="$${file_name/-after-transformation.tmp.csv/}" ; \
printf "%10s: $(bold)%-30s$(normal) = $(green)$(bold)%-10d$(normal)\n" "$${file_name:0:10}" "$${counter}" "$${count}" >> $@ ; \
done
.PHONY: _oxigraph-run-counts-no-report1
_oxigraph-run-counts-no-report1: _oxigraph-count1-clean $(OXIGRAPH_COUNTS_REPORT1)
.PHONY: _oxigraph-run-counts-no-report2
_oxigraph-run-counts-no-report2: _oxigraph-count2-clean $(OXIGRAPH_COUNTS_REPORT2)
.PHONY: oxigraph-report-counts1
oxigraph-report-counts1: $(OXIGRAPH_COUNTS_REPORT1)
@echo "Report of all SPARQL SELECT statements that perform a COUNT before transformation:"
@cat $?
.PHONY: oxigraph-report-counts2
oxigraph-report-counts2: $(OXIGRAPH_COUNTS_REPORT2)
@echo "Report of all SPARQL SELECT statements that perform a COUNT after transformation:"
@cat $?
.PHONY: _oxigraph-run-counts1-no-reload
_oxigraph-run-counts1-no-reload: _oxigraph-count1-clean oxigraph-report-counts1
.PHONY: _oxigraph-run-counts2-no-reload
_oxigraph-run-counts2-no-reload: _oxigraph-count2-clean oxigraph-report-counts2
.PHONY: oxigraph-run-counts1
oxigraph-run-counts1: oxigraph-reload _oxigraph-run-counts1-no-reload
.PHONY: oxigraph-run-counts2
oxigraph-run-counts2: oxigraph-reload _oxigraph-run-counts2-no-reload
.PHONY: oxigraph-count-before-transform
oxigraph-count-before-transform: _oxigraph-run-counts1-no-reload
printf "$(bold)$(green)Ran the counts before transformation$(normal)\n"
.PHONY: oxigraph-count-after-transform
oxigraph-count-after-transform: _oxigraph-run-counts2-no-reload
printf "$(bold)$(green)Ran the counts after transformation$(normal)\n"
#$(info <--- .make/oxigraph-count.mk)
endif # _MK_OXIGRAPH_COUNT_MK_