xflminterface IF_Query : public XF_RefCount


The IF_Query interface allows an application to perform queries on an XFLAIM database.  An IF_Query object is obtained by calling the IF_DbSystem::createIFQuery method.  The methods on an IF_Query object allow an application to define query criteria and then retrieve query results.  It also allows query results to be sorted, and absolute positioning to be done within the result set.


Method Summary

RCODE setLanguage - Set the language for string comparisons.
RCODE setCollection - Set the database collection that is to be searched.
RCODE setupQueryExpr(1) - Setup query criteria from a unicode string that is an XPATH expression.
RCODE setupQueryExpr(2) - Setup query criteria from a native string that is an XPATH expression.
RCODE copyCriteria - Copy query criteria from another query object into this object.
RCODE addXPathComponent - Add an XPATH component to the query criteria.
RCODE addOperator - Add an operator to the query criteria.
RCODE addUnicodeValue - Add a unicode string operand to the query criteria.
RCODE addUTF8Value - Add a UTF8 string operand to the query criteria.
RCODE addBinaryValue - Add a binary value operand to the query criteria.
RCODE addUINTValue - Add an unsigned integer operand to the query criteria.
RCODE addINTValue - Add a signed integer operand to the query criteria.
RCODE addUINT64Value - Add a 64 bit unsigned integer operand to the query criteria.
RCODE addINT64Value - Add a 64 bit signed integer operand to the query criteria.
RCODE addBoolean - Add a boolean predicate to the query criteria.
RCODE addFunction(1) - Add a predefined function operand or predicate to the query criteria.
RCODE addFunction(2) - Add an application defined function operand or predicate to the query criteria.
RCODE getFirst - Return the first node or document of the query result set.
RCODE getLast - Return the last node or document of the query result set.
RCODE getNext - Return the next node or document of the query result set.  If not positioned, start from first node or document.
RCODE getPrev - Return the previous node or document of the query result set.  If not positioned, start from last node or document.
RCODE getCurrent - Return the current node or document of the query result set.  Must have already retrieved a node or document from the result set.
RCODE resetQuery - Clears the query criteria and sets the query object to its initialized state.
RCODE getStatsAndOptInfo - Return optimization and statistics information about the query.
RCODE freeStatsAndOptInfo - Free optimization and statistics information that was returned by getStatsAndOptInfo.
RCODE setDupHandling - Configure whether query should allow returning of same document more than once.
RCODE setIndex - Set the index to be used by the query.  Zero may be specified to force a database scan.
RCODE getIndex - Returns index being used in query.
RCODE addSortKey - Specify a sort key component for the query result set.
RCODE enablePositioning - Enable absolute positioning within the query result set.
RCODE positionTo(1) - Position to an absolute position within the query result set.
RCODE positionTo(2) - Position to a specific key within a query result set that has sort keys.
RCODE getPosition - Get the current absolute position within a query result set.
RCODE buildResultSet - Build the query result set - usually called when it is desirable to build the result set in a background thread.
RCODE stopBuildingResultSet - Stop another thread that is building the result set via buildResultSet.
RCODE getCounts - Get the current counts for the query result set.
RCODE enableResultSetEncryption - If a temporary result set needs to be built for the query result set, ensure that it is encrypted when going to disk.
RCODE setQueryStatusObject - Set the query status object for the query.
RCODE setQueryValidatorObject - Set the query validator object for the query.

 

Method Detail

setLanguage

    RCODE setLanguage(

        FLMUINT    uiLanguage);

Set the language for string comparisons.

    Parameters In:

FLMUINT uiLanguage The language for string comparisons.

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE        rc;

 

    // Set query string comparison language to US english.

 

    rc = pQuery->setLanguage( XFLM_US_LANG);

 

    See Also:

[Back to Top]


setCollection

    RCODE setCollection(

        FLMUINT    uiCollection);

Set the database collection that is to be searched.

    Parameters In:

FLMUINT uiCollection The database collection that is to be searched.

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE        rc;

 

    // Set collection to be searched to be the default data collection.

 

    rc = pQuery->setCollection( XFLM_DATA_COLLECTION);

 

    See Also:

[Back to Top]


setupQueryExpr(1)

    RCODE setupQueryExpr(

        IF_Db *                    pDb,

        FLMUNICODE  *   puzQuery);

Set the query criteria from a unicode string that is an XPATH expression.

    Parameters In:

