You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2014/04/09 00:16:12 UTC

[14/50] [abbrv] git commit: Updated the cluster details to consider the number of local processors.

Updated the cluster details to consider the number of local processors.


Project: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/commit/903576e1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/tree/903576e1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-vxquery/diff/903576e1

Branch: refs/heads/master
Commit: 903576e11361a91d2b5ea7e2f9f8cf7af7b8680f
Parents: 0b80d3f
Author: Preston Carman <pr...@apache.org>
Authored: Tue Apr 1 21:52:00 2014 -0700
Committer: Preston Carman <pr...@apache.org>
Committed: Tue Apr 1 21:52:00 2014 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/vxquery/cli/VXQuery.java  |  1 -
 .../vxquery/metadata/VXQueryMetadataProvider.java      | 13 +++++++++++--
 .../vxquery/xmlquery/query/XMLQueryCompiler.java       |  9 +++++----
 3 files changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/903576e1/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
----------------------------------------------------------------------
diff --git a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
index 3f0975a..ada055d 100644
--- a/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
+++ b/vxquery-cli/src/main/java/org/apache/vxquery/cli/VXQuery.java
@@ -33,7 +33,6 @@ import org.apache.vxquery.compiler.algebricks.prettyprint.VXQueryLogicalExpressi
 import org.apache.vxquery.context.DynamicContext;
 import org.apache.vxquery.context.DynamicContextImpl;
 import org.apache.vxquery.context.RootStaticContextImpl;
-import org.apache.vxquery.context.StaticContext;
 import org.apache.vxquery.context.StaticContextImpl;
 import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.result.ResultUtils;

http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/903576e1/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
index 71963be..0aaac5c 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/metadata/VXQueryMetadataProvider.java
@@ -52,7 +52,7 @@ import edu.uci.ics.hyracks.dataflow.std.result.ResultWriterOperatorDescriptor;
 public class VXQueryMetadataProvider implements IMetadataProvider<String, String> {
     String[] nodeList;
 
-    public void setNodeList(String[] nodeList) {
+    public VXQueryMetadataProvider(String[] nodeList) {
         this.nodeList = nodeList;
     }
 
@@ -74,7 +74,15 @@ public class VXQueryMetadataProvider implements IMetadataProvider<String, String
         return new Pair<IOperatorDescriptor, AlgebricksPartitionConstraint>(scanner, constraint);
     }
 
-    public AlgebricksPartitionConstraint getClusterLocations(String[] nodeList, int partitions) {
+    public AlgebricksPartitionConstraint getClusterLocations() {
+        int availableProcessors = Runtime.getRuntime().availableProcessors();
+        if (availableProcessors < 1) {
+            availableProcessors = 1;
+        }
+        return getClusterLocations(nodeList, availableProcessors);
+    }
+
+    private static AlgebricksPartitionConstraint getClusterLocations(String[] nodeList, int partitions) {
         ArrayList<String> locs = new ArrayList<String>();
         for (String node : nodeList) {
             for (int j = 0; j < partitions; j++) {
@@ -152,6 +160,7 @@ public class VXQueryMetadataProvider implements IMetadataProvider<String, String
             public FunctionIdentifier getFunctionIdentifier() {
                 return fid;
             }
+
             public boolean isFunctional() {
                 return true;
             }

http://git-wip-us.apache.org/repos/asf/incubator-vxquery/blob/903576e1/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
----------------------------------------------------------------------
diff --git a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
index 54bac7e..d07de9a 100644
--- a/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
+++ b/vxquery-core/src/main/java/org/apache/vxquery/xmlquery/query/XMLQueryCompiler.java
@@ -39,8 +39,10 @@ import org.apache.vxquery.types.Quantifier;
 import org.apache.vxquery.types.SequenceType;
 import org.apache.vxquery.xmlquery.ast.ModuleNode;
 import org.apache.vxquery.xmlquery.translator.XMLQueryTranslator;
+import org.omg.SendingContext.RunTime;
 
 import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
+import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
 import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.algebricks.common.utils.Pair;
 import edu.uci.ics.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder;
@@ -78,7 +80,7 @@ public class XMLQueryCompiler {
     private final ICompilerFactory cFactory;
 
     private final VXQueryMetadataProvider mdProvider;
-    
+
     private LogicalOperatorPrettyPrintVisitor pprinter;
 
     private ModuleNode moduleNode;
@@ -145,10 +147,9 @@ public class XMLQueryCompiler {
             }
         });
         builder.setNullWriterFactory(new VXQueryNullWriterFactory());
-        builder.setClusterLocations(new AlgebricksAbsolutePartitionConstraint(nodeList));
+        mdProvider = new VXQueryMetadataProvider(nodeList);
+        builder.setClusterLocations(mdProvider.getClusterLocations());
         cFactory = builder.create();
-        mdProvider = new VXQueryMetadataProvider();
-        mdProvider.setNodeList(nodeList);
     }
 
     public void compile(String name, Reader query, CompilerControlBlock ccb, int optimizationLevel)