[32/50] [abbrv] jena git commit: JENA-800 : Reorder function corresponding to that in 2.11.2.

2014-11-10 Thread rvesse
JENA-800 : Reorder function corresponding to that in 2.11.2.

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

Branch: refs/heads/hadoop-rdf
Commit: a9c7671cdd2b6d7c8c9c2031aac41b325cac91e1
Parents: ef40d6b
Author: Andy Seaborne a...@apache.org
Authored: Wed Nov 5 11:26:46 2014 +
Committer: Andy Seaborne a...@apache.org
Committed: Wed Nov 5 11:26:46 2014 +

--
 .../optimizer/reorder/ReorderFixedAlt.java  | 80 
 1 file changed, 80 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/jena/blob/a9c7671c/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
--
diff --git 
a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
new file mode 100644
index 000..e5014c9
--- /dev/null
+++ 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.sparql.engine.optimizer.reorder;
+
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.TERM ;
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.VAR ;
+
+import com.hp.hpl.jena.sparql.engine.optimizer.Pattern ;
+import com.hp.hpl.jena.sparql.engine.optimizer.StatsMatcher ;
+import com.hp.hpl.jena.sparql.graph.NodeConst ;
+import com.hp.hpl.jena.sparql.sse.Item ;
+
+/**
+ * Alternative fixed reorder function. This corresponds to the algorithm prior
+ * to Jena 2.11.2. It is susceptable to picking bad orders when there are lots
+ * of non-characterstic (non-selective) rdf:type triples.
+ * p
+ * The default ReorderFixed is better in most cases because it avoids
+ * ? rdf:type T which can be very unselective. Being data independent, that 
is
+ * a guess. Consider using the stats matcher for detailed control.
+ */
+public class ReorderFixedAlt extends ReorderTransformationSubstitution
+{
+public ReorderFixedAlt() {}
+
+// Fixed scheme for when we have no stats.
+// It chooses a triple pattern by order of preference.
+
+private static Item type = Item.createNode(NodeConst.nodeRDFType) ;
+
+/** The number of triples used for the base scale */
+public static int MultiTermSampleSize = 100 ; 
+
+/** Maximum value for a match involving two terms. */
+public static int MultiTermMax = 9 ; 
+
+public final static StatsMatcher matcher ;
+static {
+matcher = new StatsMatcher() ;
+
+//matcher.addPattern(new Pattern(1,   TERM, TERM, TERM)) ; // SPO 
- built-in - not needed a s a rule
+
+// Numbers choosen as an approximation ratios for a graph of 100 
triples
+matcher.addPattern(new Pattern(2,   TERM, TERM, VAR)) ; // SP?
+
+// Pointless - this rule is over ridden by lower weight ?PO
+   // matcher.addPattern(new Pattern(5,   TERM, type, TERM)) ;
// ? type O -- worse than ?PO
+
+matcher.addPattern(new Pattern(3,   VAR,  TERM, TERM)) ;// ?PO
+matcher.addPattern(new Pattern(2,   TERM, VAR,  TERM)) ;// S?O
+
+matcher.addPattern(new Pattern(10,  TERM, VAR,  VAR)) ; // S??
+matcher.addPattern(new Pattern(20,  VAR,  VAR,  TERM)) ;// ??O
+matcher.addPattern(new Pattern(30,  VAR,  TERM, VAR)) ; // ?P?
+
+matcher.addPattern(new Pattern(MultiTermSampleSize, VAR,  VAR,  VAR)) 
; // ???
+}
+
+@Override
+public double weight(PatternTriple pt)
+{
+return matcher.match(pt) ;
+}
+}



[14/50] [abbrv] jena git commit: JENA-800 : Reorder function corresponding to that in 2.11.2.

2014-11-10 Thread rvesse
JENA-800 : Reorder function corresponding to that in 2.11.2.

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

Branch: refs/heads/JENA-507
Commit: a9c7671cdd2b6d7c8c9c2031aac41b325cac91e1
Parents: ef40d6b
Author: Andy Seaborne a...@apache.org
Authored: Wed Nov 5 11:26:46 2014 +
Committer: Andy Seaborne a...@apache.org
Committed: Wed Nov 5 11:26:46 2014 +

--
 .../optimizer/reorder/ReorderFixedAlt.java  | 80 
 1 file changed, 80 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/jena/blob/a9c7671c/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
