lordcheng10 edited a comment on pull request #3061:
URL: https://github.com/apache/bookkeeper/pull/3061#issuecomment-1042894104
> What about making this new behaviour configurable?
Like adding a new boolean parameter 'autoShrink'?
The default is false, to keep previous behaviour.
My concern is that this implementation may help in your case but this is a
utility class possibly used by many other applications
@eolivelli @merlimat I agree to add autoShrink, but when we configure
autoShrink=false, the following situation cannot be solved:
**step1:**
**put** k1=4,k2=4,v1=4,v2=4 :
table[10000]= {
[],
[],
......
[],
[4,4,4,4]
}
usedBuckets=1
size=1
resizeThreshold=int(0.66*10000) = 6600
**step2:**
**put** k1=3,k2=3,v1=3,v2=3 :
table[10000]= {
[],
[],
......
[3,3,3,3],
[4,4,4,4]
}
usedBuckets=2
size=2
resizeThreshold= 6600
**step3:**
**remove** k1=3,k2=3,v1=3,v2=3 :
table[10000]= {
[],
[],
......
[DeletedKey,DeletedKey,ValueNotFound,ValueNotFound],
[4,4,4,4]
}
usedBuckets=2
size=1
resizeThreshold= 6600
....
put/remove
......
**step6601:**
**put** k1=6601,k2=6601,v1=6601,v2=6601
table[10000]= {
[],
[],
......
[DeletedKey,DeletedKey,ValueNotFound,ValueNotFound],
[DeletedKey,DeletedKey,ValueNotFound,ValueNotFound],
[DeletedKey,DeletedKey,ValueNotFound,ValueNotFound],
[DeletedKey,DeletedKey,ValueNotFound,ValueNotFound],
[4,4,4,4]
}
usedBuckets=6601
size=1
resizeThreshold= 6600
**usedBuckets=6601>resizeThreshold=6600 so expand.**
**However, the actual size of the map is 1, and there is still a lots of
free space, so it should not be expanded.**
**After running for a long time, if this situation is encountered many
times, then with the continuous expansion, there will be more and more free
memory space.**
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]