Permalink
Browse files

fixed bug with reconfiguration pairs

  • Loading branch information...
Rebecca Taft
Rebecca Taft committed Mar 14, 2014
1 parent 86e5e83 commit 6d5ae04a1edfa3996ff43267732d05b74991397b
@@ -54,6 +54,12 @@ public String toString() {
return String.format("(%s->%s)", from, to);
}
@Override
public final int hashCode() {
return (from == null ? 0 : from.hashCode() * 31) +
(to == null ? 0 : to.hashCode());
}
/**
* @param o Object to compare to.
* @return Is the object equal to a value in the pair.
@@ -116,7 +116,10 @@ public Plan computePlan(ArrayList<Map<Long, Long>> hotTuplesList, Map<Integer, L
List<Plan.Range> oldRanges = aPlan.getRangeValues(i, r.from, r.to);
for(Plan.Range oldRange : oldRanges) {
aPlan.removeRange(i, oldRange.from);
aPlan.addRange(dstPartition, Math.max(oldRange.from, r.from), Math.min(oldRange.to, r.to));
if(!aPlan.hasPartition(dstPartition)) {
aPlan.addPartition(dstPartition);
}
aPlan.addRange(dstPartition, Math.max(oldRange.from, r.from), Math.min(oldRange.to, r.to));
if(oldRange.from < r.from) {
aPlan.addRange(i, oldRange.from, r.from - 1);
@@ -4,12 +4,15 @@
package edu.brown.hstore.reconfiguration;
import java.io.File;
import java.util.Set;
import java.util.HashSet;
import org.junit.Test;
import edu.brown.BaseTestCase;
import edu.brown.hashing.ReconfigurationPlan;
import edu.brown.hashing.TwoTieredRangePartitions;
import edu.brown.hstore.reconfiguration.ReconfigurationUtil.ReconfigurationPair;
import edu.brown.utils.FileUtil;
import edu.brown.utils.ProjectType;
@@ -30,10 +33,19 @@ public void testReconfigurationPair() throws Exception{
ReconfigurationPair pair2 = new ReconfigurationPair(2,1);
ReconfigurationPair pair3 = new ReconfigurationPair(1,3);
ReconfigurationPair pair4 = new ReconfigurationPair(1,2);
assertTrue(pair1 < pair2);
assertTrue(pair1 > pair3);
assertTrue(pair1.compareTo(pair2) < 0);
assertTrue(pair1.compareTo(pair3) > 0);
assertTrue(pair1.compareTo(pair4) == 0);
assertTrue(pair1.equals(pair4));
assertFalse(pair2.equals(pair3));
Set<ReconfigurationPair> reconfigPairs = new HashSet<>();
reconfigPairs.add(pair1);
reconfigPairs.add(pair2);
reconfigPairs.add(pair3);
reconfigPairs.add(pair4);
assertTrue(reconfigPairs.size() == 3);
}
/**

0 comments on commit 6d5ae04

Please sign in to comment.