IF_Db * pDb Pointer to database object.
FLMUNICODE * puzQuery The unicode string that contains the XPATH expression.  This string will be parsed and setup as the query criteria for this query.  Element names and attribute names in the string will be looked up in the database dictionary (pDb's dictionary), verified, and translated to the appropriate name id.

    Example Code:

    IF_Db *         pDb;       //Assume that we have already opened the database

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    FLMUNICODE *    puzQuery = {'/','p','e','r','s','o','n',

                                '/','n','a','m','e','=','"','r','a','l','p','h','"', 0};

    RCODE           rc;

 

    // Set the XPATH query criteria for query to be: "/person/name="ralph""

    // NOTE: It is assumed that the element names for "person" and "name" are defined in the

    // database dictionary for pDb

 

    rc = pQuery->setupQueryExpr( pDb, puzQuery);

 

    See Also: setupQueryExpr(2)

[Back to Top]


setupQueryExpr(2)

    RCODE setupQueryExpr(

        IF_Db *    pDb,

        char  *       pszQuery);

Set the query criteria from a native string that is an XPATH expression.

    Parameters In:

IF_Db * pDb Pointer to database object.
char * pszQuery The native string that contains the XPATH expression.  This string will be parsed and setup as the query criteria for this query.  Element names and attribute names in the string will be looked up in the database dictionary (pDb's dictionary), verified, and translated to the appropriate name id.

    Example Code:

    IF_Db *       pDb;       //Assume that we have already opened the database

    IF_Query *    pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE         rc;

 

    // Set the XPATH query criteria for query to be: "/person/name="ralph""

    // NOTE: It is assumed that the element names for "person" and "name" are defined in the

    // database dictionary for pDb

 

    rc = pQuery->setupQueryExpr( pDb, "/person/name=\"ralph\"");

 

    See Also: setupQueryExpr(1)

[Back to Top]


copyCriteria

    RCODE copyCriteria(

        IF_Query *           pSrcQuery);

Copy the query criteria from another query object into this object.  Any existing query criteria will be cleared first.

    Parameters In:

IF_Query  * pSrcQuery Query object whose query criteria is to be copied into this object.

    Parameters Out: none

    Example Code:

    IF_Query *   pQuery;    // Assume that we get the pQuery object by calling createIFQuery.

    IF_Query *   pSrcQuery;

    RCODE        rc;

    FLMUINT      uiIndex;

    FLMBOOL      bHaveMultiple;

 

    // Assume that pSrcQuery has already been set up with query criteria.

 

    rc = pQuery->copyCriteria( pSrcQuery);

 

[Back to Top]


addXPathComponent

    RCODE addXPathComponent(

        eXPathAxisTypes              eXPathAxis,

        eDomNodeType                eNodeType,

        FLMUINT                        uiNameId,

        IF_QueryNodeSource *    pNodeSource = NULL);

Add an XPATH component to the query criteria.

    Parameters In:

eXPathAxisTypes eXPathAxis The axis of this component.  The axis specifies this components relationship to the prior component (if any) - such as parent, child, attribute, previous sibling, etc.
eDomNodeType eNodeType The type of node for this component.
FLMUINT uiNameId The name id for the component.  This is only used if the node type (eNodeType) is ELEMENT_NODE, DATA_NODE, or ATTRIBUTE_NODE.
IF_QueryNodeSource * pNodeSource The axis of this component.  The axis specifies this components relationship to the prior component (if any) - such as parent, child, attribute, previous sibling, etc.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID    1    // Assume this is defined in the dictionary as "person"

    #define NAME_ELEMENT_ID      2    // Assume this is defined in the dictionary as "name"

 

    IF_Query *    pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE       rc;

   

    // Set the XPATH query criteria for query to be: "/person/name="ralph""

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( CHILD_AXIS, ELEMENT_NODE, NAME_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_EQ_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addUTF8Value(  "ralph", 0)))

    {

        goto Exit;

    }

 

    See Also: addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addOperator

    RCODE addOperator(

        eQueryOperators               eOperator,

        FLMUINT                        uiCompareRules = 0,

        IF_OperandComparer *    pOpComparer = NULL);

Add an operator to the query criteria.

    Parameters In:

eQueryOperators eOperator The operator to be added to the criteria.
FLMUINT uiCompareRules For string operands, additional comparison rules may be specified (such as case insensitive, compress whitespace, etc.).
IF_OperandComparer * pOpComparer An object that will perform the comparison.  If NULL, the comparison is done internally by XFLAIM using the predefined rules it has for each operator and the comparison rules.  If non-NULL, operands are passed to compare method on this object for comparison.

    Parameters Out: none

    Example Code: see addXPathComponent

    See Also: addXPathComponent, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addUnicodeValue

    RCODE addUnicodeValue(

        FLMUNICODE *    puzValue);

Add a unicode string operand to the query criteria.

    Parameters In:

FLMUNICODE * puzValue The unicode string operand.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID    1    // Assume this is defined in the dictionary as "person"

    #define NAME_ELEMENT_ID      2    // Assume this is defined in the dictionary as "name"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

    FLMUNICODE *    puzValue = {'r', 'a', 'l', 'p', 'h', 0};

   

    // Set the XPATH query criteria for query to be: "/person/name="ralph""

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( CHILD_AXIS, ELEMENT_NODE, NAME_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_EQ_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addUnicodeValue( puzValue)))

    {

        goto Exit;

    }

 

    See Also: addXPathComponent, addOperator, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addUTF8Value

    RCODE addUTF8Value(

        char *    pszUTF8Value);

Add a UTF8 string operand to the query criteria.

    Parameters In:

char * pszUTF8Value The UTF8 string operand.

    Parameters Out: none

    Example Code: see addXPathComponent

    See Also: addXPathComponent, addOperator, addUnicodeValue, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addBinaryValue

    RCODE addBinaryValue(

        void *            pvVal,

        FLMUINT    uiValLen);

Add a binary value operand to the query criteria.

    Parameters In:

void * pvVal The binary value operand.
FLMUINT uiValLen The length of the binary value in bytes.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID    1    // Assume this is defined in the dictionary as "person"

    #define PASSWORD_ELEMENT_ID  3    // Assume this is defined in the dictionary as "password"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

    FLMBYTE         ucPassword [20];

   

    // Set the XPATH query criteria for query to be: "/person/password=<binary value>"

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( CHILD_AXIS, ELEMENT_NODE, PASSWORD_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_EQ_OP, 0, NULL)))

    {

        goto Exit;

    }

 

    // Look for a password of all zeroes.

 

    memset( ucPassword, 0, sizeof( ucPassword));

    if (RC_BAD( rc = pQuery->addBinaryValue( ucPassword, sizeof( ucPassword))))

    {

        goto Exit;

    }

 

    See Also: addXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addUINTValue

    RCODE addUINTValue(

        FLMUINT    uiVal);

Add an unsigned integer value operand to the query criteria.

    Parameters In:

FLMUINT uiVal The unsigned integer value operand.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID        1    // Assume this is defined in the dictionary as "person"

    #define AGE_ATTRIBUTE_ID         4    // Assume this is defined in the dictionary as "age"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

   

    // Set the XPATH query criteria for query to be: "/person/@age >= 18"

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( ATTRIBUTE_AXIS, ATTRIBUTE_NODE,

                                AGE_ATTRIBUTE_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_GE_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addUINTValue( 18)))

    {

        goto Exit;

    }

 

    See Also: addXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addINTValue

    RCODE addINTValue(

        FLMINT    iVal);

