tonellotto / jdbm2

Automatically exported from code.google.com/p/jdbm2
0 stars 0 forks source link

Bug in getFirstLargerThan in FreePhysicalRowIdPage.java #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Bug in getFirstLargerThan in FreePhysicalRowIdPage.java

The algorithm in getFirstLargerThan(int size) (FreePhysicalRowIdPage.java) has 
a bug:

If a slot was found which points to a record whose size is far greater than the 
searched size (i.e. waste > wasteMargin) then the wrong information is stored 
in bestSlotSize.

Line 185 should say:
bestSlotSize = theSize

and not:
bestSlotSize = size

Also the condition in 179 should be:
(bestSlotSize >= theSize)

and not:
(bestSlotSize >= size)

The current algorithm basically ignores wasteMargin2 and returns the first 
record which fits regardless of the wasted space.

To make the algorithm a bit better I suggest to store the bestSlotWaste rather 
than the bestSlotSize

Original issue reported on code.google.com by matth...@ladkau.de on 19 Dec 2011 at 12:47

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for this bug report. 
I submitted fix and made new release (2.3). It was also submited to 3.0 branch. 

Original comment by kja...@gmail.com on 19 Dec 2011 at 10:24