Exemplo n.º 1
0
        public bool restoreDbTest(
			string	sDbName,
			string	sBackupPath,
			DbSystem	dbSystem)
        {
            MyRestoreStatus	restoreStatus = null;

            // Try restoring the database

            beginTest( "Restore Database Test (from directory \"" + sBackupPath + "\" to " + sDbName + ")");

            restoreStatus = new MyRestoreStatus();
            try
            {
                dbSystem.dbRestore( sDbName, null, null, sBackupPath, null,
                    null, restoreStatus);
            }
            catch (XFlaimException ex)
            {
                endTest( restoreStatus.outputLines(), ex, "restoring database");
                return( false);
            }

            endTest( restoreStatus.outputLines(), true);
            return( true);
        }
Exemplo n.º 2
0
        private IntPtr m_pDataVector; // Pointer to IF_DataVector object in unmanaged space

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Db constructor.
        /// </summary>
        /// <param name="pDataVector">
        /// Reference to an IF_Db object.
        /// </param>
        /// <param name="dbSystem">
        /// DbSystem object that this Db object is associated with.
        /// </param>
        internal DataVector(
			IntPtr	pDataVector,
			DbSystem	dbSystem)
        {
            if (pDataVector == IntPtr.Zero)
            {
                throw new XFlaimException( "Invalid IF_DataVector reference");
            }

            m_pDataVector = pDataVector;

            if (dbSystem == null)
            {
                throw new XFlaimException( "Invalid DbSystem reference");
            }

            m_dbSystem = dbSystem;

            // Must call something inside of DbSystem.  Otherwise, the
            // m_dbSystem object gets a compiler warning on linux because
            // it is not used anywhere.  Other than that, there is really
            // no need to make the following call.
            if (m_dbSystem.getDbSystem() == IntPtr.Zero)
            {
                throw new XFlaimException( "Invalid DbSystem.IF_DbSystem object");
            }
        }
Exemplo n.º 3
0
        public bool createDbTest(
			string	sDbName,
			DbSystem	dbSystem)
        {
            Db			db = null;
            RCODE	rc;

            beginTest( "Create Database Test (" + sDbName + ")");

            for (;;)
            {
                rc = RCODE.NE_XFLM_OK;
                try
                {
                    XFLM_CREATE_OPTS	createOpts = new XFLM_CREATE_OPTS();

                    createOpts.uiBlockSize = 8192;
                    createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
                    createOpts.uiMinRflFileSize = 2000000;
                    createOpts.uiMaxRflFileSize = 20000000;
                    createOpts.bKeepRflFiles = 1;
                    createOpts.bLogAbortedTransToRfl = 1;
                    createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
                    db = dbSystem.dbCreate( sDbName, null, null, null, null, createOpts);
                }
                catch (XFlaimException ex)
                {
                    rc = ex.getRCode();

                    if (rc != RCODE.NE_XFLM_FILE_EXISTS)
                    {
                        endTest( false, ex, "creating database");
                        return( false);
                    }
                }
                if (rc == RCODE.NE_XFLM_OK)
                {
                    break;
                }

                // rc better be NE_XFLM_FILE_EXISTS - try to delete the file

                try
                {
                    dbSystem.dbRemove( sDbName, null, null, true);
                }
                catch (XFlaimException ex)
                {
                    endTest( false, ex, "removing database");
                    return( false);
                }
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            endTest( false, true);
            return( true);
        }
Exemplo n.º 4
0
        public bool openDbTest(
			string	sDbName,
			DbSystem	dbSystem)
        {
            Db	db = null;

            beginTest( "Open Database Test (" + sDbName + ")");

            try
            {
                db = dbSystem.dbOpen( sDbName, null, null, null, false);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "opening database");
                return( false);
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            endTest( false, true);
            return( true);
        }
Exemplo n.º 5
0
        public bool checkDbTest(
			string	sDbName,
			DbSystem	dbSystem)
        {
            MyDbCheckStatus	dbCheckStatus = null;
            DbInfo				dbInfo = null;
            XFLM_DB_HDR			dbHdr = new XFLM_DB_HDR();

            // Try restoring the database

            beginTest( "Check Database Test (" + sDbName + ")");

            dbCheckStatus = new MyDbCheckStatus();
            try
            {
                dbInfo = dbSystem.dbCheck( sDbName, null, null, null,
                    DbCheckFlags.XFLM_ONLINE | DbCheckFlags.XFLM_DO_LOGICAL_CHECK,
                    dbCheckStatus);
            }
            catch (XFlaimException ex)
            {
                endTest( dbCheckStatus.outputLines(), ex, "checking database");
                return( false);
            }

            dbInfo.getDbHdr( dbHdr);
            System.Console.Write( "\n");
            System.Console.WriteLine( "Signature............. {0}", dbHdr.szSignature);
            System.Console.WriteLine( "Database Version...... {0}", dbHdr.ui32DbVersion);
            System.Console.WriteLine( "Block Size............ {0}", dbHdr.ui16BlockSize);

            if (dbHdr.szSignature != "FLAIMDB")
            {
                endTest( true, false);
                System.Console.WriteLine( "Invalid signature in database header");
                return( false);
            }
            if (dbHdr.ui16BlockSize != 8192 && dbHdr.ui16BlockSize != 4096)
            {
                endTest( true, false);
                System.Console.WriteLine( "Invalid block size in database header");
                return( false);
            }
            if ((DBVersions)dbHdr.ui32DbVersion != DBVersions.XFLM_CURRENT_VERSION_NUM)
            {
                endTest( true, false);
                System.Console.WriteLine( "Invalid version in database header");
                return( false);
            }
            endTest( true, true);
            return( true);
        }
Exemplo n.º 6
0
        public bool removeDbTest(
			string	sDbName,
			DbSystem	dbSystem)
        {
            beginTest( "Remove Database Test (" + sDbName + ")");
            try
            {
                dbSystem.dbRemove( sDbName, null, null, true);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "removing database");
                return( false);
            }
            endTest( false, true);
            return( true);
        }
