summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2016-09-27 05:08:51 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2016-09-27 05:26:02 +0200
commit3b64a198568d5b2bb14066581aca112cc6182fd7 (patch)
tree9f0c7dab5062a1de141d71f8186d47ff09e1e17d /sc/source/core
parent622bb4bc72ee6e8eae3193e80e13748be150e1e0 (diff)
bnc#957991: Improve pivot cache reading performance
Performance problem was caused by grouping. Pivot tables with the same source are linked to each other by the pivot cache and so all the pivot tables were updated when one group was added to one of the tables. This code change first of all fixes a functional issue: group name was wrongly imported and so pivot tables using group fields were broken. This caused by calling RefreshPivotTableGroups() on a pivot table which is not part of the cache yet and so update was not called on this table. Calling ReloadGroupTableData() solve this problem. Second part of the codechange is about the consistency of the pivot cache. We have an invariant in this code to have the same groups for tabels with the same source. To keep this invariant we update every newly inserted tables adding the neccessary groups. The performance improvement here is that until the table is not part of the cache, it does not updates other tables. Group syncronization is done when the table is inserted to the ScDPCollection. Change-Id: Iaff55ffa3ed9c9b48cb18bd150eb4e1f7b617353
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/data/dpobject.cxx74
1 files changed, 74 insertions, 0 deletions
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 4ba4398aae69..302eea5bcbfa 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -3545,6 +3545,68 @@ bool ScDPCollection::ReloadGroupsInCache(ScDPObject* pDPObj, std::set<ScDPObject
return true;
}
+bool ScDPCollection::GetReferenceGroups(const ScDPObject& rDPObj, const ScDPDimensionSaveData** pGroups) const
+{
+ for (const std::unique_ptr<ScDPObject>& aTable : maTables)
+ {
+ const ScDPObject& rRefObj = *aTable.get();
+
+ if (rDPObj.IsSheetData()){
+ if(!rRefObj.IsSheetData())
+ continue;
+
+ const ScSheetSourceDesc* pDesc = rDPObj.GetSheetDesc();
+ const ScSheetSourceDesc* pRefDesc = rRefObj.GetSheetDesc();
+ if (pDesc == nullptr || pRefDesc == nullptr)
+ continue;
+
+ if (pDesc->HasRangeName())
+ {
+ if (!pRefDesc->HasRangeName())
+ continue;
+
+ if (pDesc->GetRangeName() == pRefDesc->GetRangeName())
+ {
+ *pGroups = rRefObj.GetSaveData()->GetExistingDimensionData();
+ return true;
+ }
+ }
+ else
+ {
+ if (pRefDesc->HasRangeName())
+ continue;
+
+ if (pDesc->GetSourceRange() == pRefDesc->GetSourceRange())
+ {
+ *pGroups = rRefObj.GetSaveData()->GetExistingDimensionData();
+ return true;
+ }
+ }
+ }
+ else if (rDPObj.IsImportData())
+ {
+ if (!rRefObj.IsImportData ())
+ continue;
+
+ const ScImportSourceDesc* pDesc = rDPObj.GetImportSourceDesc();
+ const ScImportSourceDesc* pRefDesc = rRefObj.GetImportSourceDesc();
+ if (pDesc == nullptr || pRefDesc == nullptr)
+ continue;
+
+ if (pDesc->aDBName.equals(pRefDesc->aDBName) &&
+ pDesc->aObject.equals(pRefDesc->aObject) &&
+ pDesc->GetCommandType() == pRefDesc->GetCommandType())
+ {
+ *pGroups = rRefObj.GetSaveData()->GetExistingDimensionData();
+ return true;
+ }
+
+ }
+ }
+ return false;
+}
+
+
void ScDPCollection::DeleteOnTab( SCTAB nTab )
{
maTables.erase( std::remove_if(maTables.begin(), maTables.end(), MatchByTable(nTab)), maTables.end());
@@ -3724,6 +3786,18 @@ bool ScDPCollection::InsertNewTable(ScDPObject* pDPObj)
return true;
}
+bool ScDPCollection::HasTable(ScDPObject* pDPObj) const
+{
+ for (const std::unique_ptr<ScDPObject>& aTable : maTables)
+ {
+ if (aTable.get() == pDPObj)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
ScDPCollection::SheetCaches& ScDPCollection::GetSheetCaches()
{
return maSheetCaches;