Add a signed integer value operand to the query criteria.

    Parameters In:

FLMINT iVal The signed integer value operand.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID        1    // Assume this is defined in the dictionary as "person"

    #define AGE_ATTRIBUTE_ID         4    // Assume this is defined in the dictionary as "age"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

   

    // Set the XPATH query criteria for query to be: "/person/@age >= 18"

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( ATTRIBUTE_AXIS, ATTRIBUTE_NODE,

                                AGE_ATTRIBUTE_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_GE_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addINTValue( 18)))

    {

        goto Exit;

    }

 

    See Also: addXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addUINT64Value

    RCODE addUINT64Value(

        FLMUINT64    ui64Val);

Add a 64 bit unsigned integer value operand to the query criteria.

    Parameters In:

FLMUINT64 ui64Val The 64 bit unsigned integer value operand.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID        1    // Assume this is defined in the dictionary as "person"

    #define AGE_ATTRIBUTE_ID         4    // Assume this is defined in the dictionary as "age"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

   

    // Set the XPATH query criteria for query to be: "/person/@age >= 18"

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( ATTRIBUTE_AXIS, ATTRIBUTE_NODE,

                                AGE_ATTRIBUTE_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_GE_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addUINT64Value( 18)))

    {

        goto Exit;

    }

 

    See AlsoaddXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addINT64Value

    RCODE addINT64Value(

        FLMINT64    i64Val);

Add a 64 bit signed integer value operand to the query criteria.

    Parameters In:

FLMINT64 i64Val The 64 bit signed integer value operand.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID        1    // Assume this is defined in the dictionary as "person"

    #define AGE_ATTRIBUTE_ID         4    // Assume this is defined in the dictionary as "age"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

   

    // Set the XPATH query criteria for query to be: "/person/@age >= 18"

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( ATTRIBUTE_AXIS, ATTRIBUTE_NODE,

                                AGE_ATTRIBUTE_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_GE_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addINT64Value( 18)))

    {

        goto Exit;

    }

 

    See AlsoaddXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addBoolean, addFunction(1), addFunction(2)

[Back to Top]


addBoolean

    RCODE addBoolean(

        FLMBOOL    bVal,

        FLMBOOL    bUnknown = FALSE);

Add tri-state boolean predicate to the query criteria.  Allows an application to have a predicate that always evaluates to TRUE, FALSE, or UNKNOWN in the criteria.

    Parameters In:

FLMBOOL bVal The boolean value of TRUE or FALSE.  NOTE: This parameter is ignored if the bUnknown parameter is TRUE.  In that case, the value for the predicate will be UNKNOWN.
FLMBOOL bUnknown If TRUE, the value of the predicate is UNKNOWN, and the bVal parameter is ignored.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID        1    // Assume this is defined in the dictionary as "person"

    #define AGE_ATTRIBUTE_ID         4    // Assume this is defined in the dictionary as "age"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

   

    // Set the XPATH query criteria for query to be: "/person/@age >= 18 && <UNKNOWN>"

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( ATTRIBUTE_AXIS, ATTRIBUTE_NODE,

                                AGE_ATTRIBUTE_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_GE_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addINT64Value( 18)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_AND_OP, 0, NULL)))

    {

        goto Exit;

    }

 

    // The <UNKNOWN> predicate

 

    if (RC_BAD( rc = pQuery->addBoolean( FALSE, TRUE)))    // Could also be TRUE, TRUE

    {

        goto Exit;

    }

 

    See AlsoaddXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addFunction(1), addFunction(2)

[Back to Top]


addFunction(1)

    RCODE addFunction(

        eQueryFunctions     eFunction);

Add a pre-defined function into the query criteria.  Depending on the type of data returned by the function, a function may be inserted anywhere an operand could appear, or if the data returned is a boolean value (TRUE,FALSE,UNKNOWN), it may be inserted anywhere a predicate could appear.

    Parameters In:

eQueryFunctions eFunction The pre-defined function that is to be called.

    Parameters Out: none

    Example Code: none - there are no currently supported functions.

    See AlsoaddXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(2)

[Back to Top]


addFunction(2)

    RCODE addFunction(

        IF_QueryValFunc *    pFuncObj,

        FLMBOOL                bHasXPathExpr);

Add an application defined function into the query criteria.  Depending on the type of data returned by the function, a function may be inserted anywhere an operand could appear, or if the data returned is a boolean value (TRUE,FALSE,UNKNOWN), it may be inserted anywhere a predicate could appear.

    Parameters In:

