From f67dc40e6986a02dd6a57ba7ad693e5d334d1a1f Mon Sep 17 00:00:00 2001 From: dsandersoremutah Date: Wed, 27 Sep 2006 15:54:58 +0000 Subject: [PATCH] Finished coding the methods in the Query class for C#. git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@921 0109f412-320b-0410-ab79-c3e0c5ffbbe6 --- xflaim/csharp/xflaim/Query.cpp | 139 +++++++++++++++ xflaim/csharp/xflaim/Query.cs | 302 +++++++++++++++++++++++++++++++++ 2 files changed, 441 insertions(+) diff --git a/xflaim/csharp/xflaim/Query.cpp b/xflaim/csharp/xflaim/Query.cpp index 323ee6a..e43987a 100644 --- a/xflaim/csharp/xflaim/Query.cpp +++ b/xflaim/csharp/xflaim/Query.cpp @@ -490,3 +490,142 @@ FLMEXTC FLMEXP RCODE FLMAPI xflaim_Query_addSortKey( *pui64Context = (FLMUINT64)((FLMUINT)pvContext); return( rc); } + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_Query_enablePositioning( + FLMUINT64 ui64Query) +{ + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + + return( pQuery->enablePositioning()); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_Query_positionTo( + FLMUINT64 ui64Query, + FLMUINT64 ui64Db, + FLMUINT64 ui64OldNode, + FLMUINT32 ui32TimeLimit, + FLMUINT32 ui32Position, + FLMUINT64 * pui64Node) +{ + RCODE rc; + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + IF_Db * pDb = (IF_Db *)((FLMUINT)ui64Db); + IF_DOMNode * pNode = (IF_DOMNode *)((FLMUINT)ui64OldNode); + + rc = pQuery->positionTo( pDb, &pNode, (FLMUINT)ui32TimeLimit, (FLMUINT)ui32Position); + *pui64Node = (FLMUINT64)((FLMUINT)pNode); + return( rc); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_Query_positionToByKey( + FLMUINT64 ui64Query, + FLMUINT64 ui64Db, + FLMUINT64 ui64OldNode, + FLMUINT32 ui32TimeLimit, + FLMUINT64 ui64SearchKey, + FLMUINT32 ui32RetrieveFlags, + FLMUINT64 * pui64Node) +{ + RCODE rc; + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + IF_Db * pDb = (IF_Db *)((FLMUINT)ui64Db); + IF_DOMNode * pNode = (IF_DOMNode *)((FLMUINT)ui64OldNode); + IF_DataVector * pSearchKey = (IF_DataVector *)((FLMUINT)ui64SearchKey); + + rc = pQuery->positionTo( pDb, &pNode, (FLMUINT)ui32TimeLimit, + pSearchKey, (FLMUINT)ui32RetrieveFlags); + *pui64Node = (FLMUINT64)((FLMUINT)pNode); + return( rc); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_Query_getPosition( + FLMUINT64 ui64Query, + FLMUINT64 ui64Db, + FLMUINT32 * pui32Position) +{ + RCODE rc; + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + IF_Db * pDb = (IF_Db *)((FLMUINT)ui64Db); + FLMUINT uiPosition; + + rc = pQuery->getPosition( pDb, &uiPosition); + *pui32Position = (FLMUINT32)uiPosition; + return( rc); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_Query_buildResultSet( + FLMUINT64 ui64Query, + FLMUINT64 ui64Db, + FLMUINT32 ui32TimeLimit) +{ + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + IF_Db * pDb = (IF_Db *)((FLMUINT)ui64Db); + + return( pQuery->buildResultSet( pDb, (FLMUINT)ui32TimeLimit)); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_Query_stopBuildingResultSet( + FLMUINT64 ui64Query) +{ + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + + pQuery->stopBuildingResultSet(); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP void FLMAPI xflaim_Query_enableResultSetEncryption( + FLMUINT64 ui64Query) +{ + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + + pQuery->enableResultSetEncryption(); +} + +/**************************************************************************** +Desc: +****************************************************************************/ +FLMEXTC FLMEXP RCODE FLMAPI xflaim_Query_getCounts( + FLMUINT64 ui64Query, + FLMUINT64 ui64Db, + FLMUINT32 ui32TimeLimit, + FLMBOOL bPartialCountOk, + FLMUINT32 * pui32ReadCount, + FLMUINT32 * pui32PassedCount, + FLMUINT32 * pui32PositionableToCount, + FLMBOOL * pbDoneBuildingResultSet) +{ + RCODE rc; + IF_Query * pQuery = (IF_Query *)((FLMUINT)ui64Query); + IF_Db * pDb = (IF_Db *)((FLMUINT)ui64Db); + FLMUINT uiReadCount; + FLMUINT uiPassedCount; + FLMUINT uiPositionableToCount; + + rc = pQuery->getCounts( pDb, (FLMUINT)ui32TimeLimit, bPartialCountOk, + &uiReadCount, &uiPassedCount, &uiPositionableToCount, + pbDoneBuildingResultSet); + *pui32ReadCount = (FLMUINT32)uiReadCount; + *pui32PassedCount = (FLMUINT32)uiPassedCount; + *pui32PositionableToCount = (FLMUINT32)uiPositionableToCount; + return( rc); +} diff --git a/xflaim/csharp/xflaim/Query.cs b/xflaim/csharp/xflaim/Query.cs index 899c01c..25b76b1 100644 --- a/xflaim/csharp/xflaim/Query.cs +++ b/xflaim/csharp/xflaim/Query.cs @@ -1178,5 +1178,307 @@ namespace xflaim int bSortMissingHigh, out ulong pulContext); +//----------------------------------------------------------------------------- +// enablePositioning +//----------------------------------------------------------------------------- + + /// + /// Enable absolute positioning in the query result set. + /// + public void enablePositioning() + { + RCODE rc; + + if ((rc = xflaim_Query_enablePositioning( m_pQuery)) != 0) + { + throw new XFlaimException( rc); + } + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_Query_enablePositioning( + ulong pQuery); + +//----------------------------------------------------------------------------- +// positionTo +//----------------------------------------------------------------------------- + + /// + /// Position to the in the result that is at + /// the absolute position specified by the uiPosition parameter. + /// + /// + /// An existing object can optionally be + /// passed in, and it will be reused instead of a new object being allocated. + /// + /// + /// Time limit (in milliseconds) for operation to complete. A value of zero + /// indicates that the operation should not time out. + /// + /// + /// Absolute position in the result set to position to. + /// + /// + /// Returns a object. + /// + public DOMNode positionTo( + DOMNode nodeToReuse, + uint uiTimeLimit, + uint uiPosition) + { + RCODE rc; + ulong pOldNode = (nodeToReuse != null) ? nodeToReuse.getNode() : 0; + ulong pNode; + DOMNode newNode; + + if ((rc = xflaim_Query_positionTo( m_pQuery, m_db.getDb(), + pOldNode, uiTimeLimit, + uiPosition, out pNode)) != 0) + { + throw new XFlaimException( rc); + } + if (nodeToReuse == null) + { + newNode = new DOMNode( pNode, m_db); + } + else + { + newNode = nodeToReuse; + newNode.setNodePtr( pNode, m_db); + } + + return( newNode); + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_Query_positionTo( + ulong pQuery, + ulong pDb, + ulong pOldNode, + uint uiTimeLimit, + uint uiPosition, + out ulong ppNode); + +//----------------------------------------------------------------------------- +// positionTo +//----------------------------------------------------------------------------- + + /// + /// Position to the in the result that is at + /// the position specified by the searchKey parameter. + /// + /// + /// An existing object can optionally be + /// passed in, and it will be reused instead of a new object being allocated. + /// + /// + /// Time limit (in milliseconds) for operation to complete. A value of zero + /// indicates that the operation should not time out. + /// + /// + /// This is a key that corresponds to the sort key that was specified using + /// the addSortKey method. This method looks up the node in the result set + /// that has this search key and returns it. + /// + /// + /// The search flags that direct how the key is to be used to do positioning. + /// This should be values from that are ORed together. + /// + /// + /// Returns a object. + /// + public DOMNode positionTo( + DOMNode nodeToReuse, + uint uiTimeLimit, + DataVector searchKey, + RetrieveFlags retrieveFlags) + { + RCODE rc; + ulong pOldNode = (nodeToReuse != null) ? nodeToReuse.getNode() : 0; + ulong pNode; + DOMNode newNode; + + if ((rc = xflaim_Query_positionToByKey( m_pQuery, m_db.getDb(), + pOldNode, uiTimeLimit, searchKey.getDataVector(), + retrieveFlags, out pNode)) != 0) + { + throw new XFlaimException( rc); + } + if (nodeToReuse == null) + { + newNode = new DOMNode( pNode, m_db); + } + else + { + newNode = nodeToReuse; + newNode.setNodePtr( pNode, m_db); + } + + return( newNode); + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_Query_positionToByKey( + ulong pQuery, + ulong pDb, + ulong pOldNode, + uint uiTimeLimit, + ulong pDataVector, + RetrieveFlags retrieveFlags, + out ulong ppNode); + +//----------------------------------------------------------------------------- +// getPosition +//----------------------------------------------------------------------------- + + /// + /// Returns the absolute position within the result set where the query + /// is currently positioned. + /// + /// Returns absolute position. + public uint getPosition() + { + RCODE rc; + uint uiPosition; + + if ((rc = xflaim_Query_getPosition( m_pQuery, m_db.getDb(), + out uiPosition)) != 0) + { + throw new XFlaimException( rc); + } + return( uiPosition); + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_Query_getPosition( + ulong pQuery, + ulong pDb, + out uint puiPosition); + +//----------------------------------------------------------------------------- +// buildResultSet +//----------------------------------------------------------------------------- + + /// + /// Build the result set for the query. + /// + /// + /// Time limit (in milliseconds) for operation to complete. A value of + /// zero indicates that the operation should not time out. + /// + public void buildResultSet( + uint uiTimeLimit) + { + RCODE rc; + + if ((rc = xflaim_Query_buildResultSet( m_pQuery, m_db.getDb(), + uiTimeLimit)) != 0) + { + throw new XFlaimException( rc); + } + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_Query_buildResultSet( + ulong pQuery, + ulong pDb, + uint uiTimeLimit); + +//----------------------------------------------------------------------------- +// stopBuildingResultSet +//----------------------------------------------------------------------------- + + /// + /// Stop building the result set for the query. + /// + public void stopBuildingResultSet() + { + xflaim_Query_stopBuildingResultSet( m_pQuery); + } + + [DllImport("xflaim")] + private static extern void xflaim_Query_stopBuildingResultSet( + ulong pQuery); + +//----------------------------------------------------------------------------- +// enableResultSetEncryption +//----------------------------------------------------------------------------- + + /// + /// Enable encryption for the query result set while it is being built. + /// Anything that overflows to disk will be encrypted. + /// + public void enableResultSetEncryption() + { + xflaim_Query_enableResultSetEncryption( m_pQuery); + } + + [DllImport("xflaim")] + private static extern void xflaim_Query_enableResultSetEncryption( + ulong pQuery); + +//----------------------------------------------------------------------------- +// getCounts +//----------------------------------------------------------------------------- + + /// + /// Return counts about the result set that has either been built or is + /// in the process of being built. + /// + /// + /// Time limit (in milliseconds) for operation to complete. A value of + /// zero indicates that the operation should not time out. + /// + /// + /// Specifies whether the method should wait for the result set to be + /// completely built before returning counts. If true, the method will + /// return the current counts, even if the result set is not completely built. + /// + /// + /// Returns total nodes or documents read so far. + /// + /// + /// Returns total nodes or documents that have passed the query criteria. + /// This is essentially the current total of nodes or documents that will + /// be in the query result set. + /// + /// + /// Returns the number of nodes that can be positioned to. This will be + /// zero if the result set must be sorted before positioning can occur. + /// + /// + /// Indicates if the result set is completely built yet. + /// + public void getCounts( + uint uiTimeLimit, + bool bPartialCountOk, + out uint uiReadCount, + out uint uiPassedCount, + out uint uiPositionableToCount, + out bool bDoneBuildingResultSet) + { + RCODE rc; + int bDoneBuilding; + + if ((rc = xflaim_Query_getCounts( m_pQuery, m_db.getDb(), uiTimeLimit, + (int)(bPartialCountOk ? 1 : 0), out uiReadCount, out uiPassedCount, + out uiPositionableToCount, out bDoneBuilding)) != 0) + { + throw new XFlaimException( rc); + } + bDoneBuildingResultSet = bDoneBuilding != 0 ? true : false; + } + + [DllImport("xflaim")] + private static extern RCODE xflaim_Query_getCounts( + ulong pQuery, + ulong pDb, + uint uiTimeLimit, + int bPartialCountOk, + out uint uiReadCount, + out uint uiPassedCount, + out uint uiPositionableToCount, + out int bDoneBuilding); + } }