Exemplo n.º 7
0
        public bool copyDbTest(
			string	sSrcDbName,
			string	sDestDbName,
			DbSystem	dbSystem)
        {
            // Try copying the database

            MyDbCopyStatus	copyStatus = new MyDbCopyStatus();

            beginTest( "Copy Database Test (" + sSrcDbName + " --> " + sDestDbName + ")");
            try
            {
                dbSystem.dbCopy( sSrcDbName, null, null, sDestDbName, null, null, copyStatus);
            }
            catch (XFlaimException ex)
            {
                endTest( copyStatus.outputLines(), ex, "copying database");
                return( false);
            }
            endTest( copyStatus.outputLines(), true);
            return( true);
        }
Exemplo n.º 8
0
        public bool renameDbTest(
			string	sSrcDbName,
			string	sDestDbName,
			DbSystem	dbSystem)
        {
            // Try renaming the database

            MyDbRenameStatus	renameStatus = new MyDbRenameStatus();

            beginTest( "Rename Database Test (" + sSrcDbName + " --> " + sDestDbName + ")");
            try
            {
                dbSystem.dbRename( sSrcDbName, null, null, sDestDbName, true, renameStatus);
            }
            catch (XFlaimException ex)
            {
                endTest( renameStatus.outputLines(), ex, "renaming database");
                return( false);
            }
            endTest( renameStatus.outputLines(), true);
            return( true);
        }
Exemplo n.º 9
0
        public bool settingsTests(
			DbSystem	dbSystem)
        {
            if (!setTempDirTest( dbSystem))
            {
                return( false);
            }
            if (!setCheckpointIntervalTest( dbSystem))
            {
                return( false);
            }
            if (!setCacheAdjustIntervalTest( dbSystem))
            {
                return( false);
            }
            if (!setCacheCleanupIntervalTest( dbSystem))
            {
                return( false);
            }
            if (!setUnusedCleanupIntervalTest( dbSystem))
            {
                return( false);
            }
            if (!setMaxUnusedTimeTest( dbSystem))
            {
                return( false);
            }
            if (!setQuerySaveMaxTest( dbSystem))
            {
                return( false);
            }
            if (!setDirtyCacheLimitsTest( dbSystem))
            {
                return( false);
            }
            return( true);
        }
Exemplo n.º 10
0
        public bool rebuildDbTest(
			string	sSrcDbName,
			string	sDestDbName,
			DbSystem	dbSystem)
        {
            MyDbRebuildStatus	dbRebuildStatus = null;
            XFLM_CREATE_OPTS	createOpts = null;

            // Try restoring the database

            beginTest( "Rebuild Database Test (" + sSrcDbName + " to " + sDestDbName + ")");

            dbRebuildStatus = new MyDbRebuildStatus();
            createOpts = new XFLM_CREATE_OPTS();

            createOpts.uiBlockSize = 8192;
            createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
            createOpts.uiMinRflFileSize = 2000000;
            createOpts.uiMaxRflFileSize = 20000000;
            createOpts.bKeepRflFiles = 1;
            createOpts.bLogAbortedTransToRfl = 1;
            createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
            try
            {
                dbSystem.dbRebuild( sSrcDbName, null, sDestDbName, null, null,
                    null, null, createOpts, dbRebuildStatus);
            }
            catch (XFlaimException ex)
            {
                endTest( dbRebuildStatus.outputLines(), ex, "rebuilding database");
                return( false);
            }

            endTest( true, true);
            return( true);
        }
Exemplo n.º 11
0
        private bool setCacheAdjustIntervalTest(
			DbSystem	dbSystem)
        {
            uint	uiSetValue = 37;
            uint	uiGetValue;

            beginTest( "Set Cache Adjust Interval");

            try
            {
                dbSystem.setCacheAdjustInterval( uiSetValue);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setCacheAdjustInterval");
                return( false);
            }
            try
            {
                uiGetValue = dbSystem.getCacheAdjustInterval();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getCacheAdjustInterval");
                return( false);
            }
            if (uiSetValue != uiGetValue)
            {
                endTest( false, false);
                System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
                    uiGetValue, uiSetValue);
            }
            endTest( false, true);

            return( true);
        }
Exemplo n.º 12
0
        private bool setQuerySaveMaxTest(
			DbSystem	dbSystem)
        {
            uint	uiSetValue = 117;
            uint	uiGetValue;

            beginTest( "Set Query Save Max");

            try
            {
                dbSystem.setQuerySaveMax( uiSetValue);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setQuerySaveMax");
                return( false);
            }
            try
            {
                uiGetValue = dbSystem.getQuerySaveMax();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getQuerySaveMax");
                return( false);
            }
            if (uiSetValue != uiGetValue)
            {
                endTest( false, false);
                System.Console.WriteLine( "GetValue [{0}] != SetValue [{1}]",
                    uiGetValue, uiSetValue);
            }
            endTest( false, true);

            return( true);
        }
Exemplo n.º 13
0
        private bool setTempDirTest(
			DbSystem	dbSystem)
        {
            string	sSetDir = "abc/def/efg";
            string	sGetDir;

            System.IO.Directory.CreateDirectory( sSetDir);

            beginTest( "Set Temporary Directory");

            try
            {
                dbSystem.setTempDir( sSetDir);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setTempDir");
                return( false);
            }
            try
            {
                sGetDir = dbSystem.getTempDir();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getTempDir");
                return( false);
            }
            if (sSetDir != sGetDir)
            {
                endTest( false, false);
                System.Console.WriteLine( "GetDir != SetDir");
                System.Console.WriteLine( "GetDir = [{0}], setDir = [{1}]", sGetDir, sSetDir);
            }
            endTest( false, true);

            return( true);
        }