IF_QueryValFunc * pFuncObj This is a pointer to the object whose methods will be called to obtain a value for the function during query evaluation.
FLMBOOL bHasXPathExpr This indicates whether or not the function takes an XPATH expression parameter.  The XPATH expression, if expected, must be specified inside parentheses, and must evaluate to a set of one or more DOM nodes.  See example.

    Parameters Out: none

    Example Code:

    #define PERSON_ELEMENT_ID        1    // Assume this is defined in the dictionary as "person"

    #define AGE_ATTRIBUTE_ID         4    // Assume this is defined in the dictionary as "age"

    #define ADDRESS_ELEMENT_ID       5    // Assume this is defined in the dictionary as "address"

 

    IF_Query *      pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE           rc;

    APP_Func        appFunc;   // Application defined function that implements IF_QueryValFunc

                               // This function expects an address element node as a parameter.

                               // There may be multiple address elements.

   

    // Set the XPATH query criteria for query to be: "/person[@age >= 18 && APP_FUNC(address)]"

   

    if (RC_BAD( rc = pQuery->addXPathComponent( ROOT_AXIS, ELEMENT_NODE, PERSON_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_LBRACKET_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( ATTRIBUTE_AXIS, ATTRIBUTE_NODE,

                                AGE_ATTRIBUTE_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_GE_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addINT64Value( 18)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_AND_OP, 0, NULL)))

    {

        goto Exit;

    }

 

    // The APP_FUNC(address) predicate

 

    if (RC_BAD( rc = pQuery->addFunction( &appFunc, TRUE)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_LPAREN_OP, 0, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addXPathComponent( CHILD_AXIS, ELEMENT_NODE, ADDRESS_ELEMENT_ID, NULL)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->addOperator( XFLM_RPAREN_OP, 0, NULL)))

    {

        goto Exit;

    }

 

    // Add the closing right bracket

 

    if (RC_BAD( rc = pQuery->addOperator( XFLM_RBRACKET_OP, 0, NULL)))

    {

        goto Exit;

    }

 

    See AlsoaddXPathComponent, addOperator, addUnicodeValue, addUTF8Value, addBinaryValue, addUINTValue, addINTValue, addUINT64Value, addINT64Value, addBoolean, addFunction(1)

[Back to Top]


getFirst

    RCODE getFirst(

        IF_Db *                    pDb,

        IF_DOMNode **     ppNode,

        FLMUINT                uiTimeLimit = 0);

Return the first node or document in the result set of the query.

    Parameters In:

IF_Db * pDb Pointer to database object.  This should represent the database that is to be searched.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.

    Parameters Out:

IF_DOMNode * ppNode Found node or document is returned here.  Note that if *ppNode is pointing to another node, it will be released before returning the found node or document.

    Example Code:

    IF_Query *      pQuery;    // Assume that we get the pQuery object by calling createIFQuery.

    IF_Db *         pDb;       // Assume that we have opened the database with a call to dbOpen.

    RCODE           rc;

    IF_DOMNode *    pNode = NULL;

    FLMBOOL         bHaveFirst = FALSE;

   

    // Assume that the query criteria has been set up by appropriate calls to addXPathComponent, etc.

   

    // Read through all of the results in the result set.

 

    for (;;)

    {

        if (!bHaveFirst)

        {

            rc = pQuery->getFirst( pDb, &pNode, 0);

            bHaveFirst = TRUE;

        }

        else

        {

            rc = pQuery->getNext( pD, &pNode, 0, 0, NULL);

        }

        if (RC_BAD( rc))

        {

            if (rc == NE_XFLM_EOF_HIT)

            {

                rc = NE_XFLM_OK;

                break;

            }

            else

            {

                goto Exit;

            }

        }

 

        // Process the returned node or document

        .

        .

        .

 

    }

    See Also: getLast, getNext, getPrev, getCurrent

[Back to Top]


getLast

    RCODE getLast(

        IF_Db *                    pDb,

        IF_DOMNode **     ppNode,

        FLMUINT                uiTimeLimit = 0);

Return the last node or document in the result set of the query.

    Parameters In:

IF_Db * pDb Pointer to database object.  This should represent the database that is to be searched.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.

    Parameters Out:

IF_DOMNode * ppNode Found node or document is returned here.  Note that if *ppNode is pointing to another node, it will be released before returning the found node or document.

    Example Code:

    IF_Query *      pQuery;    // Assume that we get the pQuery object by calling createIFQuery.

    IF_Db *         pDb;       // Assume that we have opened the database with a call to dbOpen.

    RCODE           rc;

    IF_DOMNode *    pNode = NULL;

    FLMBOOL         bHaveLast = FALSE;

   

    // Assume that the query criteria has been set up by appropriate calls to addXPathComponent, etc.

   

    // Read through all of the results in the result set - in reverse order

 

    for (;;)

    {

        if (!bHaveLast )

        {

            rc = pQuery->getLast( pDb, &pNode, 0);

            bHaveLast = TRUE;

        }

        else

        {

            rc = pQuery->getPrev( pD, &pNode, 0, 0, NULL);

        }

        if (RC_BAD( rc))

        {

            if (rc == NE_XFLM_BOF_HIT)

            {

                rc = NE_XFLM_OK;

                break;

            }

            else

            {

                goto Exit;

            }

        }

 

        // Process the returned node or document

        .

        .

        .

 

    }

    See Also: getFirst, getNext, getPrev, getCurrent

[Back to Top]


getNext

    RCODE getNext(

        IF_Db *                    pDb,

        IF_DOMNode **     ppNode,

        FLMUINT                uiTimeLimit = 0,

        FLMUINT                uiNumToSkip = 0,

        FLMUINT *             puiNumSkipped = NULL);

Return the next node or document in the result set of the query.  If the query object has not yet retrieved any objects and is not positioned anywhere, this method will start from the first node or document in the result set of the query.

    Parameters In:

IF_Db * pDb Pointer to database object.  This should represent the database that is to be searched.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.
FLMUINT uiNumToSkip Number of nodes or documents to skip over in the result set.  This includes skipping the node or document the query is currently positioned on.  NOTE: A value of zero is equivalent to a value of one.

    Parameters Out:

IF_DOMNode * ppNode Found node or document is returned here.  Note that if *ppNode is pointing to another node, it will be released before returning the found node or document.
FLMUINT * puiNumSkipped Returns the number of nodes or documents that were skipped over.  The count includes the current node or document, which is always skipped.  Thus, if a next node or document is found, the "skipped" count will always be at least one.  If no next node or document is found, this count will be zero.

    Example Code: see getFirst.

    See Also: getFirst, getLast, getPrev, getCurrent

[Back to Top]


getPrev

    RCODE getPrev(

        IF_Db *                    pDb,

        IF_DOMNode **     ppNode,

        FLMUINT                uiTimeLimit = 0,

        FLMUINT                uiNumToSkip = 0,

        FLMUINT *             puiNumSkipped = NULL);

Return the previous node or document in the result set of the query.  If the query object has not yet retrieved any objects and is not positioned anywhere, this method will start from the last node or document in the result set of the query.

    Parameters In:

IF_Db * pDb Pointer to database object.  This should represent the database that is to be searched.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.
FLMUINT uiNumToSkip Number of nodes or documents to skip over in the result set.  This includes skipping the node or document the query is currently positioned on.  NOTE: A value of zero is equivalent to a value of one.

    Parameters Out:

IF_DOMNode * ppNode Found node or document is returned here.  Note that if *ppNode is pointing to another node, it will be released before returning the found node or document.
FLMUINT * puiNumSkipped Returns the number of nodes or documents that were skipped over.  The count includes the current node or document, which is always skipped.  Thus, if a previous node or document is found, the "skipped" count will always be at least one.  If no previous node or document is found, this count will be zero.

    Example Code: see getLast.

    See Also: getFirst, getLast, getNext, getCurrent

[Back to Top]


getCurrent

    RCODE getCurrent(

        IF_Db *                    pDb,

        IF_DOMNode **     ppNode);

Return the current node or document in the result set of the query.  If the query object has not yet retrieved any objects and is not positioned anywhere, this method will return an error.

    Parameters In:

IF_Db * pDb Pointer to database object.  This should represent the database that is to be searched.

    Parameters Out:

IF_DOMNode * ppNode Current node or document is returned here.  Note that if *ppNode is pointing to another node, it will be released before returning the current node or document.

    Example Code:

    IF_Query *      pQuery;    // Assume that we get the pQuery object by calling createIFQuery.

    IF_Db *         pDb;       // Assume that we have opened the database with a call to dbOpen.

    RCODE           rc;

    IF_DOMNode *    pNode = NULL;

   

    // Assume that the query criteria has been set up by appropriate calls to addXPathComponent, etc.

   

    // Assume that we have already made a call to getFirst, getLast, getNext, or getPrev

 

    rc = pQuery->getCurrent( pDb, &pNode);

    See Also: getFirst, getLast, getNext, getPrev

[Back to Top]


resetQuery

    void resetQuery( void);

Clears the query criteria and sets the query object to its initialized state.

    Parameters In: none

    Parameters Out: none

    Example Code:

    IF_Query *      pQuery;    // Assume that we get the pQuery object by calling createIFQuery.

 

    pQuery->resetQuery();

[Back to Top]


getStatsAndOptInfo

    RCODE getStatsAndOptInfo(

        FLMUINT *                     puiNumOptInfos,

        XFLM_OPT_INFO **     ppOptInfo);

Return optimization and statistics information about the query.

    Parameters In: none

    Parameters Out:

FLMUINT * puiNumOptInfos Number of XFLM_OPT_INFO structures in the array represented by *ppOptInfo.
XFLM_OPT_INFO ** ppOptInfo Returns a pointer to an array of XFLM_OPT_INFO structures that contain optimization and statistics information on the query.  When the application is done with this array, it should free it by calling IF_DbSystem::freeMem.

    Example Code:

    IF_Query *      pQuery;    // Assume that we get the pQuery object by calling createIFQuery.

    IF_Db *         pDb;       // Assume that we have opened the database with a call to dbOpen.

    RCODE           rc;

    XFLM_OPT_INFO * pOptInfoArray = NULL;

    FLMUINT         uiNumOptInfos;

   

    // Assume that the query criteria has been set up by appropriate calls to addXPathComponent, etc.

   

    // Assume that we have already made calls to getFirst, getLast, getNext, or getPrev

 

    if (RC_BAD( rc = pQuery->getStatsAndOptInfo( &uiNumOptInfos, &pOptInfoArray)))

    {

        goto Exit;

    }

 

    // Process the information

    .

    .

    .

 

Exit:

 

    // Free the array

 

    pQuery->freeStatsAndOptInfo( &pOptInfoArray);

 

    See Also: freeStatsAndOptInfo

[Back to Top]


freeStatsAndOptInfo

    void freeStatsAndOptInfo(

        XFLM_OPT_INFO **     ppOptInfo);

Free the optimization and statistics array that was allocated by getStatsAndOptInfo.

    Parameters In/Out:

XFLM_OPT_INFO ** ppOptInfo *ppOptInfo points to array that is to be freed.  Upon freeing the array, this routine will also reset *ppOptInfo to NULL.

    Example Code: see getStatsAndOptInfo.

    See Also: getStatsAndOptInfo

[Back to Top]


setDupHandling

    void setDupHandling(

        FLMBOOL    bRemoveDups);

Specify whether or not to allow a document to be returned more than once from a query.  This method must be called before the query has been optimized.

    Parameters In:

FLMBOOL bRemoveDups If TRUE, a document may only be returned once from a query.

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE        rc;

 

    // Set query to only allow a document to be returned once.

 

    rc = pQuery->setDupHandling( TRUE);

 

[Back to Top]


setIndex

    RCODE setIndex(

        FLMUINT    uiIndex);

Specify the index to be used for the query.  May also be used to specify that NO index is to be used - i.e., force a database scan.

    Parameters In:

FLMUINT uiIndex Index to be used.  Zero specifies that NO index is to be used - i.e., force a database scan.

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE        rc;

 

    // Set query to use index #27

 

    rc = pQuery->setIndex( 27);

 

[Back to Top]


getIndex

    RCODE getIndex(

        IF_Db *           pDb,

        FLMUINT *    puiIndex,

        FLMBOOL *   pbHaveMultiple);

Returns the index being used for the query, if any.  NOTE: If the query has not been optimized, it will be inside this method in order to determine an index.  Therefore, this call should only be made after all of the query criteria has been set.

    Parameters In:

IF_Db * pDb Pointer to database object - should be database that is going to be queried.

    Parameters Out:

FLMUINT * puiIndex Returns index that is being used, if any.  Zero is returned if no index is being used.
FLMBOOL * pbHaveMultiple Returns a flag indicating whether more than one index is being used.

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE        rc;

    FLMUINT      uiIndex;

    FLMBOOL      bHaveMultiple;

 

    // Assume that query has already set up all query criteria.

 

    rc = pQuery->getIndex( &uiIndex, &bHaveMultiple);

 

[Back to Top]


addSortKey

    RCODE addSortKey(

        void *             pvSortKeyContext,

        FLMBOOL    bChildToContext,

        FLMBOOL    bElement,

        FLMUINT      uiNameId,

        FLMUINT      uiCompareRules,

        FLMUINT      uiLimit,

        FLMUINT      uiKeyComponent,

        FLMBOOL     bSortDescending,

        FLMBOOL     bSortMissingHigh,

        void **            ppvContext);

Specifies a sort key for sorting the query result set.  Multiple sort key components may be specified by calling this method multiple times.  The uiKeyComponent parameter specifies whether it is a primary key component (#1), secondary key component (#2), etc.  Depending on which indexes were selected for optimization, it may be necessary for XFLAIM to build the entire result set before any of the query results can actually be returned.  This will be true if more than one index is used to optimize the query, or if a single index is used whose definition does not match the sort keys specified.

    Parameters In:

void  * pvSortKeyContext Each sort key component specifies either an element or an attribute in an XML document that is relative to another element or attribute in the same XML document.  This parameter is a handle to a sort key component that was previously created by calling addSortKey (returned via the ppvContext parameter).  In this way, the sort keys for a query result set may be made up of virtually any combination of elements and/or attributes within documents of the result set.  Note that it is legitimate to add sort key components that are not actually used for sorting - but are used to specify context for the components that are to be used in sorting.  Non-sorting components are given by passing a zero in the uiKeyComponent parameter.
FLMBOOL bChildToContext Is this sort key component a child or sibling of the component specified by pvSortKeyContext?
FLMBOOL bElement Is this sort key component an attribute or an element?
FLMUINT uiNameId Element name id or attribute name id for this component.
FLMUINT uiCompareRules If the component is a string data type, this specifies the comparison rules to be used during sort compare operations.
FLMUINT uiLimit If the component is a string data type, this specifies the maximum number of characters that will be used in the sort key component.  NOTE: This does NOT mean that the entire value will not be compared during sort operations.  It simply limits the amount of data that will be stored in the keys in the b-tree that will be used to create the sorted result set.  It is important to have a limit so that the sort keys don't grow too large to hold in the b-tree.
FLMUINT uiKeyComponent Specifies whether this sort key component is a primary key component (#1), secondary key component (#2), etc.  A value of zero specifies that this component is not to be used in sorting at all, but is provided to specify context for other components.

If there are N components with non-zero values in this parameter, those values must include all of the numbers between 1 and N.  It does not matter what order they are defined in, as long as all numbers between 1 and N were specified once and only once.  There must be at least one component with a non-zero value in this parameter.

FLMBOOL bSortDescending Specifies whether this sort key component should be sorted in ascending order (FALSE) or descending order (TRUE).
FLMBOOL bSortMissingHigh Specifies what to do when this sort key component is missing from the document that is being sorted.  Missing components may be sorted "high" (TRUE) - meaning they sort AFTER all other values, or "low" (FALSE) - meaning they sort BEFORE all other values.

    Parameters Out:

void  * ppvContext Returns a context handle for the sort key component just created.  This may be passed into subsequent calls to addSortKey in the pvSortKeyContext parameter to provide context for subsequently created sort key components.  If a NULL is passed, no context handle is returned.

    Example Code:

    #define PERSON_ELEMENT_ID        1    // Assume this is defined in the dictionary as "person"

    #define LASTNAME_ELEMENT_ID      6    // Assume this is defined in the dictionary as "LastName"

    #define FIRSTNAME_ELEMENT_ID     7    // Assume this is defined in the dictionary as "FirstName"

 

    IF_Query *         pQuery;    // Assume that we get the pQuery object by calling createIFQuery.

    IF_Db *            pDb;       // Assume that pDb has already been opened by calling dbOpen

    RCODE              rc;

    IF_DOMNode *       pNode = NULL;

    IF_DataVector *    pSearchKey = NULL;

    void *             pvElementComponent;

    FLMUINT            uiCurrPosition;

 

    // Create a sort key of LastName (primary key) + FirstName (secondary key).  These should be two

    // elements subordinate to the person element.

 

    // The "person" element is context for the other two components - it is NOT used to sort on.

 

    if (RC_BAD( rc = pQuery->addSortKey( NULL, FALSE, TRUE, PERSON_ELEMENT_ID,

                                     0, 0, 0, FALSE, FALSE, &pvElementComponent)))

    {

        goto Exit;

    }

 

    // The "LastName" element is the primary sort key.  It must be a child of the "person" element

    // (specified by the pvElementComponent parameter)

 

    if (RC_BAD( rc = pQuery->addSortKey( pvElementComponent, TRUE, TRUE, LASTNAME_ELEMENT_ID,

                                     0, 0, 1, FALSE, FALSE, NULL)))

    {

        goto Exit;

    }

 

    // The "FirstName" element is the secondary sort key.  It must be a child of the "person" element

    // (specified by the pvElementComponent parameter)

 

    if (RC_BAD( rc = pQuery->addSortKey( pvElementComponent, TRUE, TRUE, FIRSTNAME_ELEMENT_ID,

                                     0, 0, 2, FALSE, FALSE, NULL)))

    {

        goto Exit;

    }

 

    // Enable absolute positioning in the result set

 

    if (RC_BAD( rc = pQuery->enablePositioning()))

    {

        goto Exit;

    }

 

    // Position to the 14th item in the result set and retrieve it

 

    if (RC_BAD( rc = pQuery->positionTo( pDb, &pNode, 0, 14)))

    {

        goto Exit;

    }

 

    // Position to the item whose last name is "Smith" and whose first name is "Carl"

    // Setup a search key for that purpose.

 

    if (RC_BAD( rc = pDbSystem->createIFDataVector( &pSearchKey)))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pSearchKey->setUTF8( 0, (FLMBYTE *)"Smith")))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pSearchKey->setUTF8( 1, (FLMBYTE *)"Carl")))

    {

        goto Exit;

    }

    if (RC_BAD( rc = pQuery->positionTo( pDb, &pNode, 0, pSearchKey, XFLM_EXACT)))

    {

        goto Exit;

    }

 

    // Determine our current absolute position in the result set

 

    if (RC_BAD( rc = pQuery->getPosition( pDb, &uiCurrPosition)))

    {

        goto Exit;

    }

 

 

    See Also: enablePositioning, positionTo(1), positionTo(2), getPosition, buildResultSet, stopBuildingResultSet, getCounts, enableResultSetEncryption

