jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1441797 - in /jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql: algebra/optimize/TransformPropertyFunction.java pfunction/PropertyFunctionRegistry.java
Date Sat, 02 Feb 2013 19:50:55 GMT
Author: andy
Date: Sat Feb  2 19:50:55 2013
New Revision: 1441797

URL: http://svn.apache.org/viewvc?rev=1441797&view=rev
Log:
Extract getting a PropertyFunctionRegistry.
Add testing for PF's in quad patterns (currently commented out)

Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/pfunction/PropertyFunctionRegistry.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java?rev=1441797&r1=1441796&r2=1441797&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java
(original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/optimize/TransformPropertyFunction.java
Sat Feb  2 19:50:55 2013
@@ -18,28 +18,38 @@
 
 package com.hp.hpl.jena.sparql.algebra.optimize;
 
+import org.apache.jena.atlas.logging.Log ;
+
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.query.ARQ ;
 import com.hp.hpl.jena.sparql.algebra.Op ;
 import com.hp.hpl.jena.sparql.algebra.PropertyFunctionGenerator ;
 import com.hp.hpl.jena.sparql.algebra.TransformCopy ;
 import com.hp.hpl.jena.sparql.algebra.op.OpBGP ;
+import com.hp.hpl.jena.sparql.algebra.op.OpQuad ;
+import com.hp.hpl.jena.sparql.algebra.op.OpQuadPattern ;
 import com.hp.hpl.jena.sparql.algebra.op.OpTriple ;
+import com.hp.hpl.jena.sparql.pfunction.PropertyFunctionRegistry ;
 import com.hp.hpl.jena.sparql.util.Context ;
 
 /** Rewrite to replace a property function property with the call to the property function
implementation */
 public class TransformPropertyFunction extends TransformCopy
 {
     private final Context context ;
-
+    private final boolean doingMagicProperties ;
+    private final PropertyFunctionRegistry registry ;
+    
     public TransformPropertyFunction(Context context)
     {
-        this.context = context ;   
+        this.context = context ;  
+        doingMagicProperties = context.isTrue(ARQ.enablePropertyFunctions) ;
+        registry = PropertyFunctionRegistry.chooseRegistry(context) ;
     }
     
     @Override
     public Op transform(OpTriple opTriple)
     {
-        boolean doingMagicProperties = context.isTrue(ARQ.enablePropertyFunctions) ;
         if ( ! doingMagicProperties )
             return opTriple ;
         
@@ -56,10 +66,46 @@ public class TransformPropertyFunction e
     @Override
     public Op transform(OpBGP opBGP)
     {
-        boolean doingMagicProperties = context.isTrue(ARQ.enablePropertyFunctions) ;
         if ( ! doingMagicProperties )
             return opBGP ;
         
-        return PropertyFunctionGenerator.buildPropertyFunctions(opBGP, context) ;
+        return PropertyFunctionGenerator.buildPropertyFunctions(registry, opBGP, context)
;
     }
+    
+    // Normally, property functionprocessing is done before quad conversion
+    // we could convert back to OpGraph and so handle quads 
+    
+    // For the moment, leave in old mode.
+    
+//    @Override
+//    public Op transform(OpQuad opQuad)
+//    {
+//        if ( ! doingMagicProperties )
+//            return super.transform(opQuad) ; ;
+//        check(opQuad.getQuad().getPredicate()) ;
+//        return super.transform(opQuad) ;
+//    }
+//    
+//    private void check(Node p)
+//    {
+//        if ( p.isURI() )
+//        {
+//            if ( registry.manages(p.getURI()) )
+//                Log.warn(this,  "Property function in quad: "+p) ;
+//        }
+//    }
+//    
+//    @Override
+//    public Op transform(OpQuadPattern opQuadPattern)
+//    {
+//        if ( ! doingMagicProperties )
+//            return super.transform(opQuadPattern) ; ;
+//        
+//        for ( Triple t : opQuadPattern.getBasicPattern().getList() )
+//            check(t.getPredicate()) ;
+//        
+//        return super.transform(opQuadPattern) ;
+//    }
+
 }
+

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/pfunction/PropertyFunctionRegistry.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/pfunction/PropertyFunctionRegistry.java?rev=1441797&r1=1441796&r2=1441797&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/pfunction/PropertyFunctionRegistry.java
(original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/pfunction/PropertyFunctionRegistry.java
Sat Feb  2 19:50:55 2013
@@ -55,6 +55,16 @@ public class PropertyFunctionRegistry
         return (PropertyFunctionRegistry)context.get(ARQConstants.registryPropertyFunctions)
;
     }
     
+    /** Get the PropertyFunctionRegistry, defailting to the global one */
+    public static PropertyFunctionRegistry chooseRegistry(Context context)
+    {
+        PropertyFunctionRegistry registry = PropertyFunctionRegistry.get(context) ;
+        // Else global
+        if ( registry == null )
+            registry = PropertyFunctionRegistry.get() ;
+        return registry ;
+    }
+    
     public static void set(Context context, PropertyFunctionRegistry reg)
     { context.set(ARQConstants.registryPropertyFunctions, reg) ; }
     



Mime
View raw message