# HG changeset patch
# User drewp@bigasterisk.com
# Date 1525932519 0
# Node ID 4bc24f91b6f1066d5b0b2201f20bc65f7d44cf48
# Parent 49a2a18abe8b0b0325512d3411e943e81ab5d357
fix floatValue cache
Ignore-this: f5e5c6ffef3f48eebd03ecd19fab99b7
diff -r 49a2a18abe8b -r 4bc24f91b6f1 light9/web/graph.coffee
--- a/light9/web/graph.coffee Thu May 10 05:29:55 2018 +0000
+++ b/light9/web/graph.coffee Thu May 10 06:08:39 2018 +0000
@@ -266,7 +266,7 @@
switch objs.size
when 0
- throw new Error("no value for "+s+" "+p)
+ throw new Error("no value for "+s.value+" "+p.value)
when 1
obj = objs.values().next().value
return obj
@@ -274,7 +274,7 @@
throw new Error("too many different values: " + JSON.stringify(quads))
floatValue: (s, p) ->
- key = s + '|' + p
+ key = s.value + '|' + p.value
hit = @cachedFloatValues.get(key)
return hit if hit != undefined
#log('float miss', s, p)
diff -r 49a2a18abe8b -r 4bc24f91b6f1 light9/web/rdfdb-synced-graph_test.html
--- a/light9/web/rdfdb-synced-graph_test.html Thu May 10 05:29:55 2018 +0000
+++ b/light9/web/rdfdb-synced-graph_test.html Thu May 10 06:08:39 2018 +0000
@@ -27,24 +27,39 @@
const assert = chai.assert;
describe("rdfdb-synced-graph", () => {
- let elem;
- beforeEach(() => {
- elem = document.querySelector("#graph");
- window.g = elem;
- elem.graph.clearGraph();
- });
- it("makes a node", () => {
- assert.equal(elem.tagName, "RDFDB-SYNCED-GRAPH");
- });
- it("loads trig", (done) => {
- elem.graph.loadTrig(`
- @prefix : .
+ let elem, U;
+ beforeEach(() => {
+ elem = document.querySelector("#graph");
+ window.g = elem;
+ elem.graph.clearGraph();
+ U = elem.graph.Uri.bind(elem.graph);
+ });
+ it("makes a node", () => {
+ assert.equal(elem.tagName, "RDFDB-SYNCED-GRAPH");
+ });
+ it("loads trig", (done) => {
+ elem.graph.loadTrig(`
+ @prefix : .
:a :b :c :d .
`, () => {
- assert.equal(elem.graph.quads().length, 1);
- done();
+ assert.equal(elem.graph.quads().length, 1);
+ done();
});
+ });
+ describe("floatValue read call", () => {
+ it("loads two values without confusing them in a cache", (done) => {
+ elem.graph.loadTrig(`
+ @prefix : .
+ :s :a 1 :g .
+ :s :b 2 :g .
+ `, () => {
+ assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1);
+ assert.equal(elem.graph.floatValue(U(":s"), U(":b")), 2);
+ assert.equal(elem.graph.floatValue(U(":s"), U(":a")), 1);
+ done();
+ });
});
+ });
});
mocha.run();