We had problem joining an sdf featureClass to an Oracle table using Autodesk Oracle provider.
This problem was detected on
- MapGuide Enterprise 2009 SP1
- MapGuide EnterPrise 2010
- MapGuide OS 2.1 alpha ( with FDO from Enterprise 2010)
But it was working fine on
- MapGuide Enterprise 2009
- MapGuide OS 2.0 ( with FDO from Enterprise 2009 SP1)
I spended some time in debug to figure out what was happening.
First thing i found, there are 4 join algorythms and Mapguide choose the proper one depending on the providers sorting capabilities
If both provider support sorting then algo = sort-merge
If only first provider support sorting then algo = nested loop join and sorted block
If only second provider support sorting then algo = Batch Sorted Block
if both does not support sorting then algo = nested loop join
I was currious because i had a copy of my Oracle table in SHP format and joining my shp to the same sdf was working fine.
Oracle joined to SDF is using the nested loop join and sorted block algo
and
SHP to SDF is using the nested loop join algo
So to test, i forced the use of the nested loop join for all joins.
Using this, Oracle->SDF join works.
I bet the reason for these 4 algo is performances related. So i decided to investigate and try to find the problem in the nested loop join and sorted block algo
I found that the sdfReader was closed just before an attemp to get the table description, that was throwing a null reference exception.
In the GwsRightNestedLoopSortedBlockJoinQueryResults.cpp file
EGwsStatus CGwsRightNestedLoopSortedBlockJoinQueryResults::SetRelatedValues (
const GWSFeatureId & vals
)
{
if (m_joinkeys == vals) {
if (! m_neverusepooling) {
// this completes features pool
if (! m_bClosed) {
while (ReadNext ())
;
//Close (); /* this should not be closed at this time, it will be closed later */
}
}
m_usepool = true;
m_poolpos = -1;
return eGwsOk;
}
m_pool->Reset ();
m_usepool = false;
m_poolpos = -1;
return CGwsRightNestedLoopJoinQueryResults::SetRelatedValues (vals);
}
With that little Close() commented out the nested loop join and sorted block algo works fine.
The SdfReader seems to be closed ok but i would need help from a GWS expert to validate this fix because that code is not very easy to follow.
Another question, Now that i got both algo working, i timed both to check the gain in performance.
Surprise! the nested loop join is faster (1.5 sec) than the nested loop join and sorted block (2 sec). Should we use the nested loop join for that case?
Bruno Scott