Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }