Skip to content

Commit

Permalink
Fixes for AGGREGATE_WEIGHTED_AVG. This works quite nicely now. There …
Browse files Browse the repository at this point in the history
…is still a problem in TPC-C for it, but for the most part I think this is fixed
  • Loading branch information
apavlo committed Mar 21, 2012
1 parent 7c7a365 commit e889abb
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 53 deletions.
15 changes: 5 additions & 10 deletions src/frontend/edu/brown/optimizer/PlanOptimizerUtil.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -503,22 +503,17 @@ public static boolean updateAggregateColumns(final PlanOptimizerState state, Agg
int new_idx = 0; int new_idx = 0;
for (Integer guid : child_node.getOutputColumnGUIDs()) { for (Integer guid : child_node.getOutputColumnGUIDs()) {
PlanColumn pc = state.plannerContext.get(guid); PlanColumn pc = state.plannerContext.get(guid);
if (pc.getStorage().equals(Storage.kTemporary)) { assert (pc != null);
if (pc.equals(orig_pc, true, true)) {
if (trace.get())
LOG.trace(String.format("[%02d] Found non-expression PlanColumn match:\nORIG: %s\nNEW: %s", new_idx, orig_pc, pc));
new_pc = pc; new_pc = pc;
break; break;
} else {
assert (pc != null);
if (pc.equals(orig_pc, true, true)) {
if (trace.get())
LOG.trace(String.format("[%02d] Found non-expression PlanColumn match:\nORIG: %s\nNEW: %s", new_idx, orig_pc, pc));
new_pc = pc;
break;
}
} }
new_idx++; new_idx++;
} // FOR } // FOR
if (new_pc == null) { if (new_pc == null) {
LOG.error(String.format("Couldn't find %d => %s\n", new_idx, new_pc)); LOG.error(String.format("Failed to find %d => %s\n", new_idx, new_pc));
LOG.error(PlanNodeUtil.debug(PlanNodeUtil.getRoot(node))); LOG.error(PlanNodeUtil.debug(PlanNodeUtil.getRoot(node)));
} }
assert (new_pc != null); assert (new_pc != null);
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1004,11 +1004,10 @@ static public junit.framework.Test suite() {
builder.addServerConfig(config);*/ builder.addServerConfig(config);*/


// CLUSTER! // CLUSTER!
// 2012-03-16 - DISABLED UNTIL WE GET A BETTER BUILD AND TEST SERVER config = new LocalCluster("fixedsql-cluster.jar", 2, 2,
// config = new LocalCluster("fixedsql-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
// 1, BackendTarget.NATIVE_EE_JNI); config.compile(project);
// config.compile(project); builder.addServerConfig(config);
// builder.addServerConfig(config);


return builder; return builder;
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -219,20 +219,17 @@ static public Test suite() {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////


// get a server config that similar, but doesn't use the same backend // get a server config that similar, but doesn't use the same backend
config = new LocalSingleProcessServer("distregression-hsql.jar", 1, BackendTarget.HSQLDB_BACKEND); // config = new LocalSingleProcessServer("distregression-hsql.jar", 1, BackendTarget.HSQLDB_BACKEND);

// build the jarfile (note the reuse of the TPCC project) // build the jarfile (note the reuse of the TPCC project)
config.compile(project); // config.compile(project);

// add this config to the set of tests to run // add this config to the set of tests to run
builder.addServerConfig(config); // builder.addServerConfig(config);


// Cluster // Cluster
// 2012-03-16 - DISABLED UNTIL WE GET A BETTER BUILD AND TEST SERVER config = new LocalCluster("distregression-cluster.jar", 2, 2,
// config = new LocalCluster("distregression-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
// 1, BackendTarget.NATIVE_EE_JNI); config.compile(project);
// config.compile(project); builder.addServerConfig(config);
// builder.addServerConfig(config);


return builder; return builder;
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
package edu.brown.optimizer; package org.voltdb.regressionsuites;


import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
Expand All @@ -17,16 +17,24 @@
import org.voltdb.client.ClientResponse; import org.voltdb.client.ClientResponse;
import org.voltdb.client.ProcCallException; import org.voltdb.client.ProcCallException;
import org.voltdb.compiler.VoltProjectBuilder; import org.voltdb.compiler.VoltProjectBuilder;
import org.voltdb.regressionsuites.LocalCluster;
import org.voltdb.regressionsuites.LocalSingleProcessServer; import org.voltdb.regressionsuites.LocalSingleProcessServer;
import org.voltdb.regressionsuites.MultiConfigSuiteBuilder; import org.voltdb.regressionsuites.MultiConfigSuiteBuilder;
import org.voltdb.regressionsuites.RegressionSuite; import org.voltdb.regressionsuites.RegressionSuite;
import org.voltdb.regressionsuites.VoltServerConfig; import org.voltdb.regressionsuites.VoltServerConfig;


import edu.brown.catalog.CatalogUtil; import edu.brown.catalog.CatalogUtil;
import edu.brown.hstore.Hstoreservice.Status; import edu.brown.hstore.Hstoreservice.Status;
import edu.brown.optimizer.BasePlanOptimizerTestCase;
import edu.brown.utils.StringUtil; import edu.brown.utils.StringUtil;


public class TestPlanOptimizerRegressionSuite extends RegressionSuite { /**
* Special test cases for checking complex operations in the PlanOptimizer
* @author pavlo
*/
public class TestPlanOptimizerSuite extends RegressionSuite {

private static final String PREFIX = "planopt";


@Test @Test
public void testSingleAggregate() throws IOException, ProcCallException { public void testSingleAggregate() throws IOException, ProcCallException {
Expand Down Expand Up @@ -106,14 +114,16 @@ public void testMultipleAggregates() throws IOException, ProcCallException {
Map<Integer, List<Double>> expectedValues = new HashMap<Integer, List<Double>>(); Map<Integer, List<Double>> expectedValues = new HashMap<Integer, List<Double>>();
for (Integer c_b_a_id : values.keySet()) { for (Integer c_b_a_id : values.keySet()) {
for (List<Integer> vals : values.get(c_b_a_id)) { for (List<Integer> vals : values.get(c_b_a_id)) {
if (expectedValues.containsKey(c_b_a_id) == false) { List<Double> colValues = expectedValues.get(c_b_a_id);
expectedValues.put(c_b_a_id, new ArrayList<Double>()); if (colValues == null) {
colValues = new ArrayList<Double>();
expectedValues.put(c_b_a_id, colValues);
} }
int total = 0; int total = 0;
for (Integer val : vals) { for (Integer val : vals) {
total += val.intValue(); total += val.intValue();
} // FOR } // FOR
expectedValues.get(c_b_a_id).add(total / (double)values.get(c_b_a_id).size()); colValues.add(total / (double)vals.size());
} // FOR } // FOR
} // FOR } // FOR


Expand All @@ -124,15 +134,15 @@ public void testMultipleAggregates() throws IOException, ProcCallException {
assertNotNull(result); assertNotNull(result);
System.err.println(result); System.err.println(result);


int query_offsets[] = { 4, 5 }; int query_offsets[] = { 3, 4 };
int expected_offsets[] = { 3, 4 }; int expected_offsets[] = { 3, 4 };
while (result.advanceRow()) { while (result.advanceRow()) {
Integer c_b_a_id = Integer.valueOf((int)result.getLong(0)); Integer c_b_a_id = Integer.valueOf((int)result.getLong(0));
for (int i = 0; i < query_offsets.length; i++) { for (int i = 0; i < query_offsets.length; i++) {
double actual = result.getDouble(query_offsets[i]); double actual = result.getDouble(query_offsets[i]);
Double expected = expectedValues.get(c_b_a_id).get(expected_offsets[i]); Double expected = expectedValues.get(c_b_a_id).get(expected_offsets[i]);
assertNotNull(c_b_a_id.toString(), expected); assertNotNull(c_b_a_id.toString(), expected);
System.err.printf("EXPECTED[%d] => %.1f\n", c_b_a_id, expected); System.err.printf("[%d] => EXPECTED:%.1f / ACTUAL:%.1f\n", c_b_a_id, expected, actual);
assertEquals(c_b_a_id.toString(), expected.doubleValue(), actual, 0.1); assertEquals(c_b_a_id.toString(), expected.doubleValue(), actual, 0.1);
} // FOR } // FOR
} // WHILE } // WHILE
Expand Down Expand Up @@ -173,13 +183,13 @@ protected VoltTable loadTable(Client client) throws IOException, ProcCallExcepti
* JUnit / RegressionSuite Boilerplate Constructor * JUnit / RegressionSuite Boilerplate Constructor
* @param name The name of this test suite * @param name The name of this test suite
*/ */
public TestPlanOptimizerRegressionSuite(String name) { public TestPlanOptimizerSuite(String name) {
super(name); super(name);
} }


static public junit.framework.Test suite() { static public junit.framework.Test suite() {
MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestPlanOptimizerRegressionSuite.class); MultiConfigSuiteBuilder builder = new MultiConfigSuiteBuilder(TestPlanOptimizerSuite.class);
VoltProjectBuilder project = new BasePlanOptimizerTestCase.PlanOptimizerTestProjectBuilder("planoptreg"); VoltProjectBuilder project = new BasePlanOptimizerTestCase.PlanOptimizerTestProjectBuilder(PREFIX);
VoltServerConfig config = null; VoltServerConfig config = null;


// Single Statement Procedures // Single Statement Procedures
Expand All @@ -193,15 +203,15 @@ static public junit.framework.Test suite() {


// CLUSTER CONFIG #1 // CLUSTER CONFIG #1
// One site with four partitions running in this JVM // One site with four partitions running in this JVM
config = new LocalSingleProcessServer("planoptreg-twoPart.jar", 4, BackendTarget.NATIVE_EE_JNI); config = new LocalSingleProcessServer(PREFIX + "-twoPart.jar", 4, BackendTarget.NATIVE_EE_JNI);
config.compile(project); config.compile(project);
builder.addServerConfig(config); builder.addServerConfig(config);


// CLUSTER CONFIG #2 // CLUSTER CONFIG #2
// Two sites, each with two partitions running in separate JVMs // Two sites, each with two partitions running in separate JVMs
// config = new LocalCluster("planoptreg-twoSiteTwoPart.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI); config = new LocalCluster(PREFIX + "-twoSiteTwoPart.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
// config.compile(project); config.compile(project);
// builder.addServerConfig(config); builder.addServerConfig(config);


return builder; return builder;
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -333,11 +333,10 @@ static public Test suite() {
// CONFIG #4: Local Cluster (of processes) // CONFIG #4: Local Cluster (of processes)
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////


// 2012-03-16 - DISABLED UNTIL WE GET A BETTER BUILD AND TEST SERVER config = new LocalCluster("sqlfeatures-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
// config = new LocalCluster("sqlfeatures-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI); success = config.compile(project);
// success = config.compile(project); assert(success);
// assert(success); builder.addServerConfig(config);
// builder.addServerConfig(config);


return builder; return builder;
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1092,10 +1092,9 @@ static public junit.framework.Test suite() {
builder.addServerConfig(config); builder.addServerConfig(config);


// CLUSTER? // CLUSTER?
// 2012-03-16 - DISABLED UNTIL WE GET A BETTER BUILD AND TEST SERVER config = new LocalCluster("sqltypes-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
// config = new LocalCluster("sqltypes-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI); config.compile(project);
// config.compile(project); builder.addServerConfig(config);
// builder.addServerConfig(config);


return builder; return builder;
} }
Expand Down
9 changes: 4 additions & 5 deletions tests/frontend/org/voltdb/regressionsuites/TestTPCCSuite.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -820,11 +820,10 @@ static public Test suite() {
// CONFIG #2: cluster of 2 nodes running 2 site each, one replica // CONFIG #2: cluster of 2 nodes running 2 site each, one replica
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////


// 2012-03-16 - DISABLED UNTIL WE GET A BETTER BUILD AND TEST SERVER config = new LocalCluster("tpcc-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI);
// config = new LocalCluster("tpcc-cluster.jar", 2, 2, 1, BackendTarget.NATIVE_EE_JNI); success = config.compile(project);
// success = config.compile(project); assert(success);
// assert(success); builder.addServerConfig(config);
// builder.addServerConfig(config);


return builder; return builder;
} }
Expand Down

0 comments on commit e889abb

Please sign in to comment.