Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- db_bench_sqlite3.cc.orig 2011-07-28 23:46:04.000000000 +0400
- +++ db_bench_sqlite3.cc 2011-07-29 05:27:58.000000000 +0400
- @@ -74,7 +74,7 @@
- static bool FLAGS_transaction = true;
- // If true, we enable Write-Ahead Logging
- -static bool FLAGS_WAL_enabled = false;
- +static bool FLAGS_WAL_enabled = true;
- inline
- static void ExecErrorCheck(int status, char *err_msg) {
- @@ -454,10 +454,10 @@
- // Change locking mode to exclusive and create tables/index for database
- std::string locking_stmt = "PRAGMA locking_mode = EXCLUSIVE";
- + std::string wal_stmt = "PRAGMA wal_autocheckpoint = 4096";
- std::string create_stmt =
- - "CREATE TABLE test (key blob, value blob, PRIMARY KEY(key))";
- - std::string index_stmt = "CREATE INDEX keyindex ON test (key)";
- - std::string stmt_array[] = { locking_stmt, create_stmt, index_stmt };
- + "CREATE TABLE test (key INTEGER PRIMARY KEY, value blob)";
- + std::string stmt_array[] = { locking_stmt, wal_stmt, create_stmt };
- int stmt_array_length = sizeof(stmt_array) / sizeof(std::string);
- for (int i = 0; i < stmt_array_length; i++) {
- status = sqlite3_exec(db_, stmt_array[i].c_str(), NULL, NULL, &err_msg);
- @@ -494,7 +494,7 @@
- std::string end_trans_str = "END TRANSACTION;";
- // Check for synchronous flag in options
- - std::string sync_stmt = (write_sync) ? "PRAGMA synchronous = FULL" :
- + std::string sync_stmt = (write_sync) ? "PRAGMA synchronous = NORMAL" :
- "PRAGMA synchronous = OFF";
- status = sqlite3_exec(db_, sync_stmt.c_str(), NULL, NULL, &err_msg);
- ExecErrorCheck(status, err_msg);
- @@ -527,18 +527,16 @@
- // Create values for key-value pair
- const int k = (order == SEQUENTIAL) ? i + j :
- (rand_.Next() % num_entries);
- - char key[100];
- - snprintf(key, sizeof(key), "%016d", k);
- // Bind KV values into replace_stmt
- - status = sqlite3_bind_blob(replace_stmt, 1, key, 16, SQLITE_STATIC);
- + status = sqlite3_bind_int(replace_stmt, 1, k);
- ErrorCheck(status);
- status = sqlite3_bind_blob(replace_stmt, 2, value,
- value_size, SQLITE_STATIC);
- ErrorCheck(status);
- // Execute replace_stmt
- - bytes_ += value_size + strlen(key);
- + bytes_ += value_size + sizeof(k);
- status = sqlite3_step(replace_stmt);
- StepErrorCheck(status);
- @@ -599,12 +597,10 @@
- // Create and execute SQL statements
- for (int j = 0; j < entries_per_batch; j++) {
- // Create key value
- - char key[100];
- int k = (order == SEQUENTIAL) ? i + j : (rand_.Next() % reads_);
- - snprintf(key, sizeof(key), "%016d", k);
- // Bind key value into read_stmt
- - status = sqlite3_bind_blob(read_stmt, 1, key, 16, SQLITE_STATIC);
- + status = sqlite3_bind_int(read_stmt, 1, k);
- ErrorCheck(status);
- // Execute read statement
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement