Permalink
Browse files

added new file to correctness demos

  • Loading branch information...
jmeehan16 committed Aug 25, 2014
1 parent 5e51020 commit 0bb0f88153716e2e83d59ae7ebfbfe4a39dd9f43
@@ -42,6 +42,7 @@
public static final String OUTPUT_FILE = "logs/demohstoreout.txt";
public static final String OVERWRITE_FILE = "logs/demohstorecurrent.txt";
public static final String CONTESTANTS_FILE = "logs/hstorecontestants.txt";
public static final String VOTE_FILE = "demo/demo-votes.txt";
public static final int DELETE_CODE = -1;
public static final boolean SOCKET_CONTROL = true;
@@ -41,7 +41,7 @@
import org.voltdb.VoltTable;
import edu.brown.benchmark.voterexperiments.demosstorecorrect.VoterDemoSStoreConstants;
import edu.brown.benchmark.voterexperiments.demohstorecorrect.VoterDemoHStoreConstants;
import edu.brown.rand.RandomDistribution.Zipf;
public abstract class VoterDemoHStoreUtil {
@@ -319,6 +319,11 @@ private static void closeAllFiles(ArrayList<PrintWriter> p)
}
}
public static void writeToContestantsFile(VoltTable[] v, ArrayList<String> tableNames, int numVotes) throws IOException
{
writeToFile(v,tableNames,numVotes,VoterDemoHStoreConstants.CONTESTANTS_FILE);
}
public static void writeToFile(VoltTable[] v, ArrayList<String> tableNames, int numVotes) throws IOException
{
ArrayList<PrintWriter> out = new ArrayList<PrintWriter>();
@@ -362,5 +367,47 @@ public static void writeToFile(VoltTable[] v, ArrayList<String> tableNames, int
}
closeAllFiles(out);
}
public static void writeToFile(VoltTable[] v, ArrayList<String> tableNames, int numVotes, String filename) throws IOException
{
PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(filename, false)));
if(numVotes == VoterDemoHStoreConstants.DELETE_CODE)
{
p.print("####DELETECANDIDATE####\n");
}
else
p.print("####" + numVotes + "####\n");
for(int i = 0; i < v.length; i++)
{
String tableName = tableNames.get(i);
p.print("**" + tableName + "**\n");
int j = 0;
while(j < v[i].getRowCount())
{
for(int k = 0; k < v[i].getColumnCount(); k++)
{
if(k > 0)
{
p.print(",");
}
p.print((v[i].fetchRow(j).get(k)).toString());
}
p.print("\n");
j++;
}
if(tableName.endsWith("Three"))
{
while(j < 3)
{
p.print("-----,0\n");
j++;
}
}
p.print("---------------------------\n");
}
p.close();
}
}
@@ -121,7 +121,8 @@
public final SQLStmt getActualVoteCountStmt = new SQLStmt( "SELECT totalcnt, successcnt FROM proc_one_count WHERE row_id = 1;");
public final SQLStmt getTrendingCountStmt = new SQLStmt("SELECT count(*) FROM w_rows;");
public final SQLStmt getRemainingContestants = new SQLStmt("SELECT count(*) FROM contestants;");
public final SQLStmt getRemovedContestant = new SQLStmt("SELECT contestant_name, num_votes FROM removed_contestant WHERE row_id = 1;");
public final SQLStmt getRemovedContestants = new SQLStmt("SELECT row_id, contestant_name, num_votes FROM removed_contestant ORDER BY row_id DESC;");
public final SQLStmt getAllRemainingContestants = new SQLStmt("SELECT c.contestant_name, v.num_votes FROM v_votes_by_contestant v JOIN contestants c ON v.contestant_number = c.contestant_number ORDER BY num_votes DESC;");
public final SQLStmt getVotesTilNextDeleteStmt = new SQLStmt( "SELECT cnt FROM votes_next_delete WHERE row_id=1;");
/////////////////////////////
//END GET RESULTS
@@ -162,6 +163,13 @@ private void printResults() throws IOException
VoltTable[] v = voltExecuteSQL();
VoterDemoHStoreUtil.writeToFile(v, tableNames, VoterDemoHStoreConstants.DELETE_CODE);
voltQueueSQL(getAllRemainingContestants);
tableNames.add("RemainingContestants");
voltQueueSQL(getRemovedContestants);
tableNames.add("RemovedContestants");
v = voltExecuteSQL();
VoterDemoHStoreUtil.writeToContestantsFile(v, tableNames, VoterDemoHStoreConstants.DELETE_CODE);
}
public long run() {
@@ -39,7 +39,6 @@
import org.voltdb.VoltTable;
import org.voltdb.types.TimestampType;
import edu.brown.benchmark.voter.VoterConstants;
import edu.brown.benchmark.voterexperiments.demohstorecorrect.VoterDemoHStoreConstants;
import edu.brown.benchmark.voterexperiments.demohstorecorrect.VoterDemoHStoreUtil;
@@ -141,7 +140,8 @@
public final SQLStmt getActualVoteCountStmt = new SQLStmt( "SELECT totalcnt, successcnt FROM proc_one_count WHERE row_id = 1;");
public final SQLStmt getTrendingCountStmt = new SQLStmt("SELECT count(*) FROM w_rows;");
public final SQLStmt getRemainingContestants = new SQLStmt("SELECT count(*) FROM contestants;");
public final SQLStmt getRemovedContestant = new SQLStmt("SELECT contestant_name, num_votes FROM removed_contestant WHERE row_id = 1;");
public final SQLStmt getRemovedContestants = new SQLStmt("SELECT row_id, contestant_name, num_votes FROM removed_contestant ORDER BY row_id DESC;");
public final SQLStmt getAllRemainingContestants = new SQLStmt("SELECT c.contestant_name, v.num_votes FROM v_votes_by_contestant v JOIN contestants c ON v.contestant_number = c.contestant_number ORDER BY num_votes DESC;");
public final SQLStmt getVotesTilNextDeleteStmt = new SQLStmt( "SELECT cnt FROM votes_next_delete WHERE row_id=1;");
/////////////////////////////
//END GET RESULTS
@@ -183,6 +183,12 @@ private void printResults(int numVotes) throws IOException
VoltTable[] v = voltExecuteSQL();
VoterDemoHStoreUtil.writeToFile(v, tableNames, numVotes);
voltQueueSQL(getAllRemainingContestants);
tableNames.add("RemainingContestants");
voltQueueSQL(getRemovedContestants);
tableNames.add("RemovedContestants");
v = voltExecuteSQL();
VoterDemoHStoreUtil.writeToContestantsFile(v, tableNames, VoterDemoHStoreConstants.DELETE_CODE);
}
@@ -42,6 +42,7 @@
public static final String OUTPUT_FILE = "logs/demosstoreout.txt";
public static final String OVERWRITE_FILE = "logs/demosstorecurrent.txt";
public static final String CONTESTANTS_FILE = "logs/sstorecontestants.txt";
public static final String VOTE_FILE = "demo/demo-votes.txt";
public static final int DELETE_CODE = -1;
public static final boolean SOCKET_CONTROL = true;
@@ -318,6 +318,11 @@ private static void closeAllFiles(ArrayList<PrintWriter> p)
}
}
public static void writeToContestantsFile(VoltTable[] v, ArrayList<String> tableNames, int numVotes) throws IOException
{
writeToFile(v,tableNames,numVotes,VoterDemoSStoreConstants.CONTESTANTS_FILE);
}
public static void writeToFile(VoltTable[] v, ArrayList<String> tableNames, int numVotes) throws IOException
{
ArrayList<PrintWriter> out = new ArrayList<PrintWriter>();
@@ -361,5 +366,47 @@ public static void writeToFile(VoltTable[] v, ArrayList<String> tableNames, int
}
closeAllFiles(out);
}
public static void writeToFile(VoltTable[] v, ArrayList<String> tableNames, int numVotes, String filename) throws IOException
{
PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(filename, false)));
if(numVotes == VoterDemoSStoreConstants.DELETE_CODE)
{
p.print("####DELETECANDIDATE####\n");
}
else
p.print("####" + numVotes + "####\n");
for(int i = 0; i < v.length; i++)
{
String tableName = tableNames.get(i);
p.print("**" + tableName + "**\n");
int j = 0;
while(j < v[i].getRowCount())
{
for(int k = 0; k < v[i].getColumnCount(); k++)
{
if(k > 0)
{
p.print(",");
}
p.print((v[i].fetchRow(j).get(k)).toString());
}
p.print("\n");
j++;
}
if(tableName.endsWith("Three"))
{
while(j < 3)
{
p.print("-----,0\n");
j++;
}
}
p.print("---------------------------\n");
}
p.close();
}
}
@@ -49,7 +49,6 @@
import org.voltdb.VoltTable;
import org.voltdb.types.TimestampType;
import edu.brown.benchmark.voterexperiments.demohstorecorrect.VoterDemoHStoreConstants;
import edu.brown.benchmark.voterexperiments.demosstorecorrect.VoterDemoSStoreConstants;
import edu.brown.benchmark.voterexperiments.demosstorecorrect.VoterDemoSStoreUtil;
@@ -133,7 +132,8 @@ protected void toSetTriggerTableName()
public final SQLStmt getActualVoteCountStmt = new SQLStmt( "SELECT totalcnt, successcnt FROM proc_one_count WHERE row_id = 1;");
public final SQLStmt getTrendingCountStmt = new SQLStmt("SELECT count(*) FROM trending_leaderboard;");
public final SQLStmt getRemainingContestants = new SQLStmt("SELECT count(*) FROM contestants;");
public final SQLStmt getRemovedContestant = new SQLStmt("SELECT contestant_name, num_votes FROM removed_contestant WHERE row_id = 1;");
public final SQLStmt getRemovedContestants = new SQLStmt("SELECT row_id, contestant_name, num_votes FROM removed_contestant ORDER BY row_id DESC;");
public final SQLStmt getAllRemainingContestants = new SQLStmt("SELECT c.contestant_name, v.num_votes FROM v_votes_by_contestant v JOIN contestants c ON v.contestant_number = c.contestant_number ORDER BY num_votes DESC;");
public final SQLStmt getVotesTilNextDeleteStmt = new SQLStmt( "SELECT cnt FROM votes_next_delete WHERE row_id=1;");
/////////////////////////////
//END GET RESULTS
@@ -174,6 +174,13 @@ private void printResults() throws IOException
VoltTable[] v = voltExecuteSQL();
VoterDemoSStoreUtil.writeToFile(v, tableNames, VoterDemoSStoreConstants.DELETE_CODE);
voltQueueSQL(getAllRemainingContestants);
tableNames.add("RemainingContestants");
voltQueueSQL(getRemovedContestants);
tableNames.add("RemovedContestants");
v = voltExecuteSQL();
VoterDemoSStoreUtil.writeToContestantsFile(v, tableNames, VoterDemoSStoreConstants.DELETE_CODE);
}
public long run() {
@@ -197,7 +204,7 @@ public long run() {
if(remainingContestants <= 1)
{
return VoterDemoHStoreConstants.BM_FINISHED;
return VoterDemoSStoreConstants.BM_FINISHED;
}
voltQueueSQL(insertRemovedContestant, remainingContestants, lowestConName, lowestConVotes);
@@ -140,7 +140,8 @@
public final SQLStmt getActualVoteCountStmt = new SQLStmt( "SELECT totalcnt, successcnt FROM proc_one_count WHERE row_id = 1;");
public final SQLStmt getTrendingCountStmt = new SQLStmt("SELECT count(*) FROM trending_leaderboard;");
public final SQLStmt getRemainingContestants = new SQLStmt("SELECT count(*) FROM contestants;");
public final SQLStmt getRemovedContestant = new SQLStmt("SELECT contestant_name, num_votes FROM removed_contestant WHERE row_id = 1;");
public final SQLStmt getRemovedContestants = new SQLStmt("SELECT row_id, contestant_name, num_votes FROM removed_contestant ORDER BY row_id DESC;");
public final SQLStmt getAllRemainingContestants = new SQLStmt("SELECT c.contestant_name, v.num_votes FROM v_votes_by_contestant v JOIN contestants c ON v.contestant_number = c.contestant_number ORDER BY num_votes DESC;");
public final SQLStmt getVotesTilNextDeleteStmt = new SQLStmt( "SELECT cnt FROM votes_next_delete WHERE row_id=1;");
/////////////////////////////
//END GET RESULTS
@@ -182,6 +183,12 @@ private void printResults(int numVotes) throws IOException
VoltTable[] v = voltExecuteSQL();
VoterDemoSStoreUtil.writeToFile(v, tableNames, numVotes);
voltQueueSQL(getAllRemainingContestants);
tableNames.add("RemainingContestants");
voltQueueSQL(getRemovedContestants);
tableNames.add("RemovedContestants");
v = voltExecuteSQL();
VoterDemoSStoreUtil.writeToContestantsFile(v, tableNames, VoterDemoSStoreConstants.DELETE_CODE);
}

0 comments on commit 0bb0f88

Please sign in to comment.