[mapguide-commits] r6348 - trunk/MgDev/Server/src/Gws/GwsQueryEngine
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Dec 20 06:54:37 EST 2011
Author: jng
Date: 2011-12-20 03:54:37 -0800 (Tue, 20 Dec 2011)
New Revision: 6348
Modified:
trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsBatchSortedBlockJoinQueryResults.cpp
trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsFeatureSourceQuery.cpp
Log:
#1888: Supplemental fix. This refines the property name check if the left side is a join query with a sortable left side.
Modified: trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsBatchSortedBlockJoinQueryResults.cpp
===================================================================
--- trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsBatchSortedBlockJoinQueryResults.cpp 2011-12-20 09:58:54 UTC (rev 6347)
+++ trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsBatchSortedBlockJoinQueryResults.cpp 2011-12-20 11:54:37 UTC (rev 6348)
@@ -29,6 +29,19 @@
// This setting limits the batch size used by the join algorithm
int CGwsBatchSortedBlockJoinQueryResults::sm_nBatchSize = 100; //Default
+// FIXME:
+//
+// All current MapGuide Feature Join bugs (#502, #791, #1396, #1790) are caused by this
+// particular join algorithm. All tickets involved a SDF/SHP joined to a sortable secondary
+// source
+//
+// Before #1888, SDF/SHP sources were not considered sortable (they still are not sortable if
+// the join is on multiple properties, but this scenario is pretty uncommon)
+//
+// The submission of #1888 therefore effectively sweeps the above tickets under the carpet
+// as this algorithm is no longer used, but that doesn't hide the fact if this
+// algorithm is chosen with data sources similar to the aforementioned tickets,
+// the merged result may not be correct.
/////////////////////////////////////////////////////////////////////
//
Modified: trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsFeatureSourceQuery.cpp
===================================================================
--- trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsFeatureSourceQuery.cpp 2011-12-20 09:58:54 UTC (rev 6347)
+++ trunk/MgDev/Server/src/Gws/GwsQueryEngine/GwsFeatureSourceQuery.cpp 2011-12-20 11:54:37 UTC (rev 6348)
@@ -357,14 +357,68 @@
lJoin->JoinMethod () == eGwsSortMerge)
{
// if left part is ordered and ordering is identical to
- // the left join attrbites use this orderin
+ // the left join attributes use this ordering
+ //
+ // Or to explain visually (in crude ASCII):
+ //
+ // [Left Side - Joined]
+ //
+ // [Left sorting prop \ /
+ // for first join] \/
+ // \
+ // [Our current left side] \ / [Our right side]
+ // \ /
+ // [Left sorting prop for \ /
+ // 2nd join is the same] \/
+ //
+ // If both left sorting props are the same it implies both are the same. Left side here
+ // cannot support ordering if both are different because sorting cannot be applied to an
+ // iterator (which the join source is represented by)
+ //
+ // TODO: If we want to be really smart, we would propagate the new property back to the parent
+ // source as an additional property to sort on (if capable) if they're different
FdoPtr<FdoStringCollection> l = lJoin->LeftProperties ();
if (l->GetCount () == lCols->GetCount ()) {
int i;
for (i = 0; i < l->GetCount (); i ++) {
- if (wcscmp (l->GetString (i), lCols->GetString (i)) != 0) {
- break;
+ //Compare the names
+ FdoPtr<FdoExpression> lexpr1 = FdoExpression::Parse(l->GetString(i)); //Join Source
+ FdoPtr<FdoExpression> lexpr2 = FdoExpression::Parse(lCols->GetString(i)); //Our left join prop
+ //Both parse out to identifiers
+ if (lexpr1->GetExpressionType() == FdoExpressionItemType_Identifier &&
+ lexpr2->GetExpressionType() == FdoExpressionItemType_Identifier)
+ {
+ FdoIdentifier* ident1 = (FdoIdentifier*)lexpr1.p; //Join Source
+ FdoIdentifier* ident2 = (FdoIdentifier*)lexpr2.p; //Our left join prop
+ FdoString* name1 = ident1->GetName();
+ FdoString* name2 = ident2->GetName();
+ bool bMatch = wcscmp (name1, name2) == 0;
+
+ //If our left join prop is qualified need to check if join names match
+ int scopeLen;
+ FdoString** ident2Scope = ident2->GetScope(scopeLen);
+ if (scopeLen > 0)
+ {
+ //The first descendant scope is the one we're interested in
+ FdoString* parentName = ident2Scope[scopeLen - 1];
+ //The originating left source join query definition
+ IGWSJoinQueryDefinition* leftJoinQueryDef = dynamic_cast<IGWSJoinQueryDefinition*>(lqdef.p);
+ if (NULL != leftJoinQueryDef)
+ {
+ FdoString* joinName = leftJoinQueryDef->JoinName();
+ if (wcscmp(parentName, joinName) != 0)
+ bMatch = false;
+ }
+ }
+
+ if (!bMatch) {
+ break;
+ }
}
+ else
+ {
+ break;
+ }
}
if (i == l->GetCount ())
lSupportsOrdering = true;
More information about the mapguide-commits
mailing list