[Back to Top]


enablePositioning

    RCODE enablePositioning( void);

Enable absolute positioning for the query result set.  When absolute positioning is enabled, the query results are gathered into a temporary result set so that the application can position to any member of the set using a number - 0 to N-1, where N is the number of items in the result set.  Depending on sort options (see addSortKey) and which indexes were selected for optimization, it may be necessary for XFLAIM to build the entire result set before any of the results can actually be returned.

    Parameters In: none

    Parameters Out: none

    Example Code: see addSortKey.

    See Also: addSortKey, positionTo(1), positionTo(2), getPosition, buildResultSet, stopBuildingResultSet, getCounts, enableResultSetEncryption

[Back to Top]


positionTo(1)

    RCODE positionTo(

        IF_Db *                   pDb,

        IF_DOMNode **    ppNode,

        FLMUINT               uiTimeLimit,

        FLMUINT               uiPosition);

Position to an absolute position within the result set and return the node or document at that position.  Depending on sort options (see addSortKey), the entire result set may need to be created before this method returns.  NOTE: Absolute positioning must have been enabled by calling enablePositioning.

    Parameters In:

IF_Db * pDb Pointer to database object - should be database that is going to be queried.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.
FLMUINT uiPosition Absolute position to position to in result set.  This is zero based.  If there are N nodes or documents in the result set, this must be a number between 0 and N-1.

    Parameters Out:

