[Libreoffice-commits] .: 7 commits - configure.in mdds/0001-fix-linking-error-with-boost-1.50.patch mdds/0001-help-compiler-select-the-right-overload-of-vector-in.patch mdds/mdds_0.6.0-unreachable-code.patch mdds/mdds_0.6.0-unused-parameter.patch mdds/UnpackedTarball_mdds.mk sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Sep 17 21:40:02 PDT 2012
configure.in | 2
mdds/0001-fix-linking-error-with-boost-1.50.patch | 27 -
mdds/0001-help-compiler-select-the-right-overload-of-vector-in.patch | 52 --
mdds/UnpackedTarball_mdds.mk | 4
mdds/mdds_0.6.0-unreachable-code.patch | 28 -
mdds/mdds_0.6.0-unused-parameter.patch | 11
sc/inc/dpcache.hxx | 6
sc/inc/dpcachetable.hxx | 25 -
sc/inc/dpobject.hxx | 4
sc/source/core/data/dpcache.cxx | 21 +
sc/source/core/data/dpcachetable.cxx | 195 +++++-----
sc/source/core/data/dpgroup.cxx | 6
sc/source/core/data/dptabdat.cxx | 6
13 files changed, 160 insertions(+), 227 deletions(-)
New commits:
commit e7649f4ae1751ebcd528ea54f6affa63d34b9b56
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Sep 17 22:44:33 2012 -0400
Updated mdds to 0.6.1.
Change-Id: Ibc0a67b689e5731afdfe2b9af7d991a998ffb389
diff --git a/configure.in b/configure.in
index 563bcdc..75b9175 100644
--- a/configure.in
+++ b/configure.in
@@ -7813,7 +7813,7 @@ if test "$with_system_mdds" = "yes"; then
AC_LANG_POP([C++])
else
AC_MSG_RESULT([internal])
- MDDS_TARBALL=3e89a35f253a4f1c7de68c57d851ef38-mdds_0.6.0.tar.bz2
+ MDDS_TARBALL=9f9e15966b5624834157fe3d748312bc-mdds_0.6.1.tar.bz2
SYSTEM_MDDS=NO
dnl ===================================================================
diff --git a/mdds/0001-fix-linking-error-with-boost-1.50.patch b/mdds/0001-fix-linking-error-with-boost-1.50.patch
deleted file mode 100644
index 59367b5..0000000
--- a/mdds/0001-fix-linking-error-with-boost-1.50.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From 09937e5d6b4b82efbff40da2aa50fb02f2250bb2 Mon Sep 17 00:00:00 2001
-From: David Tardon <dtardon at redhat.com>
-Date: Sat, 28 Jul 2012 14:32:47 +0200
-Subject: [PATCH] fix linking error with boost 1.50
-
----
- include/mdds/mixed_type_matrix_storage.hpp | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/include/mdds/mixed_type_matrix_storage.hpp b/include/mdds/mixed_type_matrix_storage.hpp
-index fa0bf25..bb4e354 100644
---- a/include/mdds/mixed_type_matrix_storage.hpp
-+++ misc/build/mdds_0.6.0/include/mdds/mixed_type_matrix_storage.hpp
-@@ -32,6 +32,10 @@
-
- #include <boost/ptr_container/ptr_vector.hpp>
- #include <boost/ptr_container/ptr_map.hpp>
-+// Boost.Pool indirectly pulls in Boost.System, causing linking error
-+// with Boost 1.50, because some (deprecated) symbols from System are
-+// not found.
-+#define BOOST_SYSTEM_NO_DEPRECATED
- #include <boost/pool/object_pool.hpp>
-
- namespace mdds {
---
-1.7.11.2
-
diff --git a/mdds/0001-help-compiler-select-the-right-overload-of-vector-in.patch b/mdds/0001-help-compiler-select-the-right-overload-of-vector-in.patch
deleted file mode 100644
index fd43c1a..0000000
--- a/mdds/0001-help-compiler-select-the-right-overload-of-vector-in.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-From 900cbea3ec067833b4284584f6dfa5502dc36de8 Mon Sep 17 00:00:00 2001
-From: David Tardon <dtardon at redhat.com>
-Date: Fri, 20 Jul 2012 10:30:38 +0200
-Subject: [PATCH] help compiler select the right overload of vector::insert
-
----
- include/mdds/multi_type_vector_def.inl | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/include/mdds/multi_type_vector_def.inl b/include/mdds/multi_type_vector_def.inl
-index 252a260..fb72070 100644
---- a/include/mdds/multi_type_vector_def.inl
-+++ misc/build/mdds_0.6.0/include/mdds/multi_type_vector_def.inl
-@@ -1148,7 +1148,7 @@ void multi_type_vector<_CellBlockFunc>::insert_empty_impl(size_type row, size_ty
-
- // Insert two new block below the current; one for the empty block being
- // inserted, and one for the lower part of the current non-empty block.
-- m_blocks.insert(m_blocks.begin()+block_index+1, 2, NULL);
-+ m_blocks.insert(m_blocks.begin()+block_index+1, 2u, NULL);
-
- m_blocks[block_index+1] = new block(length);
- m_blocks[block_index+2] = new block(size_blk_next);
-@@ -1302,7 +1302,7 @@ void multi_type_vector<_CellBlockFunc>::insert_cells_to_middle(
- // Insert two new blocks.
- size_type n1 = row - start_row;
- size_type n2 = blk->m_size - n1;
-- m_blocks.insert(m_blocks.begin()+block_index+1, 2, NULL);
-+ m_blocks.insert(m_blocks.begin()+block_index+1, 2u, NULL);
- blk->m_size = n1;
-
- m_blocks[block_index+1] = new block(length);
-@@ -1467,7 +1467,7 @@ void multi_type_vector<_CellBlockFunc>::set_cells_to_single_block(
- assert(start_row_in_block < start_row && end_row < end_row_in_block);
-
- // Insert two new blocks below the current one.
-- m_blocks.insert(m_blocks.begin()+block_index+1, 2, NULL);
-+ m_blocks.insert(m_blocks.begin()+block_index+1, 2u, NULL);
-
- // first new block is for the data array being inserted.
- size_type new_size = end_row - start_row + 1;
-@@ -1985,7 +1985,7 @@ void multi_type_vector<_CellBlockFunc>::set_empty_in_single_block(
-
- // First, insert two new blocks at position past the current block.
- size_type lower_block_size = end_row_in_block - end_row;
-- m_blocks.insert(m_blocks.begin()+block_index+1, 2, NULL);
-+ m_blocks.insert(m_blocks.begin()+block_index+1, 2u, NULL);
- m_blocks[block_index+1] = new block(empty_block_size); // empty block.
- m_blocks[block_index+2] = new block(lower_block_size);
-
---
-1.7.10.2
-
diff --git a/mdds/UnpackedTarball_mdds.mk b/mdds/UnpackedTarball_mdds.mk
index c837a52..3394388 100644
--- a/mdds/UnpackedTarball_mdds.mk
+++ b/mdds/UnpackedTarball_mdds.mk
@@ -13,10 +13,6 @@ $(eval $(call gb_UnpackedTarball_set_tarball,mdds,$(MDDS_TARBALL)))
$(eval $(call gb_UnpackedTarball_add_patches,mdds,\
mdds/mdds_0.6.0.patch \
- mdds/0001-help-compiler-select-the-right-overload-of-vector-in.patch \
- mdds/mdds_0.6.0-unused-parameter.patch \
- mdds/mdds_0.6.0-unreachable-code.patch \
- mdds/0001-fix-linking-error-with-boost-1.50.patch \
mdds/0001-Workaround-for-gcc-bug.patch \
))
diff --git a/mdds/mdds_0.6.0-unreachable-code.patch b/mdds/mdds_0.6.0-unreachable-code.patch
deleted file mode 100644
index 6a9d833..0000000
--- a/mdds/mdds_0.6.0-unreachable-code.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- misc/mdds_0.6.0/include/mdds/mixed_type_matrix_def.inl 2012-07-23 16:20:34.101608964 +0200
-+++ misc/build/mdds_0.6.0/include/mdds/mixed_type_matrix_def.inl 2012-07-23 16:19:13.022858991 +0200
-@@ -44,7 +44,6 @@
- default:
- throw matrix_error("unknown density type");
- }
-- return NULL;
- }
-
- template<typename _String, typename _Flag>
---- misc/mdds_0.6.0/include/mdds/multi_type_vector_trait.hpp 2012-07-19 05:09:49.000000000 +0200
-+++ misc/build/mdds_0.6.0/include/mdds/multi_type_vector_trait.hpp 2012-07-24 09:22:04.396955159 +0200
-@@ -95,7 +95,6 @@
- default:
- throw general_error("create_new_block: failed to create a new block of unknown type.");
- }
-- return NULL;
- }
-
- base_element_block* element_block_func_base::clone_block(const base_element_block& block)
-@@ -123,7 +122,6 @@
- default:
- throw general_error("clone_block: failed to clone a block of unknown type.");
- }
-- return NULL;
- }
-
- void element_block_func_base::delete_block(base_element_block* p)
diff --git a/mdds/mdds_0.6.0-unused-parameter.patch b/mdds/mdds_0.6.0-unused-parameter.patch
deleted file mode 100644
index 6abc69e..0000000
--- a/mdds/mdds_0.6.0-unused-parameter.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- misc/mdds_0.6.0/include/mdds/multi_type_vector_types.hpp 2012-07-19 05:09:49.000000000 +0200
-+++ misc/build/mdds_0.6.0/include/mdds/multi_type_vector_types.hpp 2012-07-23 09:31:51.636388620 +0200
-@@ -302,7 +302,7 @@
- noncopyable_element_block(size_t n, const _Data& val) : base_type(n, val) {}
-
- public:
-- static _Self* clone_block(const base_element_block& blk)
-+ static _Self* clone_block(const base_element_block&)
- {
- throw element_block_error("attempted to clone a noncopyable element block.");
- }
commit 2ecaf778a7a6950082589e74696c3b33753b28ad
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Sep 17 21:32:44 2012 -0400
Use mdds::flat_segment_tree to store row flags.
Much less memory footprint & better scalability.
Change-Id: Idef9afe5fa6e247e59fb949d4c9955fab4f669dc
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 5f29711..c0d0625 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -38,7 +38,8 @@
#include <boost/unordered_set.hpp>
#include <boost/shared_ptr.hpp>
-class Date;
+#include <mdds/flat_segment_tree.hpp>
+
class ScDPItemData;
class ScDPCache;
class ScDocument;
@@ -132,7 +133,7 @@ public:
/** Check whether a specified row is active or not. When a row is active,
it is used in calculation of the results data. A row becomes inactive
when it is filtered out by page field. */
- bool isRowActive(sal_Int32 nRow) const;
+ bool isRowActive(sal_Int32 nRow, sal_Int32* pLastRow = NULL) const;
/** Set filter on/off flag to each row to control visibility. The caller
must ensure that the table is filled before calling this function. */
@@ -175,11 +176,15 @@ private:
bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const;
private:
+ typedef mdds::flat_segment_tree<SCROW, bool> RowFlagType;
+
/** unique field entires for each field (column). */
::std::vector< ::std::vector<SCROW> > maFieldEntries;
- /** Row flags. The first row below the header row has the index of 0. */
- ::std::vector<RowFlag> maRowFlags;
+ /** Rows visible by standard filter query. */
+ RowFlagType maShowByFilter;
+ /** Rows visible by page dimension filtering. */
+ RowFlagType maShowByPage;
const ScDPCache* mpCache;
};
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 7c5a41f..11ac85f 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -125,7 +125,7 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
ScDPCacheTable::ScDPCacheTable(const ScDPCache* pCache) :
- mpCache(pCache)
+ maShowByFilter(0, MAXROW+1, false), maShowByPage(0, MAXROW+1, true), mpCache(pCache)
{
}
@@ -152,29 +152,26 @@ void ScDPCacheTable::fillTable(
if (nRowCount <= 0 || nColCount <= 0)
return;
- maRowFlags.clear();
- maRowFlags.reserve(nRowCount);
+ maShowByFilter.clear();
+ maShowByPage.clear();
// Process the non-empty data rows.
for (SCROW nRow = 0; nRow < nDataSize; ++nRow)
{
- maRowFlags.push_back(RowFlag());
if (!getCache()->ValidQuery(nRow, rQuery))
continue;
if (bIgnoreEmptyRows && getCache()->IsRowEmpty(nRow))
continue;
- maRowFlags.back().mbShowByFilter = true;
+ maShowByFilter.insert_back(nRow, nRow+1, true);
}
// Process the trailing empty rows.
- for (SCROW nRow = nDataSize; nRow < nRowCount; ++nRow)
- {
- maRowFlags.push_back(RowFlag());
- if (!bIgnoreEmptyRows)
- maRowFlags.back().mbShowByFilter = true;
- }
+ if (!bIgnoreEmptyRows)
+ maShowByFilter.insert_back(nDataSize, nRowCount, true);
+
+ maShowByFilter.build_tree();
// Initialize field entries container.
maFieldEntries.clear();
@@ -189,11 +186,25 @@ void ScDPCacheTable::fillTable(
continue;
std::vector<SCROW> aAdded(nMemCount, -1);
-
+ bool bShow = false;
+ SCROW nEndSegment = -1;
for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
{
- if (!maRowFlags[nRow].mbShowByFilter)
+ if (nRow > nEndSegment)
+ {
+ if (!maShowByFilter.search_tree(nRow, bShow, NULL, &nEndSegment))
+ {
+ OSL_FAIL("Tree search failed!");
+ continue;
+ }
+ --nEndSegment; // End position is not inclusive. Move back one.
+ }
+
+ if (!bShow)
+ {
+ nRow = nEndSegment;
continue;
+ }
SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
SCROW nOrder = getOrder(nCol, nIndex);
@@ -214,63 +225,66 @@ void ScDPCacheTable::fillTable()
if (nRowCount <= 0 || nColCount <= 0)
return;
- maRowFlags.clear();
- maRowFlags.reserve(nRowCount);
-
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
- {
- maRowFlags.push_back(RowFlag());
- maRowFlags.back().mbShowByFilter = true;
- }
-
- // Initialize field entries container.
- maFieldEntries.clear();
- maFieldEntries.reserve(nColCount);
-
- // Data rows
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- maFieldEntries.push_back( vector<SCROW>() );
- SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
- if (!nMemCount)
- continue;
-
- std::vector<SCROW> aAdded(nMemCount, -1);
-
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
- {
- SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, false);
- SCROW nOrder = getOrder(nCol, nIndex);
- aAdded[nOrder] = nIndex;
- }
- for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
- {
- if (aAdded[nRow] != -1)
- maFieldEntries.back().push_back(aAdded[nRow]);
- }
- }
+ maShowByFilter.clear();
+ maShowByPage.clear();
+ maShowByFilter.insert_front(0, nRowCount, true);
+
+ // Initialize field entries container.
+ maFieldEntries.clear();
+ maFieldEntries.reserve(nColCount);
+
+ // Data rows
+ for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
+ {
+ maFieldEntries.push_back( vector<SCROW>() );
+ SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
+ if (!nMemCount)
+ continue;
+
+ std::vector<SCROW> aAdded(nMemCount, -1);
+
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
+ {
+ SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, false);
+ SCROW nOrder = getOrder(nCol, nIndex);
+ aAdded[nOrder] = nIndex;
+ }
+ for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
+ {
+ if (aAdded[nRow] != -1)
+ maFieldEntries.back().push_back(aAdded[nRow]);
+ }
+ }
}
-bool ScDPCacheTable::isRowActive(sal_Int32 nRow) const
+bool ScDPCacheTable::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
{
- if (nRow < 0 || static_cast<size_t>(nRow) >= maRowFlags.size())
- // row index out of bound
- return false;
+ bool bFilter = false, bPage = true;
+ SCROW nLastRowFilter = MAXROW, nLastRowPage = MAXROW;
+ maShowByFilter.search_tree(nRow, bFilter, NULL, &nLastRowFilter);
+ maShowByPage.search_tree(nRow, bPage, NULL, &nLastRowPage);
+ if (pLastRow)
+ {
+ // Return the last row of current segment.
+ *pLastRow = nLastRowFilter < nLastRowPage ? nLastRowFilter : nLastRowPage;
+ *pLastRow -= 1; // End position is not inclusive. Move back one.
+ }
- return maRowFlags[nRow].isActive();
+ return bFilter && bPage;
}
void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
{
- sal_Int32 nRowSize = getRowSize();
- if (nRowSize != static_cast<sal_Int32>(maRowFlags.size()))
+ SCROW nRowSize = getRowSize();
+
+ maShowByPage.clear();
+ for (SCROW nRow = 0; nRow < nRowSize; ++nRow)
{
- // sizes of the two tables differ!
- return;
+ bool bShow = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
+ maShowByPage.insert_back(nRow, nRow+1, bShow);
}
- for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
- maRowFlags[nRow].mbShowByPage = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
+ maShowByPage.build_tree();
}
const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
@@ -340,12 +354,15 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
}
tableData.push_back(headerRow);
-
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
{
- if (!maRowFlags[nRow].isActive())
+ sal_Int32 nLastRow;
+ if (!isRowActive(nRow, &nLastRow))
+ {
// This row is filtered out.
+ nRow = nLastRow;
continue;
+ }
if (!isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims))
continue;
@@ -385,7 +402,8 @@ SCROW ScDPCacheTable::getOrder(long nDim, SCROW nIndex) const
void ScDPCacheTable::clear()
{
maFieldEntries.clear();
- maRowFlags.clear();
+ maShowByFilter.clear();
+ maShowByPage.clear();
}
bool ScDPCacheTable::empty() const
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 232f7fc..aba2785 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -762,8 +762,12 @@ void ScDPGroupTableData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
sal_Int32 nRowSize = rCacheTable.getRowSize();
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
{
- if (!rCacheTable.isRowActive(nRow))
+ sal_Int32 nLastRow;
+ if (!rCacheTable.isRowActive(nRow, &nLastRow))
+ {
+ nRow = nLastRow;
continue;
+ }
CalcRowData aData;
FillRowDataFromCacheTable(nRow, rCacheTable, rInfo, aData);
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index 39f1b4f..f150d8d 100644
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -221,8 +221,12 @@ void ScDPTableData::CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable,
sal_Int32 nRowSize = rCacheTable.getRowSize();
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
{
- if (!rCacheTable.isRowActive(nRow))
+ sal_Int32 nLastRow;
+ if (!rCacheTable.isRowActive(nRow, &nLastRow))
+ {
+ nRow = nLastRow;
continue;
+ }
CalcRowData aData;
FillRowDataFromCacheTable(nRow, rCacheTable, rInfo, aData);
commit 2a2e5986555a3d2325f9f6ad1702ece305ce8df0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Sep 17 16:09:24 2012 -0400
Forward declaration cleanup in header files.
Change-Id: I2bbfa48e49bb8c91c6d3e2bb485ded9e8e67f13b
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index d834910..5f29711 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -37,16 +37,6 @@
#include <vector>
#include <boost/unordered_set.hpp>
#include <boost/shared_ptr.hpp>
-#include <com/sun/star/uno/Reference.hxx>
-
-namespace com { namespace sun { namespace star {
- namespace sdbc {
- class XRowSet;
- }
- namespace sheet {
- struct DataPilotFieldFilter;
- }
-}}}
class Date;
class ScDPItemData;
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index cba66cc..fb40c5e 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -53,6 +53,10 @@ namespace com { namespace sun { namespace star {
class XIndexAccess;
}
+ namespace sdbc {
+ class XRowSet;
+ }
+
namespace sheet {
struct DataPilotTablePositionData;
struct DataPilotTableHeaderData;
commit d3469ce86e954d6b9c15d3442791121c8c8d015e
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Sep 17 15:34:06 2012 -0400
Do the same for the no-parameter variant of fillTable().
Change-Id: I698e70e7713697e2951c3e6ead4b4d2198d8a6cf
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 08bc776..7c5a41f 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -209,14 +209,19 @@ void ScDPCacheTable::fillTable(
void ScDPCacheTable::fillTable()
{
- const SCROW nRowCount = getRowSize();
- const SCCOL nColCount = (SCCOL) getColSize();
- if ( nRowCount <= 0 || nColCount <= 0)
+ SCROW nRowCount = getRowSize();
+ SCCOL nColCount = getColSize();
+ if (nRowCount <= 0 || nColCount <= 0)
return;
maRowFlags.clear();
maRowFlags.reserve(nRowCount);
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
+ {
+ maRowFlags.push_back(RowFlag());
+ maRowFlags.back().mbShowByFilter = true;
+ }
// Initialize field entries container.
maFieldEntries.clear();
@@ -227,28 +232,21 @@ void ScDPCacheTable::fillTable()
{
maFieldEntries.push_back( vector<SCROW>() );
SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
- if ( nMemCount )
- {
- std::vector< SCROW > pAdded( nMemCount, -1 );
-
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
- {
- SCROW nIndex = getCache()->GetItemDataId( nCol, nRow, false );
- SCROW nOrder = getOrder( nCol, nIndex );
+ if (!nMemCount)
+ continue;
- if ( nCol == 0 )
- {
- maRowFlags.push_back(RowFlag());
- maRowFlags.back().mbShowByFilter = true;
- }
+ std::vector<SCROW> aAdded(nMemCount, -1);
- pAdded[nOrder] = nIndex;
- }
- for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
- {
- if ( pAdded[nRow] != -1 )
- maFieldEntries.back().push_back( pAdded[nRow] );
- }
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
+ {
+ SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, false);
+ SCROW nOrder = getOrder(nCol, nIndex);
+ aAdded[nOrder] = nIndex;
+ }
+ for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
+ {
+ if (aAdded[nRow] != -1)
+ maFieldEntries.back().push_back(aAdded[nRow]);
}
}
}
commit 1b9a8efb824b5fe6113a14279ea5a4c8070d260f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Mon Sep 17 15:10:27 2012 -0400
Refactor fillTable (3-param variant) to skip trailing empty rows.
This speeds up the process considerably if the size of the trailing
empty rows is huge.
Change-Id: Ide91174b09472a20309b4f6e18d658cb8fbefa42
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 75234af..5a5ec57 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -661,14 +661,14 @@ void ScDPCache::PostInit()
typedef mdds::flat_segment_tree<SCROW, bool>::const_reverse_iterator itr_type;
itr_type it = maEmptyRows.rbegin(), itEnd = maEmptyRows.rend();
OSL_ENSURE(it != itEnd, "corrupt flat_segment_tree instance!");
- mnDataSize = maFields[0].maItems.size();
+ mnDataSize = maFields[0].maData.size();
++it; // Skip the first position.
OSL_ENSURE(it != itEnd, "buggy version of flat_segment_tree is used.");
if (it->second)
{
SCROW nLastNonEmpty = it->first - 1;
- if (nLastNonEmpty < mnDataSize)
- mnDataSize = nLastNonEmpty;
+ if (nLastNonEmpty+1 < mnDataSize)
+ mnDataSize = nLastNonEmpty+1;
}
}
@@ -770,6 +770,7 @@ SCROW ScDPCache::GetRowCount() const
SCROW ScDPCache::GetDataSize() const
{
+ OSL_ENSURE(mnDataSize <= GetRowCount(), "Data size should never be larger than the row count.");
return mnDataSize >= 0 ? mnDataSize : 0;
}
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index f1a6417..08bc776 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -70,7 +70,7 @@ bool ScDPCacheTable::RowFlag::isActive() const
}
ScDPCacheTable::RowFlag::RowFlag() :
- mbShowByFilter(true),
+ mbShowByFilter(false),
mbShowByPage(true)
{
}
@@ -146,20 +146,41 @@ sal_Int32 ScDPCacheTable::getColSize() const
void ScDPCacheTable::fillTable(
const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
{
- const SCROW nRowCount = getRowSize();
+ SCROW nRowCount = getRowSize();
SCROW nDataSize = mpCache->GetDataSize();
- const SCCOL nColCount = (SCCOL) getColSize();
- if ( nRowCount <= 0 || nColCount <= 0)
+ SCCOL nColCount = getColSize();
+ if (nRowCount <= 0 || nColCount <= 0)
return;
maRowFlags.clear();
maRowFlags.reserve(nRowCount);
+ // Process the non-empty data rows.
+ for (SCROW nRow = 0; nRow < nDataSize; ++nRow)
+ {
+ maRowFlags.push_back(RowFlag());
+ if (!getCache()->ValidQuery(nRow, rQuery))
+ continue;
+
+ if (bIgnoreEmptyRows && getCache()->IsRowEmpty(nRow))
+ continue;
+
+ maRowFlags.back().mbShowByFilter = true;
+ }
+
+ // Process the trailing empty rows.
+ for (SCROW nRow = nDataSize; nRow < nRowCount; ++nRow)
+ {
+ maRowFlags.push_back(RowFlag());
+ if (!bIgnoreEmptyRows)
+ maRowFlags.back().mbShowByFilter = true;
+ }
+
// Initialize field entries container.
maFieldEntries.clear();
maFieldEntries.reserve(nColCount);
- // Data rows
+ // Build unique field entries.
for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
{
maFieldEntries.push_back( vector<SCROW>() );
@@ -171,24 +192,11 @@ void ScDPCacheTable::fillTable(
for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
{
- SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
- SCROW nOrder = getOrder(nCol, nIndex);
-
- if (nCol == 0)
- {
- maRowFlags.push_back(RowFlag());
- maRowFlags.back().mbShowByFilter = false;
- }
-
- if (!getCache()->ValidQuery(nRow, rQuery))
+ if (!maRowFlags[nRow].mbShowByFilter)
continue;
- if (bIgnoreEmptyRows && getCache()->IsRowEmpty(nRow))
- continue;
-
- if (nCol == 0)
- maRowFlags.back().mbShowByFilter = true;
-
+ SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
+ SCROW nOrder = getOrder(nCol, nIndex);
aAdded[nOrder] = nIndex;
}
for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
commit 1e50a93d228fbd41dc1d75aec48df088302900f8
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Sep 14 23:31:42 2012 -0400
Determine data size in cache that doesn't include trailing empty rows.
Change-Id: I47632b7ae93f4e68c4512fc30f4e4fe18e1c5f4d
diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 7f996e0..b69e3c2 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -130,6 +130,7 @@ private:
LabelsType maLabelNames; // Stores dimension names.
mdds::flat_segment_tree<SCROW, bool> maEmptyRows;
+ SCROW mnDataSize;
bool mbDisposing;
@@ -159,8 +160,9 @@ public:
bool InitFromDoc(ScDocument* pDoc, const ScRange& rRange);
bool InitFromDataBase(DBConnector& rDB);
- SCROW GetRowCount() const;
- SCROW GetItemDataId( sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty ) const;
+ SCROW GetRowCount() const;
+ SCROW GetDataSize() const;
+ SCROW GetItemDataId( sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty ) const;
rtl::OUString GetDimensionName(LabelsType::size_type nDim) const;
bool IsRowEmpty(SCROW nRow) const;
bool ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam) const;
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index c94b542..75234af 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -65,6 +65,7 @@ ScDPCache::ScDPCache(ScDocument* pDoc) :
mpDoc( pDoc ),
mnColumnCount ( 0 ),
maEmptyRows(0, MAXROW, true),
+ mnDataSize(-1),
mbDisposing(false)
{
}
@@ -654,7 +655,21 @@ public:
void ScDPCache::PostInit()
{
+ OSL_ENSURE(!maFields.empty(), "Cache not initialized!");
+
maEmptyRows.build_tree();
+ typedef mdds::flat_segment_tree<SCROW, bool>::const_reverse_iterator itr_type;
+ itr_type it = maEmptyRows.rbegin(), itEnd = maEmptyRows.rend();
+ OSL_ENSURE(it != itEnd, "corrupt flat_segment_tree instance!");
+ mnDataSize = maFields[0].maItems.size();
+ ++it; // Skip the first position.
+ OSL_ENSURE(it != itEnd, "buggy version of flat_segment_tree is used.");
+ if (it->second)
+ {
+ SCROW nLastNonEmpty = it->first - 1;
+ if (nLastNonEmpty < mnDataSize)
+ mnDataSize = nLastNonEmpty;
+ }
}
void ScDPCache::Clear()
@@ -753,6 +768,11 @@ SCROW ScDPCache::GetRowCount() const
return maFields[0].maData.size();
}
+SCROW ScDPCache::GetDataSize() const
+{
+ return mnDataSize >= 0 ? mnDataSize : 0;
+}
+
const ScDPCache::ItemsType& ScDPCache::GetDimMemberValues(SCCOL nDim) const
{
OSL_ENSURE( nDim>=0 && nDim < mnColumnCount ," nDim < mnColumnCount ");
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 6afb9c5..f1a6417 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -147,6 +147,7 @@ void ScDPCacheTable::fillTable(
const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
{
const SCROW nRowCount = getRowSize();
+ SCROW nDataSize = mpCache->GetDataSize();
const SCCOL nColCount = (SCCOL) getColSize();
if ( nRowCount <= 0 || nColCount <= 0)
return;
commit 123206d00227c102a4bee0444acdeb34bcb92802
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Sep 14 23:17:23 2012 -0400
Reduce indentation by early bailout.
Change-Id: I8cbf348289acb98d30d8e295f296c43655b00a08
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index dc7a63a..6afb9c5 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -163,37 +163,37 @@ void ScDPCacheTable::fillTable(
{
maFieldEntries.push_back( vector<SCROW>() );
SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
- if ( nMemCount )
+ if (!nMemCount)
+ continue;
+
+ std::vector<SCROW> aAdded(nMemCount, -1);
+
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
{
- std::vector<SCROW> aAdded( nMemCount, -1 );
+ SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
+ SCROW nOrder = getOrder(nCol, nIndex);
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
+ if (nCol == 0)
{
- SCROW nIndex = getCache()->GetItemDataId( nCol, nRow, bRepeatIfEmpty );
- SCROW nOrder = getOrder( nCol, nIndex );
-
- if ( nCol == 0 )
- {
- maRowFlags.push_back(RowFlag());
- maRowFlags.back().mbShowByFilter = false;
- }
+ maRowFlags.push_back(RowFlag());
+ maRowFlags.back().mbShowByFilter = false;
+ }
- if (!getCache()->ValidQuery(nRow, rQuery))
- continue;
+ if (!getCache()->ValidQuery(nRow, rQuery))
+ continue;
- if ( bIgnoreEmptyRows && getCache()->IsRowEmpty( nRow ) )
- continue;
+ if (bIgnoreEmptyRows && getCache()->IsRowEmpty(nRow))
+ continue;
- if ( nCol == 0 )
- maRowFlags.back().mbShowByFilter = true;
+ if (nCol == 0)
+ maRowFlags.back().mbShowByFilter = true;
- aAdded[nOrder] = nIndex;
- }
- for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
- {
- if ( aAdded[nRow] != -1 )
- maFieldEntries.back().push_back( aAdded[nRow] );
- }
+ aAdded[nOrder] = nIndex;
+ }
+ for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
+ {
+ if (aAdded[nRow] != -1)
+ maFieldEntries.back().push_back(aAdded[nRow]);
}
}
}
More information about the Libreoffice-commits
mailing list