--
diff --git 
a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
new file mode 100644
index 000..e5014c9
--- /dev/null
+++ 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.sparql.engine.optimizer.reorder;
+
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.TERM ;
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.VAR ;
+
+import com.hp.hpl.jena.sparql.engine.optimizer.Pattern ;
+import com.hp.hpl.jena.sparql.engine.optimizer.StatsMatcher ;
+import com.hp.hpl.jena.sparql.graph.NodeConst ;
+import com.hp.hpl.jena.sparql.sse.Item ;
+
+/**
+ * Alternative fixed reorder function. This corresponds to the algorithm prior
+ * to Jena 2.11.2. It is susceptable to picking bad orders when there are lots
+ * of non-characterstic (non-selective) rdf:type triples.
+ * p
+ * The default ReorderFixed is better in most cases because it avoids
+ * ? rdf:type T which can be very unselective. Being data independent, that 
is
+ * a guess. Consider using the stats matcher for detailed control.
+ */
+public class ReorderFixedAlt extends ReorderTransformationSubstitution
+{
+public ReorderFixedAlt() {}
+
+// Fixed scheme for when we have no stats.
+// It chooses a triple pattern by order of preference.
+
+private static Item type = Item.createNode(NodeConst.nodeRDFType) ;
+
+/** The number of triples used for the base scale */
+public static int MultiTermSampleSize = 100 ; 
+
+/** Maximum value for a match involving two terms. */
+public static int MultiTermMax = 9 ; 
+
+public final static StatsMatcher matcher ;
+static {
+matcher = new StatsMatcher() ;
+
+//matcher.addPattern(new Pattern(1,   TERM, TERM, TERM)) ; // SPO 
- built-in - not needed a s a rule
+
+// Numbers choosen as an approximation ratios for a graph of 100 
triples
+matcher.addPattern(new Pattern(2,   TERM, TERM, VAR)) ; // SP?
+
+// Pointless - this rule is over ridden by lower weight ?PO
+   // matcher.addPattern(new Pattern(5,   TERM, type, TERM)) ;
// ? type O -- worse than ?PO
+
+matcher.addPattern(new Pattern(3,   VAR,  TERM, TERM)) ;// ?PO
+matcher.addPattern(new Pattern(2,   TERM, VAR,  TERM)) ;// S?O
+
+matcher.addPattern(new Pattern(10,  TERM, VAR,  VAR)) ; // S??
+matcher.addPattern(new Pattern(20,  VAR,  VAR,  TERM)) ;// ??O
+matcher.addPattern(new Pattern(30,  VAR,  TERM, VAR)) ; // ?P?
+
+matcher.addPattern(new Pattern(MultiTermSampleSize, VAR,  VAR,  VAR)) 
; // ???
+}
+
+@Override
+public double weight(PatternTriple pt)
+{
+return matcher.match(pt) ;
+}
+}



[13/50] [abbrv] jena git commit: JENA-800 : Reorder function corresponding to that in 2.11.2.

2014-11-10 Thread rvesse
JENA-800 : Reorder function corresponding to that in 2.11.2.

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

Branch: refs/heads/eliminate-assignments
Commit: a9c7671cdd2b6d7c8c9c2031aac41b325cac91e1
Parents: ef40d6b
Author: Andy Seaborne a...@apache.org
Authored: Wed Nov 5 11:26:46 2014 +
Committer: Andy Seaborne a...@apache.org
Committed: Wed Nov 5 11:26:46 2014 +

--
 .../optimizer/reorder/ReorderFixedAlt.java  | 80 
 1 file changed, 80 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/jena/blob/a9c7671c/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
--
diff --git 
a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
new file mode 100644
index 000..e5014c9
--- /dev/null
+++ 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.sparql.engine.optimizer.reorder;
+
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.TERM ;
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.VAR ;
+
+import com.hp.hpl.jena.sparql.engine.optimizer.Pattern ;
+import com.hp.hpl.jena.sparql.engine.optimizer.StatsMatcher ;
+import com.hp.hpl.jena.sparql.graph.NodeConst ;
+import com.hp.hpl.jena.sparql.sse.Item ;
+
+/**
+ * Alternative fixed reorder function. This corresponds to the algorithm prior
+ * to Jena 2.11.2. It is susceptable to picking bad orders when there are lots
+ * of non-characterstic (non-selective) rdf:type triples.
+ * p
+ * The default ReorderFixed is better in most cases because it avoids
+ * ? rdf:type T which can be very unselective. Being data independent, that 
is
+ * a guess. Consider using the stats matcher for detailed control.
+ */
+public class ReorderFixedAlt extends ReorderTransformationSubstitution
+{
+public ReorderFixedAlt() {}
+
+// Fixed scheme for when we have no stats.
+// It chooses a triple pattern by order of preference.
+
+private static Item type = Item.createNode(NodeConst.nodeRDFType) ;
+
+/** The number of triples used for the base scale */
+public static int MultiTermSampleSize = 100 ; 
+
+/** Maximum value for a match involving two terms. */
+public static int MultiTermMax = 9 ; 
+
+public final static StatsMatcher matcher ;
+static {
+matcher = new StatsMatcher() ;
+
+//matcher.addPattern(new Pattern(1,   TERM, TERM, TERM)) ; // SPO 
- built-in - not needed a s a rule
+
+// Numbers choosen as an approximation ratios for a graph of 100 
triples
+matcher.addPattern(new Pattern(2,   TERM, TERM, VAR)) ; // SP?
+
+// Pointless - this rule is over ridden by lower weight ?PO
+   // matcher.addPattern(new Pattern(5,   TERM, type, TERM)) ;
// ? type O -- worse than ?PO
+
+matcher.addPattern(new Pattern(3,   VAR,  TERM, TERM)) ;// ?PO
+matcher.addPattern(new Pattern(2,   TERM, VAR,  TERM)) ;// S?O
+
+matcher.addPattern(new Pattern(10,  TERM, VAR,  VAR)) ; // S??
+matcher.addPattern(new Pattern(20,  VAR,  VAR,  TERM)) ;// ??O
+matcher.addPattern(new Pattern(30,  VAR,  TERM, VAR)) ; // ?P?
+
+matcher.addPattern(new Pattern(MultiTermSampleSize, VAR,  VAR,  VAR)) 
; // ???
+}
+
+@Override
+public double weight(PatternTriple pt)
+{
+return matcher.match(pt) ;
+}
+}