IF_DOMNode ** ppNode Node or document at the specified position in the result set is returned here.  Note that if *ppNode is pointing to another node, it will be released before returning the current node or document.

    Example Code: see addSortKey.

    See Also: addSortKey, enablePositioning, positionTo(2), getPosition, buildResultSet, stopBuildingResultSet, getCounts, enableResultSetEncryption

[Back to Top]


positionTo(2)

    RCODE positionTo(

        IF_Db *                   pDb,

        IF_DOMNode **    ppNode,

        FLMUINT               uiTimeLimit,

        IF_DataVector *      pSearchKey,

        FLMUINT               uiFlags);

Position to a specific key in a result set.  This method can only be called if sort keys have been specified (see addSortKey).  Depending on the sort keys and which indexes have been selected for optimization, the entire result set may need to be created before this method returns.

    Parameters In:

IF_Db * pDb Pointer to database object - should be database that is going to be queried.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.
IF_DataVector * pSearchKey Search key to be positioned to.  The components of the vector must correspond to the sort key components that were specified by calling addSortKey.  The components of the vector are zero-based, so the zeroeth component of the vector corresponds to sort key component #1, the first component of the vector corresponds to sort key component #2, etc.
FLMUINT uiFlags These flags are the same as they are for the IF_Db::keyRetrieve method.

    Parameters Out:

