@matdata/yasgui-explain-plugin 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/ExplainPlugin.d.ts +1 -1
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/tripletrail.d.ts +18 -0
- package/dist/engines/tripletrail.d.ts.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/yasgui-explain-plugin.cjs.js +91 -8
- package/dist/yasgui-explain-plugin.cjs.js.map +4 -4
- package/dist/yasgui-explain-plugin.esm.js +91 -8
- package/dist/yasgui-explain-plugin.esm.js.map +4 -4
- package/dist/yasgui-explain-plugin.min.js +55 -54
- package/dist/yasgui-explain-plugin.min.js.map +4 -4
- package/package.json +5 -4
|
@@ -912,9 +912,91 @@ var neptune = {
|
|
|
912
912
|
}
|
|
913
913
|
};
|
|
914
914
|
|
|
915
|
+
// src/engines/tripletrail.ts
|
|
916
|
+
function explainUrl2(endpoint) {
|
|
917
|
+
const index = endpoint.search(/[?#]/);
|
|
918
|
+
const [base, suffix] = index < 0 ? [endpoint, ""] : [endpoint.slice(0, index), endpoint.slice(index)];
|
|
919
|
+
const trimmed = base.replace(/\/+$/, "");
|
|
920
|
+
if (/\/(sparql|query|update)$/i.test(trimmed))
|
|
921
|
+
return trimmed.replace(/\/(sparql|query|update)$/i, "/explain") + suffix;
|
|
922
|
+
if (/\/explain$/i.test(trimmed)) return trimmed + suffix;
|
|
923
|
+
return `${trimmed}/explain${suffix}`;
|
|
924
|
+
}
|
|
925
|
+
var isNumber2 = (value) => typeof value === "number" && Number.isFinite(value);
|
|
926
|
+
var ms = (seconds2) => isNumber2(seconds2) ? seconds2 * 1e3 : void 0;
|
|
927
|
+
function toNode(step) {
|
|
928
|
+
return {
|
|
929
|
+
label: String((step == null ? void 0 : step.name) || "step").replace(/\s+/g, " ").trim(),
|
|
930
|
+
rows: isNumber2(step == null ? void 0 : step["number of results"]) ? step["number of results"] : void 0,
|
|
931
|
+
timeMs: ms(step == null ? void 0 : step["duration in seconds"]),
|
|
932
|
+
children: Array.isArray(step == null ? void 0 : step.children) ? step.children.map(toNode) : []
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
function parseTripleTrailResponse(body) {
|
|
936
|
+
var _a;
|
|
937
|
+
const text = body.trim();
|
|
938
|
+
if (!text) throw new Error("TripleTrail returned an empty response.");
|
|
939
|
+
let json;
|
|
940
|
+
try {
|
|
941
|
+
json = JSON.parse(text);
|
|
942
|
+
} catch (e) {
|
|
943
|
+
throw new Error("TripleTrail did not return JSON. Is this endpoint a TripleTrail server?");
|
|
944
|
+
}
|
|
945
|
+
if (!json || typeof json !== "object" || json.head || json.results || "boolean" in json)
|
|
946
|
+
throw new Error(
|
|
947
|
+
"The endpoint returned results instead of a plan. Is this endpoint a TripleTrail server?"
|
|
948
|
+
);
|
|
949
|
+
const summary = [];
|
|
950
|
+
if (isNumber2(json.rows)) summary.push(`Result size: ${json.rows.toLocaleString("en-US")} rows`);
|
|
951
|
+
const planning = ms((_a = json.plan) == null ? void 0 : _a["planning duration in seconds"]);
|
|
952
|
+
if (planning !== void 0) summary.push(`Query planning: ${planning.toFixed(2)} ms`);
|
|
953
|
+
const spatial = json.spatial && typeof json.spatial === "object" ? json.spatial : {};
|
|
954
|
+
if (spatial.filters || spatial.joins) {
|
|
955
|
+
const lookup = isNumber2(spatial.lookup_ms) ? `, index lookup ${spatial.lookup_ms.toFixed(1)} ms` : "";
|
|
956
|
+
summary.push(
|
|
957
|
+
`Spatial: ${spatial.filters || 0} filters, ${spatial.joins || 0} joins, ${spatial.candidates || 0} candidates${lookup}`
|
|
958
|
+
);
|
|
959
|
+
}
|
|
960
|
+
if (Array.isArray(spatial.decisions))
|
|
961
|
+
for (const decision of spatial.decisions) summary.push(`Spatial rewrite: ${String(decision)}`);
|
|
962
|
+
const root2 = json.plan && (json.plan.plan || (json.plan.name ? json.plan : void 0));
|
|
963
|
+
if (root2 && typeof root2 === "object") return { kind: "tree", root: toNode(root2), summary };
|
|
964
|
+
if (json.restricted)
|
|
965
|
+
summary.push(
|
|
966
|
+
"The plan is left out: you may read only some of the graphs, and the plan is chosen from all of them."
|
|
967
|
+
);
|
|
968
|
+
return { kind: "text", text: summary.join("\n") || "No plan." };
|
|
969
|
+
}
|
|
970
|
+
var tripletrail = {
|
|
971
|
+
id: "tripletrail",
|
|
972
|
+
label: "TripleTrail",
|
|
973
|
+
description: "The plan TripleTrail ran, with the rows and time of each step.",
|
|
974
|
+
needsRequestOptions: true,
|
|
975
|
+
buildRequest(query2, endpoint) {
|
|
976
|
+
return { query: query2, accept: "application/json", endpoint: explainUrl2(endpoint) };
|
|
977
|
+
},
|
|
978
|
+
parse(body) {
|
|
979
|
+
return parseTripleTrailResponse(body);
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
|
|
915
983
|
// src/engines/index.ts
|
|
916
|
-
var ENGINES = {
|
|
917
|
-
|
|
984
|
+
var ENGINES = {
|
|
985
|
+
qlever,
|
|
986
|
+
graphdb,
|
|
987
|
+
stardog,
|
|
988
|
+
blazegraph,
|
|
989
|
+
neptune,
|
|
990
|
+
tripletrail
|
|
991
|
+
};
|
|
992
|
+
var ENGINE_IDS = [
|
|
993
|
+
"qlever",
|
|
994
|
+
"graphdb",
|
|
995
|
+
"stardog",
|
|
996
|
+
"blazegraph",
|
|
997
|
+
"neptune",
|
|
998
|
+
"tripletrail"
|
|
999
|
+
];
|
|
918
1000
|
function isEngineId(value) {
|
|
919
1001
|
return typeof value === "string" && value in ENGINES;
|
|
920
1002
|
}
|
|
@@ -927,6 +1009,7 @@ function detectEngine(endpoint, serverHeader) {
|
|
|
927
1009
|
if (server.includes("graphdb")) return "graphdb";
|
|
928
1010
|
if (server.includes("stardog")) return "stardog";
|
|
929
1011
|
if (server.includes("blazegraph") || server.includes("bigdata")) return "blazegraph";
|
|
1012
|
+
if (server.includes("tripletrail")) return "tripletrail";
|
|
930
1013
|
if (!endpoint) return void 0;
|
|
931
1014
|
let url;
|
|
932
1015
|
try {
|
|
@@ -19821,11 +19904,11 @@ function message(text, kind = "muted") {
|
|
|
19821
19904
|
el.textContent = text;
|
|
19822
19905
|
return el;
|
|
19823
19906
|
}
|
|
19824
|
-
function formatMs2(
|
|
19825
|
-
if (
|
|
19826
|
-
if (
|
|
19827
|
-
if (
|
|
19828
|
-
return `${
|
|
19907
|
+
function formatMs2(ms2) {
|
|
19908
|
+
if (ms2 >= 1e4) return `${(ms2 / 1e3).toFixed(1)} s`;
|
|
19909
|
+
if (ms2 >= 100) return `${Math.round(ms2)} ms`;
|
|
19910
|
+
if (ms2 >= 10) return `${ms2.toFixed(1)} ms`;
|
|
19911
|
+
return `${ms2.toFixed(2)} ms`;
|
|
19829
19912
|
}
|
|
19830
19913
|
function formatRows(rows) {
|
|
19831
19914
|
return rows.toLocaleString("en-US");
|
|
@@ -20265,7 +20348,7 @@ var ExplainPlugin = class {
|
|
|
20265
20348
|
planSection.setStatus("");
|
|
20266
20349
|
planSection.body.appendChild(
|
|
20267
20350
|
message(
|
|
20268
|
-
resolved.source === "none" ? "No engine recognised for this endpoint. Pick it in the Engine list when it is QLever, GraphDB, Stardog, Blazegraph or
|
|
20351
|
+
resolved.source === "none" ? "No engine recognised for this endpoint. Pick it in the Engine list when it is QLever, GraphDB, Stardog, Blazegraph, Neptune or TripleTrail; other engines publish no plan over the SPARQL protocol." : "No plan is asked for this endpoint. Pick an engine in the Engine list to fetch one."
|
|
20269
20352
|
)
|
|
20270
20353
|
);
|
|
20271
20354
|
return;
|