diff --git a/xflaim/csharp/xflaim/Db.cs b/xflaim/csharp/xflaim/Db.cs index f7441a0..df5c87e 100644 --- a/xflaim/csharp/xflaim/Db.cs +++ b/xflaim/csharp/xflaim/Db.cs @@ -27,6 +27,158 @@ using System.Runtime.InteropServices; namespace xflaim { + //----------------------------------------------------------------------------- + // Database transaction types + //----------------------------------------------------------------------------- + + /// + /// Database transaction types. + /// IMPORTANT NOTE: These need to be kept in sync with the corresponding + /// definitions in xflaim.h + /// + public enum eDbTransType : uint + { + /// No transaction + XFLM_NO_TRANS = 0, + /// Read transaction + XFLM_READ_TRANS, + /// Update transaction + XFLM_UPDATE_TRANS + } + + //----------------------------------------------------------------------------- + // Database transaction flags + //----------------------------------------------------------------------------- + + /// + /// Database transaction flags. + /// IMPORTANT NOTE: These need to be kept in sync with the corresponding + /// definitions in xflaim.h + /// + [Flags] + public enum DbTransFlags : uint + { + /// + /// Do not terminate the transaction, even if + /// a checkpoint is waiting to complete + /// + XFLM_DONT_KILL_TRANS = 0x0001, + /// + /// Place all blocks and nodes read during the transaction + /// at the least-recently used positions in the cache lists. + /// + XFLM_DONT_POISON_CACHE = 0x0002 + } + + //----------------------------------------------------------------------------- + // Database lock types + //----------------------------------------------------------------------------- + + /// + /// Types of locks that may be requested. + /// IMPORTANT NOTE: These need to be kept in sync with the corresponding + /// enum in ftk.h + /// + public enum eLockType : uint + { + /// No lock + FLM_LOCK_NONE = 0, + /// Exclusive lock + FLM_LOCK_EXCLUSIVE, + /// Shared lock + FLM_LOCK_SHARED + } + + /// + /// Types of locks that may be requested. + /// IMPORTANT NOTE: These need to be kept in sync with the corresponding + /// definitions in xflaim.h + /// + public enum eXFlmIndexState : uint + { + /// Index is on-line and available for use. + XFLM_INDEX_ONLINE = 0, + /// Index is being built and is unavailable. + XFLM_INDEX_BRINGING_ONLINE, + /// Index has been suspended and is unavailable. + XFLM_INDEX_SUSPENDED + } + + /// + /// Index status object + /// IMPORTANT NOTE: This structure needs to be kept in sync with the corresponding + /// definitions in xflaim.h + /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] + public class XFLM_INDEX_STATUS + { + /// + /// If ~0 then index is online, otherwise this is the value of the + /// last document ID that was indexed. + /// + public long ui64LastDocumentIndexed; + /// + /// Keys processed by the background indexing thread. + /// + public long ui64KeysProcessed; + /// + /// Documents processed by the background indexing thread. + /// + public long ui64DocumentsProcessed; + /// + /// Number of transactions completed by the background indexing thread. + /// + public long ui64Transactions; + /// + /// ID of the index. + /// + public uint ui32IndexNum; + /// + /// Time the bacground indexing thread (if any) was started. + /// + public uint ui32StartTime; + /// + /// State of the background indexing thread (if any). + /// + public eXFlmIndexState eState; + } + + //----------------------------------------------------------------------------- + // RetrieveFlags + //----------------------------------------------------------------------------- + + /// + /// Flags used to specify items to be retrieved from a result set. + /// The method also uses these flags + /// to specify how keys from an index are to be retrieved. + /// IMPORTANT NOTE: These flags need to be kept in sync with the corresponding + /// definitions in xflaim.h + /// + [Flags] + public enum RetrieveFlags : uint + { + /// Return item greater than or equal to the search key. + XFLM_INCL = 0x0010, + /// Return item greater than the search key. + XFLM_EXCL = 0x0020, + /// Return item that exactly matches the search key. + XFLM_EXACT = 0x0040, + /// + /// Used in conjunction with XFLM_EXCL. Specifies that the item to be + /// returned must match the key components, but the node ids may be + /// different. + /// + XFLM_KEY_EXACT = 0x0080, + /// Retrieve the first key in the index or first item in a result set. + XFLM_FIRST = 0x0100, + /// Retrieve the last key in the index or last item in a result set. + XFLM_LAST = 0x0200, + /// Specifies whether to match node IDs in the search key. + XFLM_MATCH_IDS = 0x0400, + /// Specifies whether to match the document ID in the search key. + XFLM_MATCH_DOC_ID = 0x0800 + } + /// /// The Db class provides a number of methods that allow C# /// applications to access an XFLAIM database. A Db object @@ -38,173 +190,6 @@ namespace xflaim private ulong m_pDb; // Pointer to IF_Db object in unmanaged space private DbSystem m_dbSystem; -//----------------------------------------------------------------------------- -// Database transaction types -//----------------------------------------------------------------------------- - - /// - /// Database transaction types. - /// - public enum DbTransType : uint - { - /// No transaction - XFLM_NO_TRANS = 0, - /// Read transaction - XFLM_READ_TRANS, - /// Update transaction - XFLM_UPDATE_TRANS - } - -//----------------------------------------------------------------------------- -// Database transaction flags -//----------------------------------------------------------------------------- - - /// - /// Database transaction flags. - /// - [Flags] - public enum DbTransFlags : uint - { - /// - /// Do not terminate the transaction, even if - /// a checkpoint is waiting to complete - /// - XFLM_DONT_KILL_TRANS = 0x0001, - /// - /// Place all blocks and nodes read during the transaction - /// at the least-recently used positions in the cache lists. - /// - XFLM_DONT_POISON_CACHE = 0x0002 - } - -//----------------------------------------------------------------------------- -// Database lock types -//----------------------------------------------------------------------------- - - /// - /// Types of locks that may be requested. - /// - public enum DbLockType : uint - { - /// - /// No lock - /// - FLM_LOCK_NONE = 0, - /// - /// Exclusive lock - /// - FLM_LOCK_EXCLUSIVE, - /// - /// Shared lock - /// - FLM_LOCK_SHARED - } - -//----------------------------------------------------------------------------- -// Index status constants -//----------------------------------------------------------------------------- - - /// - /// Types of locks that may be requested. - /// - public enum DbIndexState : uint - { - /// - /// Index is on-line and available for use. - /// - XFLM_INDEX_ONLINE = 0, - /// - /// Index is being built and is unavailable. - /// - XFLM_INDEX_BRINGING_ONLINE, - /// - /// Index has been suspended and is unavailable. - /// - XFLM_INDEX_SUSPENDED - } - - /// - /// Index status object - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public class XFLM_INDEX_STATUS - { - /// - /// If ~0 then index is online, otherwise this is the value of the - /// last document ID that was indexed. - /// - public long ui64LastDocumentIndexed; - /// - /// Keys processed by the background indexing thread. - /// - public long ui64KeysProcessed; - /// - /// Documents processed by the background indexing thread. - /// - public long ui64DocumentsProcessed; - /// - /// Number of transactions completed by the background indexing thread. - /// - public long ui64Transactions; - /// - /// ID of the index. - /// - public uint ui32IndexNum; - /// - /// Time the bacground indexing thread (if any) was started. - /// - public uint ui32StartTime; - /// - /// State of the background indexing thread (if any). - /// - DbIndexState eState; - } - -//----------------------------------------------------------------------------- -// RetrieveFlags -//----------------------------------------------------------------------------- - - /// - /// Flags used by the keyRetrieve method - /// - [Flags] - public enum RetrieveFlags : uint - { - /// - /// Search for keys greater than or equal to the "from" key. - /// - XFLM_INCL = 0x0010, - /// - /// Search for keys greater than the "from" key. - /// - XFLM_EXCL = 0x0020, - /// - /// Search for an exact "from" key match. - /// - XFLM_EXACT = 0x0040, - /// - /// Search for an exact "from" key match without comparing - /// the reference component of the key. - /// - XFLM_KEY_EXACT = 0x0080, - /// - /// Retrieve the first key in the index. - /// - XFLM_FIRST = 0x0100, - /// - /// Retrieve the last key in the index. - /// - XFLM_LAST = 0x0200, - /// - /// TBD - /// - XFLM_MATCH_IDS = 0x0400, - /// - /// TBD - /// - XFLM_MATCH_DOC_ID = 0x0800 - } - //----------------------------------------------------------------------------- // constructor //----------------------------------------------------------------------------- @@ -318,7 +303,7 @@ namespace xflaim /// Starts a transaction. /// /// - /// The type of transaction () + /// The type of transaction () /// /// /// Specifies the amount of time to wait for lock requests occuring @@ -332,7 +317,7 @@ namespace xflaim /// /// public void transBegin( - DbTransType eTransType, + eDbTransType eTransType, uint uiMaxLockWait, DbTransFlags uiFlags) { @@ -348,7 +333,7 @@ namespace xflaim [DllImport("xflaim")] private static extern RCODE xflaim_Db_transBegin( ulong pDb, - DbTransType eTransType, + eDbTransType eTransType, uint uiMaxLockWait, DbTransFlags uiFlags); @@ -434,14 +419,14 @@ namespace xflaim /// /// Get the current transaction type. /// - /// - public DbTransType getTransType() + /// + public eDbTransType getTransType() { return( xflaim_Db_getTransType( m_pDb)); } [DllImport("xflaim")] - private static extern DbTransType xflaim_Db_getTransType( + private static extern eDbTransType xflaim_Db_getTransType( ulong pDb); //----------------------------------------------------------------------------- @@ -480,7 +465,7 @@ namespace xflaim /// /// Lock the database. /// - /// + /// /// Type of lock being requested. /// /// @@ -494,13 +479,13 @@ namespace xflaim /// /// public void dbLock( - DbLockType eLockType, + eLockType eLckType, int iPriority, uint uiTimeout) { RCODE rc = RCODE.NE_XFLM_OK; - if( (rc = xflaim_Db_dbLock( m_pDb, eLockType, + if( (rc = xflaim_Db_dbLock( m_pDb, eLckType, iPriority, uiTimeout)) != 0) { throw new XFlaimException(rc); @@ -510,7 +495,7 @@ namespace xflaim [DllImport("xflaim")] private static extern RCODE xflaim_Db_dbLock( ulong pDb, - DbLockType eLockType, + eLockType eLckType, int iPriority, uint uiTimeout); @@ -544,13 +529,13 @@ namespace xflaim /// Get the type of database lock current held. /// /// - public DbLockType getLockType() + public eLockType getLockType() { return( xflaim_Db_getLockType( m_pDb)); } [DllImport("xflaim")] - private static extern DbLockType xflaim_Db_getLockType( + private static extern eLockType xflaim_Db_getLockType( ulong pDb); //-----------------------------------------------------------------------------