IF_DOMNode ** ppNode Node or document at the specified position in the result set is returned here.  Note that if *ppNode is pointing to another node, it will be released before returning the current node or document.

    Example Code: see addSortKey.

    See Also: addSortKey, enablePositioning, positionTo(1), getPosition, buildResultSet, stopBuildingResultSet, getCounts, enableResultSetEncryption

[Back to Top]


getPosition

    RCODE getPosition(

        IF_Db *           pDb,

        FLMUINT *    puiPosition);

Get our current absolute position within the result set.  Returned position is zero-based.  This can only be called if the enablePositioning method has enabled absolute positioning for the result set.

    Parameters In:

IF_Db * pDb Pointer to database object - should be database that is going to be queried.

    Parameters Out:

FLMUINT * puiPosition Returns current absolute position - zero based.

    Example Code: see addSortKey.

    See Also: addSortKey, enablePositioning, positionTo(1), positionTo(2), buildResultSet, stopBuildingResultSet, getCounts, enableResultSetEncryption

[Back to Top]


buildResultSet

    RCODE buildResultSet(

        IF_Db *        pDb,

        FLMUINT    uiTimeLimit);

Build the result set for a query.  This method is supplied primarily for applications that want to build the result set on a background thread, while allowing another thread to retrieve results.  If this method is not called, and a temporary result set is needed, XFLAIM will build it automatically as needed.  I this manner, it is possible to build an application that allows one thread to launch a query that gathers results in the background.  Another thread can interact with the user as needed - waiting for keyboard keystrokes, etc.  When the user starts scrolling through the results, instead of having to fetch them at that point in time, they will have already been fetched by the background thread and will appear to be instantly available.  There are still times when the user may be required to wait for results - such as when the entire result set has to be gathered and sorted before any results can be returned.  However, having the capability to collect results in a background thread will still be very valuable in such situations.

    Parameters In:

IF_Db * pDb Pointer to database object - should be database that is going to be queried.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.

    Parameters Out: none

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE        rc;

    IF_Db *      pDb;

    // Assume that query has already set up all query criteria.  Assume that the thread that calls

    // buildResultSet is a thread that is dedicated to that purpose and none else.  In order to make

    // sure that this thread's view of the database is consistent with the thread that created

    // the query, the pDb used here should start its read transaction using the transBegin method

    // that takes another IF_Db * for its parameter.  That other IF_Db object should be the other

    // thread's IF_Db object.

 

    rc = pQuery->buildResultSet( pDb, 0);

 

    See Also: addSortKey, enablePositioning, positionTo(1), positionTo(2), getPosition, stopBuildingResultSet, getCounts, enableResultSetEncryption

[Back to Top]


stopBuildingResultSet

    void stopBuildingResultSet( void);