Exemplo n.º 14
0
        public bool backupDbTest(
			string	sDbName,
			string	sBackupPath,
			DbSystem	dbSystem)
        {
            Db					db = null;
            Backup			backup = null;
            MyBackupStatus	backupStatus = null;

            // Try backing up the database

            beginTest( "Backup Database Test (" + sDbName + " to directory \"" + sBackupPath + "\")");

            try
            {
                db = dbSystem.dbOpen( sDbName, null, null, null, false);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "opening database");
                return( false);
            }

            // Backup the database

            try
            {
                backup = db.backupBegin( true, false, 0);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling backupBegin");
                return( false);
            }

            // Perform the backup

            backupStatus = new MyBackupStatus();
            try
            {
                backup.backup( sBackupPath, null, null, backupStatus);
            }
            catch (XFlaimException ex)
            {
                endTest( backupStatus.outputLines(), ex, "calling backup");
                return( false);
            }

            // End the backup

            try
            {
                backup.endBackup();
            }
            catch (XFlaimException ex)
            {
                endTest( backupStatus.outputLines(), ex, "calling endBackup");
                return( false);
            }

            db.close();
            db = null;
            endTest( backupStatus.outputLines(), true);
            return( true);
        }
Exemplo n.º 15
0
        private bool setDirtyCacheLimitsTest(
			DbSystem	dbSystem)
        {
            ulong	ulSetMaxDirty = 117000000;
            ulong	ulGetMaxDirty;
            ulong	ulSetLowDirty = 37000000;
            ulong	ulGetLowDirty;

            beginTest( "Set Dirty Cache Limits");

            try
            {
                dbSystem.setDirtyCacheLimits( ulSetMaxDirty, ulSetLowDirty);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setDirtyCacheLimits");
                return( false);
            }
            try
            {
                dbSystem.getDirtyCacheLimits( out ulGetMaxDirty, out ulGetLowDirty);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getDirtyCacheLimits");
                return( false);
            }
            if (ulSetMaxDirty != ulGetMaxDirty || ulSetLowDirty != ulGetLowDirty)
            {
                endTest( false, false);
                if (ulSetMaxDirty != ulGetMaxDirty)
                {
                    System.Console.WriteLine( "GetMaxDirty [{0}] != SetMaxDirty [{1}]",
                        ulGetMaxDirty, ulSetMaxDirty);
                }
                if (ulSetLowDirty != ulGetLowDirty)
                {
                    System.Console.WriteLine( "GetLowDirty [{0}] != SetLowDirty [{1}]",
                        ulGetLowDirty, ulSetLowDirty);
                }
            }
            endTest( false, true);

            return( true);
        }
Exemplo n.º 16
0
        public bool importTests(
            Db			db,
            DbSystem	dbSystem)
        {
            DOMNode	doc = null;
            IStream	istream = null;

            // Create a document

            beginTest( "Import documents test");

            // Document #1

            try
            {
                istream = dbSystem.openBufferIStream( sDoc1);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream - doc 1");
                return( false);
            }

            try
            {
                doc = db.importDocument( istream, (uint)PredefinedXFlaimCollections.XFLM_DATA_COLLECTION,
                                    doc, null);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling importDocument - doc 1");
                return( false);
            }

            // Document #2

            try
            {
                istream = dbSystem.openBufferIStream( sDoc2);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream - doc 2");
                return( false);
            }

            try
            {
                doc = db.importDocument( istream, (uint)PredefinedXFlaimCollections.XFLM_DATA_COLLECTION,
                    doc, null);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling importDocument - doc 2");
                return( false);
            }

            // Index definition

            try
            {
                istream = dbSystem.openBufferIStream( sIndexDef);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream - index def");
                return( false);
            }

            try
            {
                doc = db.importDocument( istream, (uint)PredefinedXFlaimCollections.XFLM_DICT_COLLECTION,
                    doc, null);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling importDocument - index def");
                return( false);
            }
            endTest( false, true);

            return( true);
        }
Exemplo n.º 17
0
        public bool domNodesTest(
            string	sDbName,
            DbSystem	dbSystem)
        {
            bool	bOk = false;
            Db		db = null;
            bool	bStartedTrans = false;
            RCODE	rc;

            // Create the database

            beginTest( "Create database \"" + sDbName + "\"");

            for (;;)
            {
                rc = RCODE.NE_XFLM_OK;
                try
                {
                    XFLM_CREATE_OPTS	createOpts = new XFLM_CREATE_OPTS();

                    createOpts.uiBlockSize = 8192;
                    createOpts.uiVersionNum = (uint)DBVersions.XFLM_CURRENT_VERSION_NUM;
                    createOpts.uiMinRflFileSize = 2000000;
                    createOpts.uiMaxRflFileSize = 20000000;
                    createOpts.bKeepRflFiles = 1;
                    createOpts.bLogAbortedTransToRfl = 1;
                    createOpts.eDefaultLanguage = Languages.FLM_DE_LANG;
                    db = dbSystem.dbCreate( sDbName, null, null, null, null, createOpts);
                }
                catch (XFlaimException ex)
                {
                    rc = ex.getRCode();

                    if (rc != RCODE.NE_XFLM_FILE_EXISTS)
                    {
                        endTest( false, ex, "creating database");
                        return( false);
                    }
                }
                if (rc == RCODE.NE_XFLM_OK)
                {
                    break;
                }

                // rc better be NE_XFLM_FILE_EXISTS - try to delete the file

                try
                {
                    dbSystem.dbRemove( sDbName, null, null, true);
                }
                catch (XFlaimException ex)
                {
                    endTest( false, ex, "removing database");
                    return( false);
                }
            }
            endTest( false, true);

            // Start a transaction

            beginTest( "Start Update Transaction Test");
            try
            {
                db.transBegin( eDbTransType.XFLM_UPDATE_TRANS, 255, 0);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "starting update transaction");
                goto Exit;
            }
            endTest( false, true);
            bStartedTrans = true;

            // Create a document

            if (!createDocumentTest( db))
            {
                goto Exit;
            }

            // Commit the transaction

            beginTest( "Commit Update Transaction Test");
            try
            {
                bStartedTrans = false;
                db.transCommit();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "committing update transaction");
                goto Exit;
            }
            endTest( false, true);

            bOk = true;

            Exit:
            if (bStartedTrans)
            {
                db.transAbort();
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            return( bOk);
        }
