Kaydet (Commit) c31905c8 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Initial cut on matrix backend swapping. Still lots of things to fix.

Change-Id: I5262899171029772f53dccc9aea666c4b83aef36
üst e5e5c0c0
...@@ -169,12 +169,16 @@ public: ...@@ -169,12 +169,16 @@ public:
/// The maximum number of elements a matrix may have at runtime. /// The maximum number of elements a matrix may have at runtime.
inline static size_t GetElementsMax() inline static size_t GetElementsMax()
{ {
// TODO: Fix me.
return 0x08000000;
#if 0
// Roughly 125MB in total, divided by 8+1 per element => 14M elements. // Roughly 125MB in total, divided by 8+1 per element => 14M elements.
const size_t nMemMax = 0x08000000 / (sizeof(ScMatrixValue) + sizeof(ScMatValType)); const size_t nMemMax = 0x08000000 / (sizeof(ScMatrixValue) + sizeof(ScMatValType));
// With MAXROWCOUNT==65536 and 128 columns => 8M elements ~72MB. // With MAXROWCOUNT==65536 and 128 columns => 8M elements ~72MB.
const size_t nArbitraryLimit = (size_t)MAXROWCOUNT * 128; const size_t nArbitraryLimit = (size_t)MAXROWCOUNT * 128;
// Stuffed with a million rows would limit this to 14 columns. // Stuffed with a million rows would limit this to 14 columns.
return nMemMax < nArbitraryLimit ? nMemMax : nArbitraryLimit; return nMemMax < nArbitraryLimit ? nMemMax : nArbitraryLimit;
#endif
} }
/// Value or boolean. /// Value or boolean.
...@@ -215,11 +219,11 @@ public: ...@@ -215,11 +219,11 @@ public:
return (nType & SC_MATVAL_NONVALUE) == SC_MATVAL_EMPTYPATH; return (nType & SC_MATVAL_NONVALUE) == SC_MATVAL_EMPTYPATH;
} }
ScMatrix( SCSIZE nC, SCSIZE nR, DensityType eType = FILLED_ZERO); ScMatrix(SCSIZE nC, SCSIZE nR);
ScMatrix(SCSIZE nC, SCSIZE nR, double fInitVal);
/** Clone the matrix. */ /** Clone the matrix. */
ScMatrix* Clone() const; ScMatrix* Clone() const;
ScMatrix* Clone( DensityType eType) const;
/** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise
return _this_ matrix, to be assigned to a ScMatrixRef. */ return _this_ matrix, to be assigned to a ScMatrixRef. */
...@@ -236,7 +240,7 @@ public: ...@@ -236,7 +240,7 @@ public:
/** Clone the matrix and extend it to the new size. nNewCols and nNewRows /** Clone the matrix and extend it to the new size. nNewCols and nNewRows
MUST be at least of the size of the original matrix. */ MUST be at least of the size of the original matrix. */
ScMatrix* CloneAndExtend( SCSIZE nNewCols, SCSIZE nNewRows, DensityType eType) const; ScMatrix* CloneAndExtend(SCSIZE nNewCols, SCSIZE nNewRows) const;
inline void IncRef() const inline void IncRef() const
{ {
...@@ -249,7 +253,6 @@ public: ...@@ -249,7 +253,6 @@ public:
delete this; delete this;
} }
DensityType GetDensityType() const;
void SetErrorInterpreter( ScInterpreter* p); void SetErrorInterpreter( ScInterpreter* p);
void GetDimensions( SCSIZE& rC, SCSIZE& rR) const; void GetDimensions( SCSIZE& rC, SCSIZE& rR) const;
SCSIZE GetElementCount() const; SCSIZE GetElementCount() const;
...@@ -303,9 +306,9 @@ public: ...@@ -303,9 +306,9 @@ public:
double GetDouble( SCSIZE nIndex) const; double GetDouble( SCSIZE nIndex) const;
/// @return empty string if empty or empty path, else string content. /// @return empty string if empty or empty path, else string content.
const ::rtl::OUString& GetString( SCSIZE nC, SCSIZE nR) const; rtl::OUString GetString( SCSIZE nC, SCSIZE nR) const;
/// @return empty string if empty or empty path, else string content. /// @return empty string if empty or empty path, else string content.
const ::rtl::OUString& GetString( SCSIZE nIndex) const; rtl::OUString GetString( SCSIZE nIndex) const;
/** @returns the matrix element's string if one is present, otherwise the /** @returns the matrix element's string if one is present, otherwise the
numerical value formatted as string, or in case of an error the error numerical value formatted as string, or in case of an error the error
......
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
{ {
if ( nNewCols > nResMatCols || nNewRows > nResMatRows ) if ( nNewCols > nResMatCols || nNewRows > nResMatRows )
{ {
pMat = pMat->CloneAndExtend( nNewCols, nNewRows, pMat->GetDensityType() ); pMat = pMat->CloneAndExtend(nNewCols, nNewRows);
if ( nResMatCols < nNewCols ) if ( nResMatCols < nNewCols )
{ {
pMat->FillDouble( CreateDoubleError( pMat->FillDouble( CreateDoubleError(
......
...@@ -4621,7 +4621,7 @@ public: ...@@ -4621,7 +4621,7 @@ public:
return mbColVec ? mrMat.GetDouble(0, i) : mrMat.GetDouble(i, 0); return mbColVec ? mrMat.GetDouble(0, i) : mrMat.GetDouble(i, 0);
} }
const rtl::OUString& GetString(SCSIZE i) const rtl::OUString GetString(SCSIZE i) const
{ {
return mbColVec ? mrMat.GetString(0, i) : mrMat.GetString(i, 0); return mbColVec ? mrMat.GetString(0, i) : mrMat.GetString(i, 0);
} }
......
...@@ -626,8 +626,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData( ...@@ -626,8 +626,7 @@ ScExternalRefCache::TokenArrayRef ScExternalRefCache::getCellRangeData(
} }
ScMatrixRef xMat = new ScMatrix( ScMatrixRef xMat = new ScMatrix(
static_cast<SCSIZE>(nDataCol2-nDataCol1+1), static_cast<SCSIZE>(nDataCol2-nDataCol1+1), static_cast<SCSIZE>(nDataRow2-nDataRow1+1));
static_cast<SCSIZE>(nDataRow2-nDataRow1+1), ScMatrix::SPARSE_EMPTY);
// Only fill non-empty cells, for better performance. // Only fill non-empty cells, for better performance.
vector<SCROW> aRows; vector<SCROW> aRows;
...@@ -1383,8 +1382,7 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange& ...@@ -1383,8 +1382,7 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0)); pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
ScMatrixRef xMat = new ScMatrix( ScMatrixRef xMat = new ScMatrix(
static_cast<SCSIZE>(nCol2-nCol1+1), static_cast<SCSIZE>(nCol2-nCol1+1), static_cast<SCSIZE>(nRow2-nRow1+1));
static_cast<SCSIZE>(nRow2-nRow1+1), ScMatrix::SPARSE_EMPTY);
for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol) for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment