*
*
*/
public void testFillUp() {
StopWatch sw = new StopWatch();
String ddl1 = "DROP TABLE test IF EXISTS";
String ddl11 = "DROP TABLE zip IF EXISTS";
String ddl2 = "CREATE TABLE zip( zip INT IDENTITY )";
String ddl3 = "CREATE " + tableType + " TABLE test( id INT IDENTITY,"
+ " firstname VARCHAR(20), "
+ " lastname VARCHAR(20), " + " zip INTEGER, "
+ " filler VARCHAR(300))";
String ddl31 = "SET TABLE test SOURCE \"test.csv;cache_scale="
+ cacheScale + "\"";
// adding extra index will slow down inserts a bit
String ddl4 = "CREATE INDEX idx1 ON TEST (lastname)";
// adding this index will slow down inserts a lot
String ddl5 = "CREATE INDEX idx2 ON TEST (zip)";
// referential integrity checks will slow down inserts a bit
String ddl6 =
"ALTER TABLE test add constraint c1 FOREIGN KEY (zip) REFERENCES zip(zip) ON DELETE CASCADE;";
String ddl7 = "CREATE TEMP TABLE temptest( id INT,"
+ " firstname VARCHAR, " + " lastname VARCHAR, "
+ " zip INTEGER, " + " filler VARCHAR)";
String filler =
"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
String mddl1 = "DROP TABLE test2 IF EXISTS";
String mddl2 = "CREATE " + tableType
+ " TABLE test2( id1 INT, id2 INT,"
+ " firstname VARCHAR, " + " lastname VARCHAR, "
+ " zip INTEGER, " + " filler VARCHAR, "
+ " PRIMARY KEY (id1,id2) )";
String mdd13 = "SET TABLE test2 SOURCE \"test2.csv;cache_scale="
+ cacheScale + "\"";
try {
// System.out.println("Connecting");
sw.zero();
cConnection = null;
sStatement = null;
cConnection = DriverManager.getConnection(url + filepath, user,
password);
System.out.println("connection time -- " + sw.elapsedTime());
sw.zero();
sStatement = cConnection.createStatement();
java.util.Random randomgen = new java.util.Random();
// sStatement.execute("SET WRITE_DELAY " + writeDelay);
sStatement.execute(ddl1);
sStatement.execute(ddl2);
sStatement.execute(ddl3);
if (tableType.equals("TEXT")) {
sStatement.execute(ddl31);
}
// System.out.println("test table with no index");
if (indexLastName) {
sStatement.execute(ddl4);
System.out.println("created index on lastname");
}
if (indexZip) {
sStatement.execute(ddl5);
System.out.println("created index on zip");
}
if (addForeignKey) {
sStatement.execute(ddl6);
System.out.println("added foreign key");
}
if (createTempTable) {
sStatement.execute(ddl7);
System.out.println("created temp table");
}
if (multikeytable) {
sStatement.execute(mddl1);
sStatement.execute(mddl2);
if (tableType.equals("TEXT")) {
sStatement.execute(mdd13);
}
System.out.println("created multi key table");
}
// sStatement.execute("CREATE INDEX idx3 ON tempTEST (zip);");
System.out.println("complete setup time -- " + sw.elapsedTime()
+ " ms");
fillUpBigTable(filler, randomgen);
if (multikeytable) {
fillUpMultiTable(filler, randomgen);
}
sw.zero();
if (shutdown) {
sStatement.execute("SHUTDOWN");
long time = sw.elapsedTime();
storeResult("shutdown", 0, time, 0);
System.out.println("shutdown time -- " + time + " ms");
}