Changeset - 3a15fb921b9c
[Not reviewed]
default
0 3 0
Drew Perttula - 12 years ago 2013-06-10 09:52:15
drewp@bigasterisk.com
more tripleFilter speedups. accept Decimals coming in from n3 files, which happens with the 2012 code
Ignore-this: 5a63ec4776bf9c4ffc3d6b4f20242ac0
3 files changed with 20 insertions and 7 deletions:
0 comments (0 inline, 0 general)
light9/Submaster.py
Show inline comments
 
@@ -184,10 +184,10 @@ class PersistentSubmaster(Submaster):
 
    def _saveContext(self):
 
        """the context in which we should save all the lightLevel triples for
 
        this sub"""
 
        with self.graph.currentState() as g:
 
        typeStmt = (self.uri, RDF.type, L9['Submaster'])
 
        with self.graph.currentState(tripleFilter=typeStmt) as current:
 
            try:
 
                ctx = g.contextsForStatement(
 
                    (self.uri, RDF.type, L9['Submaster']))[0]
 
                ctx = current.contextsForStatement(typeStmt)[0]
 
            except IndexError:
 
                log.info("declaring %s to be a submaster" % self.uri)
 
                ctx = self.uri
light9/dmxchanedit.py
Show inline comments
 
@@ -19,6 +19,7 @@ proposal for new attribute system:
 
from __future__ import nested_scopes,division
 
import Tkinter as tk
 
from rdflib import RDF, Literal
 
from decimal import Decimal
 
from light9.namespaces import L9
 

	
 
stdfont = ('Arial', 9)
 
@@ -191,6 +192,9 @@ class Levelbox(tk.Frame):
 
        for ll in self.graph.objects(sub, L9['lightLevel']):
 
            chan = self.graph.value(ll, L9['channel'])
 
            lev = self.graph.value(ll, L9['level']).toPython()
 
            if isinstance(lev, Decimal):
 
                 lev = float(lev)
 
            assert isinstance(lev, (int, long, float)), repr(lev)
 
            self.levelFromUri[chan].setTo(lev)
 
            remaining.remove(chan)
 
        for channel in remaining:
light9/rdfdb/grapheditapi.py
Show inline comments
 
@@ -43,10 +43,17 @@ class GraphEditApi(object):
 
        value since that's tricky too
 
        """
 

	
 
        with self.currentState() as graph:
 
        # as long as currentState is expensive and has the
 
        # tripleFilter optimization, this looks like a mess. If
 
        # currentState became cheap, a lot of code here could go away.
 
        
 
        with self.currentState(tripleFilter=(subject, predicate, None)) as current:
 
            adds = set([])
 
            for setting in graph.objects(subject, predicate):
 
                if graph.value(setting, keyPred) == newKey:
 
            for setting in current.objects(subject, predicate):
 
                with self.currentState(tripleFilter=(setting, keyPred, None)) as current2:
 
                
 
                    match = current2.value(setting, keyPred) == newKey
 
                if match:
 
                    break
 
            else:
 
                setting = URIRef(subject + "/map/%s" %
 
@@ -56,8 +63,10 @@ class GraphEditApi(object):
 
                    (setting, RDF.type, nodeClass, context),
 
                    (setting, keyPred, newKey, context),
 
                    ])
 

	
 
        with self.currentState(tripleFilter=(setting, valuePred, None)) as current:
 
            dels = set([])
 
            for prev in graph.objects(setting, valuePred):
 
            for prev in current.objects(setting, valuePred):
 
                dels.add((setting, valuePred, prev, context))
 
            adds.add((setting, valuePred, newValue, context))
 

	
0 comments (0 inline, 0 general)