Exemplo n.º 18
0
        public bool statsTests(
			string	sDbName,
			DbSystem	dbSystem)
        {
            Db							db = null;
            DbSystemStats			stats = null;
            uint						uiNumDatabases;
            uint						uiStartTime;
            uint						uiStopTime;
            CS_XFLM_DB_STATS		dbStats = null;
            CS_XFLM_LFILE_STATS	lFileStats = null;

            beginTest( "Start statistics");

            try
            {
                dbSystem.startStats();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "starting statistics");
                return( false);
            }
            endTest( false, true);

            // Open a database to make some statistics happen

            beginTest( "Open Database Test (" + sDbName + ")");

            try
            {
                db = dbSystem.dbOpen( sDbName, null, null, null, false);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "opening database");
                return( false);
            }
            if (db != null)
            {
                db.close();
                db = null;
            }
            endTest( false, true);

            // Stop collecting statistics

            beginTest( "Stop statistics");

            try
            {
                dbSystem.stopStats();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "stopping statistics");
                return( false);
            }
            endTest( false, true);

            // Get statistics

            beginTest( "Get statistics");

            try
            {
                stats = dbSystem.getStats();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "getting statistics");
                return( false);
            }
            endTest( false, true);

            // Get general statistics

            beginTest( "Get general statistics");

            try
            {
                stats.getGeneralStats( out uiNumDatabases, out uiStartTime,
                            out uiStopTime);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "getting statistics");
                return( false);
            }
            endTest( false, true);
            printUIntStat( 0, "Databases", uiNumDatabases);
            printUIntStat( 0, "Start Time", uiStartTime);
            printUIntStat( 0, "Stop Time", uiStopTime);

            // Get Database statistics

            for (uint uiLoop = 0; uiLoop < uiNumDatabases; uiLoop++)
            {
                beginTest( "Get database statistics for DB#" + uiLoop);

                try
                {
                    dbStats = stats.getDbStats( uiLoop, dbStats);
                }
                catch (XFlaimException ex)
                {
                    endTest( false, ex, "getting database statistics");
                    return( false);
                }
                endTest( false, true);
                printStrStat( 0, "Database Name", dbStats.sDbName);
                printUIntStat( 0, "Logical File Count", dbStats.uiNumLFiles);
                System.Console.WriteLine( "Read Transactions");
                printCountTimeStat( 1, "Committed Transactions", dbStats.ReadTransStats.CommittedTrans);
                printCountTimeStat( 1, "Aborted Transactions", dbStats.ReadTransStats.AbortedTrans);
                System.Console.WriteLine( "Update Transactions");
                printCountTimeStat( 1, "Committed Transactions", dbStats.UpdateTransStats.CommittedTrans);
                printCountTimeStat( 1, "Aborted Transactions", dbStats.UpdateTransStats.AbortedTrans);
                printCountTimeStat( 1, "Group Completes", dbStats.UpdateTransStats.GroupCompletes);
                printULongStat( 1, "Group Finished", dbStats.UpdateTransStats.ulGroupFinished);
                printBlockIOStats( 0, "LFH Block Stats", dbStats.LFHBlockStats);
                printBlockIOStats( 0, "Avail Block Stats", dbStats.AvailBlockStats);
                printDiskIOStats( 0, "Database Header Writes", dbStats.DbHdrWrites);
                printDiskIOStats( 0, "Log Block Writes", dbStats.LogBlockWrites);
                printDiskIOStats( 0, "Log Block Restores", dbStats.LogBlockRestores);
                printDiskIOStats( 0, "Log Block Reads", dbStats.LogBlockReads);
                printUIntStat( 0, "Log Block Checksum Errors", dbStats.uiLogBlockChkErrs);
                printUIntStat( 0, "Read Errors", dbStats.uiReadErrors);
                printCountTimeStat( 0, "No Locks", dbStats.LockStats.NoLocks);
                printCountTimeStat( 0, "Waiting For Lock", dbStats.LockStats.WaitingForLock);
                printCountTimeStat( 0, "Held Lock", dbStats.LockStats.HeldLock);

                for (uint uiLoop2 = 0; uiLoop2 < dbStats.uiNumLFiles; uiLoop2++)
                {
                    beginTest( "  Get database statistics for DB#" + uiLoop + ", LFile#" + uiLoop2);

                    try
                    {
                        lFileStats = stats.getLFileStats( uiLoop, uiLoop2, lFileStats);
                    }
                    catch (XFlaimException ex)
                    {
                        endTest( false, ex, "getting logical file statistics");
                        return( false);
                    }
                    endTest( false, true);
                    System.Console.WriteLine( "  LOGICAL FILE {0} ({1})",
                        lFileStats.uiLFileNum, lFileStats.eLfType);
                    printBlockIOStats( 2, "Root Block Stats", lFileStats.RootBlockStats);
                    printBlockIOStats( 2, "Middle Block Stats", lFileStats.MiddleBlockStats);
                    printBlockIOStats( 2, "Leaf Block Stats", lFileStats.LeafBlockStats);
                    printULongStat( 2, "Block Splits", lFileStats.ulBlockSplits);
                    printULongStat( 2, "Block Combines", lFileStats.ulBlockCombines);
                }
            }

            return( true);
        }
