public void TestStats() { testName = "TestStats"; SetUpTest(true); string dbFileName = testHome + "/" + testName + ".db"; RecnoDatabaseConfig dbConfig = new RecnoDatabaseConfig(); ConfigCase1(dbConfig); RecnoDatabase db = RecnoDatabase.Open(dbFileName, dbConfig); RecnoStats stats = db.Stats(); ConfirmStatsPart1Case1(stats); // Put 1000 records into the database. PutRecordCase1(db, null); stats = db.Stats(); ConfirmStatsPart2Case1(stats); // Delete 500 records. for (int i = 250; i <= 750; i++) { db.Delete(new DatabaseEntry(BitConverter.GetBytes(i))); } stats = db.Stats(); ConfirmStatsPart3Case1(stats); db.Close(); }
public void ModifyRecordsInDB(RecnoDatabase db, Transaction txn) { uint[] recnos = new uint[100]; if (txn == null) { // Add a lot of records into database. for (int i = 0; i < 100; i++) { recnos[i] = db.Append(new DatabaseEntry( new byte[10240])); } // Remove some records from database. for (int i = 30; i < 100; i++) { db.Delete(new DatabaseEntry( BitConverter.GetBytes(recnos[i]))); } } else { // Add a lot of records into database in txn. for (int i = 0; i < 100; i++) { recnos[i] = db.Append(new DatabaseEntry( new byte[10240]), txn); } // Remove some records from database in txn. for (int i = 30; i < 100; i++) { db.Delete(new DatabaseEntry( BitConverter.GetBytes(recnos[i])), txn); } } }
public void StatsInTxn(string home, string name, bool ifIsolation) { DatabaseEnvironmentConfig envConfig = new DatabaseEnvironmentConfig(); EnvConfigCase1(envConfig); DatabaseEnvironment env = DatabaseEnvironment.Open( home, envConfig); Transaction openTxn = env.BeginTransaction(); RecnoDatabaseConfig dbConfig = new RecnoDatabaseConfig(); ConfigCase1(dbConfig); dbConfig.Env = env; RecnoDatabase db = RecnoDatabase.Open(name + ".db", dbConfig, openTxn); openTxn.Commit(); Transaction statsTxn = env.BeginTransaction(); RecnoStats stats; RecnoStats fastStats; if (ifIsolation == false) { stats = db.Stats(statsTxn); fastStats = db.FastStats(statsTxn); } else { stats = db.Stats(statsTxn, Isolation.DEGREE_ONE); fastStats = db.FastStats(statsTxn, Isolation.DEGREE_ONE); } ConfirmStatsPart1Case1(stats); // Put 1000 records into the database. PutRecordCase1(db, statsTxn); if (ifIsolation == false) { stats = db.Stats(statsTxn); fastStats = db.FastStats(statsTxn); } else { stats = db.Stats(statsTxn, Isolation.DEGREE_TWO); fastStats = db.FastStats(statsTxn, Isolation.DEGREE_TWO); } ConfirmStatsPart2Case1(stats); // Delete 500 records. for (int i = 250; i <= 750; i++) { db.Delete(new DatabaseEntry(BitConverter.GetBytes(i)), statsTxn); } if (ifIsolation == false) { stats = db.Stats(statsTxn); fastStats = db.FastStats(statsTxn); } else { stats = db.Stats(statsTxn, Isolation.DEGREE_THREE); fastStats = db.FastStats(statsTxn, Isolation.DEGREE_THREE); } ConfirmStatsPart3Case1(stats); statsTxn.Commit(); db.Close(); env.Close(); }