This method is used to tell whatever thread is currently building the result set (see buildResultSet) to stop.  It will not return until the other thread has exited buildResultSet.  If no thread is currently calling buildResultSet, this method will return immediately.

    Parameters In: none

    Parameters Out: none

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

 

    // Assume that query has already set up all query criteria and that another thread is currently

    // in the middle of calling buildResultSet.  This call will cause the other thread to exit from

    // buildResultSet.  This call will not return until the other thread has exited buildResultSet.

 

    pQuery->stopBuildingResultSet();

 

    See Also: addSortKey, enablePositioning, positionTo(1), positionTo(2), getPosition, buildResultSet, getCounts, enableResultSetEncryption

[Back to Top]


getCounts

    RCODE getCounts(

        IF_Db *            pDb,

        FLMUINT        uiTimeLimit,

        FLMBOOL       bPartialCountOk,

        FLMUINT *      puiReadCount,

        FLMUINT *      puiPassedCount,

        FLMUINT *      puiPositionableToCount,

        FLMBOOL *     pbDoneBuildingResultSet = NULL);

Get counts for a query result set that is either a) in the process of being built, or b) has been built.  This is useful for an application that wants to show progress as a result set is being built by a background thread (see buildResultSet).  It also tells an application whether or not it can do absolute positioning inside of a partially built result set - which is possible if there are no sort keys, or if the sort keys match the order of the index that is being used to optimize the query.

    Parameters In:

IF_Db * pDb Pointer to database object - should be database that is going to be queried.
FLMUINT uiTimeLimit Time limit for this operation (in milliseconds).  A value of zero indicates that there is no time limit.
FLMBOOL bPartialCountOk Should the method wait until the building of the result set is complete?  Or is it ok to return a partial count.  If this parameter is FALSE, this method will wait until the entire result set is built.  If the result set is not currently being built and has not yet been built, this method will build the result set and then return the counts.

    Parameters Out:

FLMUINT * puiReadCount Number of nodes or documents that have been "read" and evaluated so far while building the result set.
FLMUINT * puiPassedCount Number of nodes or documents that passed the query criteria so far and are currently in the result set.
FLMUINT * puiPositionableToCount Number of nodes or documents that can be positioned to so far.  NOTE: This will always either be zero, or will be the same as *puiPassedCount.  If it is non-zero, it means that we don't have to collect all of the result set and then sort it - the items can go into the result set in the order we find them.  This is either a) because we are not sorting the result set, or b) the sort keys match the index we are using for optimization.
FLMBOOL * pbDoneBuildingResultSet Flag indicating whether the entire result set has been collected.  If TRUE, *puiPassedCount and *puiPositionableCount should be the same.

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

    RCODE        rc;

    IF_Db *      pDb;

    FLMUINT      uiReadCount;

    FLMUINT      uiPassedCount;

    FLMUINT      uiPositionableToCount;

    FLMBOOL      bDoneBuildingResultSet;

 

    // Assume that query has already set up all query criteria.  Assume that another thread is

    // currently calling buildResultSet.  Determine how far along we are.

 

    rc = pQuery->getCounts( pDb, 0, TRUE, &uiReadCount, &uiPassedCount, &uiPositionableToCount,

                    &bDoneBuildingResultSet);

 

    See Also: addSortKey, enablePositioning, positionTo(1), positionTo(2), getPosition, buildResultSet, stopBuildingResultSet, enableResultSetEncryption

[Back to Top]


enableResultSetEncryption

    void enableResultSetEncryption( void);

Enable encrypting a query result set.  This is useful when a query is going to have to use a temporary result set for its query results (either to sort it, or so it can do absolute positioning in the result set).  When a result set must be sorted, it may store sort keys in the result set.  If these sort keys contain sensitive data, they should be encrypted, because result sets may spill over onto disk.  Thus, an application should call this method if any of the sort keys contain sensitive data.  NOTE: If a query does not end up using a temporary result set, enabling result set encryption will have no effect.

    Parameters In: none

    Parameters Out: none

    Example Code:

    IF_Query *   pQuery;    //Assume that we get the pQuery object by calling createIFQuery.

 

    // Assume that query has already set up all query criteria and sort keys.  We are encrypting

    // the result set because the sort keys contain sensitive data.

 

    pQuery->enableResultSetEncryption();

 

    See Also: addSortKey, enablePositioning, positionTo(1), positionTo(2), getPosition, buildResultSet, stopBuildingResultSet, getCounts

[Back to Top]


setQueryStatusObject

    void setQueryStatusObject(

        IF_QueryStatus *    pQueryStatus);

Set the query status object for the query.  The query status object contains methods that XFLAIM will call as it processes a query.  This allows an application to see query progress and display progress information and/or cancel a query at any time.

    Parameters In:

IF_QueryStatus * pQueryStatus Pointer to query status object.  The application is responsible for implementing this interface.

    Parameters Out: none

    Example Code:

    IF_Query *         pQuery;            //Assume that we get the pQuery object

                                          // by calling createIFQuery.

    APP_QueryStatus    appQueryStatus;    // Application implementation of the IF_QueryStatus interface

 

    pQuery->setQueryStatusObject( &appQueryStatus);

 

    See Also: setQueryValidatorObject

[Back to Top]


setQueryValidatorObject

    void setQueryValidatorObject(

        IF_QueryValidator *    pQueryValidator);

Set the query validator object for the query.  The query validator object contains methods that XFLAIM will call after it has passed a node or document that it thinks should be returned.  If a query validator object is specified, the application may validate the node or document before it is actually returned.  It may choose to fail the node or document, in which case it will not be returned or included in the query result set.

    Parameters In:

IF_QueryValidator * pQueryValidator Pointer to query validator object.  The application is responsible for implementing this interface.

    Parameters Out: none

    Example Code:

    IF_Query *         pQuery;            //Assume that we get the pQuery object

                                          // by calling createIFQuery.

    APP_QueryValidator appQueryValidator; // Application implementation of the IF_QueryValidator

                                          // interface.

 

    pQuery->setQueryValidatorObject( &appQueryValidator);

 

    See Also: setQueryStatusObject

[Back to Top]