jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [4/5] jena git commit: Cope with unregistered aggregates (to some degree).
Date Mon, 29 Dec 2014 16:20:40 GMT
Cope with unregistered aggregates (to some degree).

Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/58510249
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/58510249
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/58510249

Branch: refs/heads/master
Commit: 58510249db7178464ce2c6f0050c1ee19a8ac2ec
Parents: ba7cc50
Author: Andy Seaborne <andy@apache.org>
Authored: Mon Dec 29 13:22:18 2014 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Mon Dec 29 13:22:18 2014 +0000

----------------------------------------------------------------------
 .../jena/sparql/expr/aggregate/AggCustom.java   | 26 +++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/58510249/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
index 72a78bc..0fd104b 100644
--- a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
+++ b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/expr/aggregate/AggCustom.java
@@ -26,6 +26,7 @@ import org.apache.jena.atlas.lib.Lib ;
 import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.query.QueryExecException ;
 import com.hp.hpl.jena.sparql.engine.binding.Binding ;
+import com.hp.hpl.jena.sparql.expr.E_Function ;
 import com.hp.hpl.jena.sparql.expr.Expr ;
 import com.hp.hpl.jena.sparql.expr.ExprList ;
 import com.hp.hpl.jena.sparql.expr.NodeValue ;
@@ -53,8 +54,10 @@ public class AggCustom extends AggregatorBase
     @Override
     public String asSparqlExpr(SerializationContext sCxt) {
         IndentedLineBuffer x = new IndentedLineBuffer() ;
-        if ( false ) {
-            // AGG <iri>(...) syntax.
+        if ( ! AggregateRegistry.isRegistered(iri) ) {
+            // If not registered and if parsed in again not registered, it becomes a function.
+            // AGG <iri>(...) syntax.  It can;'t have been legal SPARQL 1.1 unless
it got
+            // unregistered in which case all bets are off anyway.
             x.append(getName()) ;
             x.append(" ") ;
         }
@@ -113,12 +116,29 @@ public class AggCustom extends AggregatorBase
     public String getIRI()                  { return iri ; }
 
     @Override
-    public int hashCode()   { return HC_AggCustom ^ getExprList().hashCode() ^ iri.hashCode()
; }
+    public int hashCode()   {
+        if ( ! AggregateRegistry.isRegistered(iri) ) {
+            return asFunction().hashCode() ;
+        }
+        return HC_AggCustom ^ getExprList().hashCode() ^ iri.hashCode() ;
+    }
+    
+    private E_Function asFunction() {
+        return new E_Function(iri, exprList) ;
+    }
     
     @Override
     public boolean equals(Object other)
     {
         if ( this == other ) return true ;
+        
+        if ( ! AggregateRegistry.isRegistered(iri) ) {
+            E_Function f1 = asFunction() ;
+            if ( other instanceof AggCustom )
+                other = ((AggCustom)other).asFunction() ;
+            return f1.equals(other) ;
+        }
+        
         if ( ! ( other instanceof AggCustom ) )
             return false ;
         AggCustom agg = (AggCustom)other ;


Mime
View raw message