git commit: JENA-800 : Reorder function corresponding to that in 2.11.2.

2014-11-05 Thread andy
Repository: jena
Updated Branches:
  refs/heads/master ef40d6b7d - a9c7671cd


JENA-800 : Reorder function corresponding to that in 2.11.2.

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

Branch: refs/heads/master
Commit: a9c7671cdd2b6d7c8c9c2031aac41b325cac91e1
Parents: ef40d6b
Author: Andy Seaborne a...@apache.org
Authored: Wed Nov 5 11:26:46 2014 +
Committer: Andy Seaborne a...@apache.org
Committed: Wed Nov 5 11:26:46 2014 +

--
 .../optimizer/reorder/ReorderFixedAlt.java  | 80 
 1 file changed, 80 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/jena/blob/a9c7671c/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
--
diff --git 
a/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
new file mode 100644
index 000..e5014c9
--- /dev/null
+++ 
b/jena-arq/src/main/java/com/hp/hpl/jena/sparql/engine/optimizer/reorder/ReorderFixedAlt.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * License); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hp.hpl.jena.sparql.engine.optimizer.reorder;
+
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.TERM ;
+import static 
com.hp.hpl.jena.sparql.engine.optimizer.reorder.PatternElements.VAR ;
+
+import com.hp.hpl.jena.sparql.engine.optimizer.Pattern ;
+import com.hp.hpl.jena.sparql.engine.optimizer.StatsMatcher ;
+import com.hp.hpl.jena.sparql.graph.NodeConst ;
+import com.hp.hpl.jena.sparql.sse.Item ;
+
+/**
+ * Alternative fixed reorder function. This corresponds to the algorithm prior
+ * to Jena 2.11.2. It is susceptable to picking bad orders when there are lots
+ * of non-characterstic (non-selective) rdf:type triples.
+ * p
+ * The default ReorderFixed is better in most cases because it avoids
+ * ? rdf:type T which can be very unselective. Being data independent, that 
is
+ * a guess. Consider using the stats matcher for detailed control.
+ */
+public class ReorderFixedAlt extends ReorderTransformationSubstitution
+{
+public ReorderFixedAlt() {}
+
+// Fixed scheme for when we have no stats.
+// It chooses a triple pattern by order of preference.
+
+private static Item type = Item.createNode(NodeConst.nodeRDFType) ;
+
+/** The number of triples used for the base scale */
+public static int MultiTermSampleSize = 100 ; 
+
+/** Maximum value for a match involving two terms. */
+public static int MultiTermMax = 9 ; 
+
+public final static StatsMatcher matcher ;
+static {
+matcher = new StatsMatcher() ;
+
+//matcher.addPattern(new Pattern(1,   TERM, TERM, TERM)) ; // SPO 
- built-in - not needed a s a rule
+
+// Numbers choosen as an approximation ratios for a graph of 100 
triples
+matcher.addPattern(new Pattern(2,   TERM, TERM, VAR)) ; // SP?
+
+// Pointless - this rule is over ridden by lower weight ?PO
+   // matcher.addPattern(new Pattern(5,   TERM, type, TERM)) ;
// ? type O -- worse than ?PO
+
+matcher.addPattern(new Pattern(3,   VAR,  TERM, TERM)) ;// ?PO
+matcher.addPattern(new Pattern(2,   TERM, VAR,  TERM)) ;// S?O
+
+matcher.addPattern(new Pattern(10,  TERM, VAR,  VAR)) ; // S??
+matcher.addPattern(new Pattern(20,  VAR,  VAR,  TERM)) ;// ??O
+matcher.addPattern(new Pattern(30,  VAR,  TERM, VAR)) ; // ?P?
+
+matcher.addPattern(new Pattern(MultiTermSampleSize, VAR,  VAR,  VAR)) 
; // ???
+}
+
+@Override
+public double weight(PatternTriple pt)
+{
+return matcher.match(pt) ;
+}
+}