Exemplo n.º 19
0
        public bool cacheTests(
			DbSystem	dbSystem)
        {
            uint						uiCacheAdjustPercent = 66;
            ulong						ulCacheAdjustMin = 20000000;
            ulong						ulCacheAdjustMax = 1000000000;
            ulong						ulCacheAdjustMinToLeave = 0;
            #if !mono
            CS_XFLM_CACHE_INFO	cacheInfo;
            #endif

            beginTest( "Set dynamic cache limit test");
            try
            {
                dbSystem.setDynamicMemoryLimit( uiCacheAdjustPercent,
                    ulCacheAdjustMin, ulCacheAdjustMax,
                    ulCacheAdjustMinToLeave);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setDynamicMemoryLimit");
                return( false);
            }
            endTest( false, true);

            #if !mono
            beginTest( "Get cache info for dynamic cache limit test");
            try
            {
                cacheInfo = dbSystem.getCacheInfo();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getCacheInfo");
                return( false);
            }
            endTest( false, true);

            beginTest( "See if cache limits were set");
            if (cacheInfo.bDynamicCacheAdjust == 0 ||
                cacheInfo.uiCacheAdjustPercent != uiCacheAdjustPercent ||
                cacheInfo.ulCacheAdjustMin != ulCacheAdjustMin ||
                cacheInfo.ulCacheAdjustMax != ulCacheAdjustMax ||
                cacheInfo.ulCacheAdjustMinToLeave != ulCacheAdjustMinToLeave)
            {
                endTest( false, false);
                System.Console.WriteLine( "Dynamic cache adjust parameter mismatch");
                System.Console.WriteLine( "Dynamic Adjust Flag..... Set: true Get: {0}",
                    cacheInfo.bDynamicCacheAdjust != 0 ? "true" : "false");
                System.Console.WriteLine( "Adjust Percent.......... Set: {0} Get: {1}",
                    uiCacheAdjustPercent, cacheInfo.uiCacheAdjustPercent);
                System.Console.WriteLine( "Adjust Min.............. Set: {0} Get: {1}",
                    ulCacheAdjustMin, cacheInfo.ulCacheAdjustMin);
                System.Console.WriteLine( "Adjust Max.............. Set: {0} Get: {1}",
                    ulCacheAdjustMax, cacheInfo.ulCacheAdjustMax);
                System.Console.WriteLine( "Adjust Min To Leave..... Set: {0} Get: {1}",
                    ulCacheAdjustMinToLeave, cacheInfo.ulCacheAdjustMinToLeave);
                return( false);
            }
            endTest( false, true);
            #endif

            // SET AND TEST A HARD LIMIT

            beginTest( "Set hard cache limit test");
            try
            {
                dbSystem.setHardMemoryLimit( 0, false, 0, ulCacheAdjustMax,
                    0, false);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setHardMemoryLimit");
                return( false);
            }
            endTest( false, true);

            #if !mono
            beginTest( "Get cache info for hard cache limit test");
            try
            {
                cacheInfo = dbSystem.getCacheInfo();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getCacheInfo");
                return( false);
            }
            endTest( false, true);

            beginTest( "See if cache limits were set");
            if (cacheInfo.bDynamicCacheAdjust != 0 ||
                cacheInfo.ulCacheAdjustMax != ulCacheAdjustMax ||
                cacheInfo.ulMaxBytes != ulCacheAdjustMax)
            {
                endTest( false, false);
                System.Console.WriteLine( "Hard cache adjust parameter mismatch");
                System.Console.WriteLine( "Dynamic Adjust Flag..... Set: false Get: {0}",
                    cacheInfo.bDynamicCacheAdjust != 0 ? "true" : "false");
                System.Console.WriteLine( "Max..................... Set: {0} Get: {1}",
                    ulCacheAdjustMax, cacheInfo.ulCacheAdjustMax);
                System.Console.WriteLine( "Max Bytes............... Set: {0} Get: {1}",
                    ulCacheAdjustMax, cacheInfo.ulMaxBytes);
                return( false);
            }
            endTest( false, true);

            printCacheUsage( cacheInfo.blockCache, "BLOCK CACHE USAGE");
            printCacheUsage( cacheInfo.nodeCache, "NODE CACHE USAGE");
            #endif

            return( true);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Close this data vector object.
        /// </summary>
        public void close()
        {
            // Release the native pDataVector!

            if (m_pDataVector != IntPtr.Zero)
            {
                xflaim_DataVector_Release( m_pDataVector);
                m_pDataVector = IntPtr.Zero;
            }

            // Remove our reference to the dbSystem so it can be released.

            m_dbSystem = null;
        }
Exemplo n.º 21
0
        public bool vectorTests(
			DbSystem	dbSystem)
        {
            DataVector	v;
            string		setString = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            string		getString = "XXX";
            byte []		setBinary = new byte [] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
            byte []		getBinary = new byte [] {0};
            bool			bDataSame;
            ulong			setULong = 255873421849;
            ulong			getULong = 0;
            long			setLong = -234887;
            long			getLong = 0;
            int			setInt = -400;
            int			getInt = 0;
            uint			setUInt = 880044;
            uint			getUInt = 0;

            beginTest( "Creating DataVector");
            try
            {
                v = dbSystem.createDataVector();
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling createDataVector");
                return( false);
            }
            endTest( false, true);

            // Test setting and getting of binary data

            beginTest( "Setting binary data");
            try
            {
                v.setBinary( 0, setBinary);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setBinary");
                return( false);
            }
            endTest( false, true);

            beginTest( "Getting binary data");
            try
            {
                getBinary = v.getBinary( 0);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getBinary");
                return( false);
            }
            endTest( false, true);

            beginTest( "Comparing set binary data to get binary data");

            bDataSame = true;
            if (setBinary.Length != getBinary.Length)
            {
                bDataSame = false;
            }
            else
            {
                for( uint uiLoop = 0; uiLoop < setBinary.Length; uiLoop++)
                {
                    if (setBinary [uiLoop] != getBinary [uiLoop])
                    {
                        bDataSame = false;
                        break;
                    }
                }
            }
            if (!bDataSame)
            {
                endTest( false, false);
                System.Console.WriteLine( "Set binary data does not match get binary data");
                System.Console.Write( "Set Binary Data Length: {0}\n[", setBinary.Length);
                for( uint uiLoop = 0; uiLoop < setBinary.Length; uiLoop++)
                {
                    System.Console.Write( "{0} ", setBinary[uiLoop]);
                }
                System.Console.WriteLine( "]");
                System.Console.Write( "Get Binary Data Length: {0}\n[", getBinary.Length);
                for( uint uiLoop = 0; uiLoop < getBinary.Length; uiLoop++)
                {
                    System.Console.Write( "{0} ", getBinary[uiLoop]);
                }
                System.Console.WriteLine( "]");
                return( false);
            }
            endTest( false, true);

            // Test setting and getting of string data

            beginTest( "Setting string data");
            try
            {
                v.setString( 1, setString);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setString");
                return( false);
            }
            endTest( false, true);

            beginTest( "Getting string data");
            try
            {
                getString = v.getString( 1);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getString");
                return( false);
            }
            endTest( false, true);

            beginTest( "Comparing set string data to get string data");

            if (setString != getString)
            {
                endTest( false, false);
                System.Console.WriteLine( "Set string data does not match get string data");
                System.Console.WriteLine( "Set String:\n[{0}]", setString);
                System.Console.WriteLine( "Get String:\n[{0}]", getString);
            }
            endTest( false, true);

            // Test setting and getting of ulong data

            beginTest( "Setting ulong data");
            try
            {
                v.setULong( 2, setULong);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setULong");
                return( false);
            }
            endTest( false, true);

            beginTest( "Getting ulong data");
            try
            {
                getULong = v.getULong( 2);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getULong");
                return( false);
            }
            endTest( false, true);

            beginTest( "Comparing set ulong data to get ulong data");

            if (setULong != getULong)
            {
                endTest( false, false);
                System.Console.WriteLine( "Set ulong data does not match get ulong data");
                System.Console.WriteLine( "Set: {0}, Get: {1}", setULong, getULong);
            }
            endTest( false, true);

            // Test setting and getting of long data

            beginTest( "Setting long data");
            try
            {
                v.setLong( 3, setLong);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setLong");
                return( false);
            }
            endTest( false, true);

            beginTest( "Getting long data");
            try
            {
                getLong = v.getLong( 3);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getLong");
                return( false);
            }
            endTest( false, true);

            beginTest( "Comparing set long data to get long data");

            if (setLong != getLong)
            {
                endTest( false, false);
                System.Console.WriteLine( "Set long data does not match get long data");
                System.Console.WriteLine( "Set: {0}, Get: {1}", setLong, getLong);
            }
            endTest( false, true);

            // Test setting and getting of uint data

            beginTest( "Setting uint data");
            try
            {
                v.setUInt( 4, setUInt);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setUInt");
                return( false);
            }
            endTest( false, true);

            beginTest( "Getting uint data");
            try
            {
                getUInt = v.getUInt( 4);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getUInt");
                return( false);
            }
            endTest( false, true);

            beginTest( "Comparing set uint data to get uint data");

            if (setUInt != getUInt)
            {
                endTest( false, false);
                System.Console.WriteLine( "Set uint data does not match get uint data");
                System.Console.WriteLine( "Set: {0}, Get: {1}", setUInt, getUInt);
            }
            endTest( false, true);

            // Test setting and getting of int data

            beginTest( "Setting int data");
            try
            {
                v.setInt( 5, setInt);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling setInt");
                return( false);
            }
            endTest( false, true);

            beginTest( "Getting int data");
            try
            {
                getInt = v.getInt( 5);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling getInt");
                return( false);
            }
            endTest( false, true);

            beginTest( "Comparing set int data to get int data");

            if (setInt != getInt)
            {
                endTest( false, false);
                System.Console.WriteLine( "Set int data does not match get int data");
                System.Console.WriteLine( "Set: {0}, Get: {1}", setInt, getInt);
            }
            endTest( false, true);

            return( true);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Close the output stream and free the IF_OStream object.
        /// </summary>
        public void close()
        {
            if (m_pOStream != IntPtr.Zero)
            {
                xflaim_OStream_Release( m_pOStream);
                m_pOStream = IntPtr.Zero;
            }

            m_dbSystem = null;
        }
Exemplo n.º 23
0
        private IntPtr m_pStats; // Pointer to XFLM_STATS object in unmanaged space

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="pStats">
        /// Pointer to an XFLM_STATS object in unmanaged space.
        /// </param>
        /// <param name="dbSystem">
        /// DbSystem object that this DbSystemStats object is associated with.
        /// </param>
        internal DbSystemStats(
			IntPtr	pStats,
			DbSystem	dbSystem)
        {
            if (pStats == IntPtr.Zero)
            {
                throw new XFlaimException( "Invalid pointer to XFLM_STATS structure");
            }

            m_pStats = pStats;

            if (dbSystem == null)
            {
                throw new XFlaimException( "Invalid DbSystem reference");
            }

            m_dbSystem = dbSystem;

            // Must call something inside of DbSystem.  Otherwise, the
            // m_dbSystem object gets a compiler warning on linux because
            // it is not used anywhere.  Other than that, there is really
            // no need to make the following call.
            if (m_dbSystem.getDbSystem() == IntPtr.Zero)
            {
                throw new XFlaimException( "Invalid DbSystem.IF_DbSystem object");
            }
        }
Exemplo n.º 24
0
        //-----------------------------------------------------------------------
        // Main
        //-----------------------------------------------------------------------
        static void Main()
        {
            DbSystem dbSystem;
            Db			db;
            bool		bCreatedDatabase = false;

            // Must first get a DbSystem object in order to do anything with an
            // XFLAIM database.

            dbSystem = new DbSystem();

            // Create or open the database

            db = createOrOpenDatabase( dbSystem, out bCreatedDatabase);

            // Start an update transaction.  The timeout of 255 specifies that
            // the thread should wait forever to get the database lock.  A value
            // of zero would specify that it should not wait. In that case, or
            // for any value other than 255, the application should check to see
            // if the transaction failed to start because of a lock timeout
            // error. -- In general, the application will want to catch and
            // check for XFlaimException exceptions.  Such checking is not
            // shown in the following code.

            db.transBegin( eDbTransType.XFLM_UPDATE_TRANS, 255, 0);

            // Create a document (see createADocument above for illustration of the document as text)
            // In order to get the document, we must first get or create the needed element and
            // attribute name Ids in the dictionary.

            createOrGetNameIds( db, bCreatedDatabase);

            // Now create the document, as illustrated above.  The document is created in a collection that
            // is automatically created when the database is created,
            // the PredefinedXFlaimCollections.XFLM_DATA_COLLECTION

            createADocument( db);

            // Now we simply commit the transaction.  The document we created will be committed to
            // the database, and the database will be unlocked.

            db.transCommit();

            // Find the document that has a given name of "Peter", state of "California", and
            // return the "Age" element from the document.  The XPATH query is as follows:
            //
            // person[Name/Given == "Peter" && Address/State == "California"]/Age

            DOMNode	node = queryDatabase( db);

            // Output the age to the console.

            System.Console.WriteLine( "Age = {0}", node.getUInt());

            // Navigate to the cell phone element and print it out.

            for (;;)
            {
                node = node.getNextSibling( node);
                if (node.getNameId() == uiCellPhoneElementId)
                {
                    System.Console.WriteLine( "Cell phone = {0}", node.getString());
                    break;
                }
            }
        }
Exemplo n.º 25
0
        public bool streamTests(
			DbSystem	dbSystem)
        {
            IStream			bufferStream;
            IStream			encoderStream;
            IStream			decoderStream;
            OStream			fileOStream;
            Stream			s;
            StreamReader	sr;
            string			sFileData;

            beginTest( "Creating IStream from buffer");
            try
            {
                bufferStream = dbSystem.openBufferIStream( TEST_STREAM_STRING);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBufferIStream");
                return( false);
            }
            endTest( false, true);

            beginTest( "Creating base 64 encoder stream");
            try
            {
                encoderStream = dbSystem.openBase64Encoder( bufferStream, true);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBase64Encoder");
                return( false);
            }
            endTest( false, true);

            beginTest( "Creating base 64 decoder stream");
            try
            {
                decoderStream = dbSystem.openBase64Decoder( encoderStream);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openBase64Decoder");
                return( false);
            }
            endTest( false, true);

            beginTest( "Creating file output stream");
            try
            {
                fileOStream = dbSystem.openFileOStream( "Output_Stream", true);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling openFileOStream");
                return( false);
            }
            endTest( false, true);

            beginTest( "Writing from input stream to output stream");
            try
            {
                dbSystem.writeToOStream( decoderStream, fileOStream);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling writeToOStream");
                return( false);
            }
            fileOStream.close();
            endTest( false, true);

            beginTest( "Comparing output stream data to original data");

            s = File.OpenRead( "Output_Stream");
            sr = new StreamReader( s);
            sFileData = sr.ReadLine();
            if (sFileData != TEST_STREAM_STRING)
            {
                endTest( false, false);
                System.Console.WriteLine( "Stream data does not match original string");
                System.Console.WriteLine( "File Data:\n[{0}]", sFileData);
                System.Console.WriteLine( "Original String:\n[{0}]", TEST_STREAM_STRING);
                return( false);
            }

            endTest( false, true);
            return( true);
        }
        public bool compareStringTests(
			DbSystem	dbSystem)
        {
            if (!compareStrTest( "ABC", false, "abc", false, CompareFlags.FLM_COMP_CASE_INSENSITIVE, true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( "ABC", false, "abc", false, 0, false, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( "ab  cd", false, "ab     cd", false, CompareFlags.FLM_COMP_COMPRESS_WHITESPACE, true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( " ab  cd", false, "ab     cd", false, CompareFlags.FLM_COMP_COMPRESS_WHITESPACE, false, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( " ab  cd", false, "ab     cd", false,
                    CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE,
                    true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( " ab  cd", false, "   ab     cd", false,
                CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE,
                true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( " ab  cd ", false, "   ab     cd", false,
                CompareFlags.FLM_COMP_COMPRESS_WHITESPACE | CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE,
                false, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( " ab  cd ", false, "   ab     cd", false,
                CompareFlags.FLM_COMP_COMPRESS_WHITESPACE |
                CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE |
                CompareFlags.FLM_COMP_IGNORE_TRAILING_SPACE,
                true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( " ab  cd ", false, "   ab     cd   ", false,
                CompareFlags.FLM_COMP_COMPRESS_WHITESPACE |
                CompareFlags.FLM_COMP_IGNORE_LEADING_SPACE |
                CompareFlags.FLM_COMP_IGNORE_TRAILING_SPACE,
                true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( "801-224-8888", false, "8012248888", false,
                CompareFlags.FLM_COMP_NO_DASHES,
                true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( "801_224_8888", false, "801 224 8888", false,
                CompareFlags.FLM_COMP_NO_UNDERSCORES,
                true, dbSystem))
            {
                return( false);
            }
            if (!compareStrTest( "801_224_8888", false, "801   224    8888", false,
                CompareFlags.FLM_COMP_NO_UNDERSCORES | CompareFlags.FLM_COMP_COMPRESS_WHITESPACE,
                true, dbSystem))
            {
                return( false);
            }
            return( true);
        }
        private bool compareStrTest(
			string			sLeftStr,
			bool				bLeftWild,
			string			sRightStr,
			bool				bRightWild,
			CompareFlags	compareFlags,
			bool				bExpectedEqual,
			DbSystem			dbSystem)
        {
            int	iCmp;

            beginTest( "Compare Strings, Str1: \"" + sLeftStr +
                    "\", Str2: \"" + sRightStr + "\"");

            try
            {
                iCmp = dbSystem.compareStrings( sLeftStr, bLeftWild,
                                        sRightStr, bRightWild, compareFlags,
                                        Languages.FLM_US_LANG);
            }
            catch (XFlaimException ex)
            {
                endTest( false, ex, "calling compareStrings");
                return( false);
            }
            if ((bExpectedEqual && iCmp != 0) ||
                 (!bExpectedEqual && iCmp == 0))
            {
                endTest( false, false);
                System.Console.WriteLine( "Expected Equal [{0}] != Result [{1}]",
                        bExpectedEqual, iCmp);
                System.Console.WriteLine( "Compare Flags: {0}", compareFlags);
                System.Console.WriteLine( "Left Wild: {0}", bLeftWild);
                System.Console.WriteLine( "Right Wild: {0}", bRightWild);
            }
            endTest( false, true);

            return( true);
        }
Exemplo n.º 28
0
        static void Main()
        {
            DbSystem dbSystem = new DbSystem();

            // Database create test

            CreateDbTest createDb = new CreateDbTest();
            if (!createDb.createDbTest( CREATE_DB_NAME, dbSystem))
            {
                return;
            }

            // Database open test

            OpenDbTest openDb = new OpenDbTest();
            if (!openDb.openDbTest( CREATE_DB_NAME, dbSystem))
            {
                return;
            }

            // DOM Nodes test

            DOMNodesTest domNodes = new DOMNodesTest();
            if (!domNodes.domNodesTest( TEST_DB_NAME, dbSystem))
            {
                return;
            }

            // Import tests

            ImportTests importTest = new ImportTests();
            if (!importTest.importTests( TEST_DB_NAME, dbSystem))
            {
                return;
            }

            // Statistics test

            #if !mono

            // CANT GET THIS TEST TO WORK ON MONO FOR NOW, SO WE COMPILE IT OUT
            StatsTests statsTests = new StatsTests();
            if (!statsTests.statsTests( CREATE_DB_NAME, dbSystem))
            {
                return;
            }
            #endif

            // Database copy test

            CopyDbTest copyDb = new CopyDbTest();
            if (!copyDb.copyDbTest( CREATE_DB_NAME, COPY_DB_NAME, dbSystem))
            {
                return;
            }
            if (!copyDb.copyDbTest( TEST_DB_NAME, COPY2_DB_NAME, dbSystem))
            {
                return;
            }

            // Database rename test

            RenameDbTest renameDb = new RenameDbTest();
            if (!renameDb.renameDbTest( COPY2_DB_NAME, RENAME_DB_NAME, dbSystem))
            {
                return;
            }

            // Database backup test

            BackupDbTest backupDb = new BackupDbTest();
            if (!backupDb.backupDbTest( RENAME_DB_NAME, BACKUP_PATH, dbSystem))
            {
                return;
            }

            // Database restore test

            RestoreDbTest restoreDb = new RestoreDbTest();
            if (!restoreDb.restoreDbTest( RESTORE_DB_NAME, BACKUP_PATH, dbSystem))
            {
                return;
            }

            // Database rebuild test

            RebuildDbTest rebuildDb = new RebuildDbTest();
            if (!rebuildDb.rebuildDbTest( RESTORE_DB_NAME, REBUILD_DB_NAME, dbSystem))
            {
                return;
            }

            // Database check test

            CheckDbTest checkDb = new CheckDbTest();
            if (!checkDb.checkDbTest( CREATE_DB_NAME, dbSystem))
            {
                return;
            }
            if (!checkDb.checkDbTest( COPY_DB_NAME, dbSystem))
            {
                return;
            }
            if (!checkDb.checkDbTest( RESTORE_DB_NAME, dbSystem))
            {
                return;
            }
            if (!checkDb.checkDbTest( RENAME_DB_NAME, dbSystem))
            {
                return;
            }
            if (!checkDb.checkDbTest( REBUILD_DB_NAME, dbSystem))
            {
                return;
            }

            // Database remove test

            RemoveDbTest removeDb = new RemoveDbTest();
            if (!removeDb.removeDbTest( CREATE_DB_NAME, dbSystem))
            {
                return;
            }
            if (!removeDb.removeDbTest( COPY_DB_NAME, dbSystem))
            {
                return;
            }
            if (!removeDb.removeDbTest( RESTORE_DB_NAME, dbSystem))
            {
                return;
            }
            if (!removeDb.removeDbTest( RENAME_DB_NAME, dbSystem))
            {
                return;
            }
            if (!removeDb.removeDbTest( REBUILD_DB_NAME, dbSystem))
            {
                return;
            }

            // Input and Output stream tests

            StreamTests streamTests = new StreamTests();
            if (!streamTests.streamTests( dbSystem))
            {
                return;
            }

            // Data vector tests

            VectorTests vectorTests = new VectorTests();
            if (!vectorTests.vectorTests( dbSystem))
            {
                return;
            }

            // Cache tests

            CacheTests cacheTests = new CacheTests();
            if (!cacheTests.cacheTests( dbSystem))
            {
                return;
            }

            // Various settings tests

            SettingsTests settingsTests = new SettingsTests();
            if (!settingsTests.settingsTests( dbSystem))
            {
                return;
            }

            // Various string comparison tests

            CompareStringTests compareStringTests = new CompareStringTests();
            if (!compareStringTests.compareStringTests( dbSystem))
            {
                return;
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Free the statistics assocated with this object.
        /// </summary>
        public void freeStats()
        {
            // Free the unmanaged XFLM_STATS structure.

            if (m_pStats != IntPtr.Zero)
            {
                xflaim_DbSystemStats_freeStats( m_dbSystem.getDbSystem(), m_pStats);
                m_pStats = IntPtr.Zero;
            }

            // Remove our reference to the dbSystem so it can be released.

            m_dbSystem = null;
        }
Exemplo n.º 30
0
        //-----------------------------------------------------------------------
        // This method opens or creates the sample database.
        //-----------------------------------------------------------------------
        static Db createOrOpenDatabase( DbSystem dbSystem, out bool bCreatedDatabase)
        {
            Db			db;
            string	sDbName = "sample.db";

            // Try to open a database.  If that fails, create it.  The following
            // example creates the database in the current directory.  However,
            // a full or partial file name may be specified.
            // NOTE: Multiple threads should each do their own open of the
            // database and get back their own Db object.

            try
            {
                db = dbSystem.dbOpen( sDbName, null, null, null, false);
            }
            catch (XFlaimException ex)
            {
                if (ex.getRCode() != RCODE.NE_XFLM_IO_PATH_NOT_FOUND)
                {
                    throw ex;
                }
                db = dbSystem.dbCreate( sDbName, null, null, null, null, null);
                bCreatedDatabase = true;
            }
            return( db);
        }