Changeset - 4bc24f91b6f1
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 7 years ago 2018-05-10 06:08:39
drewp@bigasterisk.com
fix floatValue cache
Ignore-this: f5e5c6ffef3f48eebd03ecd19fab99b7
2 files changed with 19 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/web/graph.coffee
Show inline comments
 
@@ -266,7 +266,7 @@ class window.SyncedGraph
 
    
 
    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 @@ class window.SyncedGraph
 
        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)
light9/web/rdfdb-synced-graph_test.html
Show inline comments
 
@@ -27,24 +27,39 @@
 
     const assert = chai.assert;
 
     
 
     describe("rdfdb-synced-graph", () => {
 
         let elem;
 
       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 : <http://example.com/> .
 
                       @prefix : <http://light9.bigasterisk.com/> .
 
                       :a :b :c :d .
 
                     `, () => {
 
                         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 : <http://light9.bigasterisk.com/> .
 
               :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();
 
    </script>
0 comments (0 inline, 0 general)