The fastest way to check feature existence by UUID in DgnModelRefP

Hi,

In our application (called MacroTEL) we dynamically fetch features (in a loop) from an Oracle DB based on user’s zoom&pan operations. When the view’s old and new extents overlap, we get from the DB the same feature that we already have in the DGN. To prevent duplicates we check the XFM UUID of the feature coming from the DB in the model we’re writing that feature. In the SS2 we could use this code and it did not have significant impact on performance:

EXPORT_GENERAL BoolInt hxfmFeature_existsByRootUUIDAndModelRef
(
DgnModelRefP    dgnModelRef,
MSWChar         *rootUUIDP
)
{
    if (mdlModelRef_isActiveModel (dgnModelRef))
    {
        XfmFeatureListP    featureList = NULL;

        if (SUCCESS != xfmFeatureMgr_getSessionFeaturesList (&featureList))
            return FALSE;

        return (SUCCESS == xfmFeatureList_findUuidByModelRef (NULL, featureList, dgnModelRef, rootUUIDP));
    }
    else
    {
        XfmFeatureP        featureP = NULL;

        if (SUCCESS != xfmFeature_createFromExistingRootFeatureUUIDByModelRef (&featureP, dgnModelRef, rootUUIDP))
            return FALSE;

        xfmFeature_freeFP (&featureP);
        return TRUE;
    }
}

In SS10, on the contrary, using the same code had enormous impact on performance so I asked here for an advice. (I’ve tried to find it, but it somehow disappeared.) Basically after some further tests we ended up with this code. It seemed to work and also the performance was ok. Unfortunately it turned up to be unreliable. It looks like the featureList doesn’t get updated immediately after some features are added to the model and then calling the xfmFeatureList_findUuid doesn’t return non SUCCESS, what causes my function return FALSE even if the same feature is already in the model. And, as you can imagine, every further fetch causes duplicate features in the model.

EXPORT_GENERAL BoolInt hxfmFeature_existsByRootUUIDAndModelRef
(
DgnModelRefP    dgnModelRef,
MSWChar         *rootUUIDP
)
{
    if (mdlModelRef_isActiveModel (dgnModelRef))
    {
        XfmFeatureListP    featureList = NULL;

        if (SUCCESS != xfmFeatureMgr_getSessionFeaturesList (&featureList))
            return FALSE;

        return SUCCESS == xfmFeatureList_findUuid (NULL, NULL, featureList, rootUUIDP);
    }
    else
    {
        XfmFeatureP        featureP = NULL;

        if (SUCCESS != xfmFeature_createFromExistingRootFeatureUUIDByModelRef (&featureP, dgnModelRef, rootUUIDP))
            return FALSE;

        xfmFeature_free (&featureP);
        return TRUE;
    }
}

The shown code is used in three different cases. Writing to:

  1. the active model
  2. a model opened as mdlWorkDgn_openFile, while the same model is attached as a reference
  3. a model opened as mdlWorkDgn_openFile, while the same model is not attached as a reference

So here is my question: What is the fastest way to check feature existence by UUID in DgnModelRefP?

SDK: 08.11.09.867 (MicroStation and Bentley Map)

Product: 08.11.09.836cs (Map PowerView)

Thank you in advance,
Mirek