ASF Bugzilla – Attachment 26362 Details for
Bug 47405
RowRecordsAggregate.getStartRowNumberForBlock / getEndRowNumberForBlock not performing with high row count
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
A patch to speed up serialization
RowRecordsAggregate-speedup.patch (text/plain), 2.99 KB, created by
Per Lewau
on 2010-12-01 08:04:01 UTC
(
hide
)
Description:
A patch to speed up serialization
Filename:
MIME Type:
Creator:
Per Lewau
Created:
2010-12-01 08:04:01 UTC
Size:
2.99 KB
patch
obsolete
>--- RowRecordsAggregate.java 2010-12-01 10:43:10.817105500 +0100 >+++ RowRecordsAggregate.java 2010-12-01 10:52:39.717185000 +0100 >@@ -54,6 +54,9 @@ > private final List<Record> _unknownRecords; > private final SharedValueManager _sharedValueManager; > >+ // Cache values to speed up serialization >+ private RowRecord[] _rowRecordValues = null; >+ > /** Creates a new instance of ValueRecordsAggregate */ > public RowRecordsAggregate() { > this(SharedValueManager.createEmpty()); >@@ -121,6 +124,8 @@ > public void insertRow(RowRecord row) { > // Integer integer = Integer.valueOf(row.getRowNumber()); > _rowRecords.put(Integer.valueOf(row.getRowNumber()), row); >+ // Clear the cached values >+ _rowRecordValues = null; > if ((row.getRowNumber() < _firstrow) || (_firstrow == -1)) { > _firstrow = row.getRowNumber(); > } >@@ -141,6 +146,9 @@ > _rowRecords.put(key, rr); > throw new RuntimeException("Attempt to remove row that does not belong to this sheet"); > } >+ >+ // Clear the cached values >+ _rowRecordValues = null; > } > > public RowRecord getRow(int rowIndex) { >@@ -193,22 +201,15 @@ > > /** Returns the physical row number of the first row in a block*/ > private int getStartRowNumberForBlock(int block) { >- //Given that we basically iterate through the rows in order, >- // TODO - For a performance improvement, it would be better to return an instance of >- //an iterator and use that instance throughout, rather than recreating one and >- //having to move it to the right position. > int startIndex = block * DBCellRecord.BLOCK_SIZE; >- Iterator<RowRecord> rowIter = _rowRecords.values().iterator(); >- RowRecord row = null; >- //Position the iterator at the start of the block >- for (int i=0; i<=startIndex;i++) { >- row = rowIter.next(); >- } >- if (row == null) { >+ if(_rowRecordValues == null) >+ _rowRecordValues = _rowRecords.values().toArray(new RowRecord[0]); >+ >+ try { >+ return _rowRecordValues[startIndex].getRowNumber(); >+ } catch(ArrayIndexOutOfBoundsException e) { > throw new RuntimeException("Did not find start row for block " + block); > } >- >- return row.getRowNumber(); > } > > /** Returns the physical row number of the end row in a block*/ >@@ -217,15 +218,14 @@ > if (endIndex >= _rowRecords.size()) > endIndex = _rowRecords.size()-1; > >- Iterator<RowRecord> rowIter = _rowRecords.values().iterator(); >- RowRecord row = null; >- for (int i=0; i<=endIndex;i++) { >- row = rowIter.next(); >- } >- if (row == null) { >- throw new RuntimeException("Did not find start row for block " + block); >+ if(_rowRecordValues == null) >+ _rowRecordValues = _rowRecords.values().toArray(new RowRecord[0]); >+ >+ try { >+ return _rowRecordValues[endIndex].getRowNumber(); >+ } catch(ArrayIndexOutOfBoundsException e) { >+ throw new RuntimeException("Did not find end row for block " + block); > } >- return row.getRowNumber(); > } > > private int visitRowRecordsForBlock(int blockIndex, RecordVisitor rv) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47405
: 26362