charlesconnell opened a new pull request, #6679:
URL: https://github.com/apache/hbase/pull/6679
This PR copies the `CodecPool` and `TestCodecPool` classes from
hadoop-common, and then applies changes to improve performance. Change the pool
data structure from `HashMap<Class<Compressor>, HashSet<Compressor>>` to
`ConcurrentHashMap<Class<Compressor>, ConcurrentSkipListSet<Compressor>>`. This
allows the "borrow" code:
```
T codec = null;
Set<T> codecSet;
synchronized (pool) {
codecSet = pool.get(codecClass);
}
if (codecSet != null) {
synchronized (codecSet) {
if (!codecSet.isEmpty()) {
codec = codecSet.iterator().next();
codecSet.remove(codec);
}
}
}
```
to be re-written as:
```
if (codecClass == null) {
return null;
}
NavigableSet<T> codecSet = pool.get(codecClass);
if (codecSet != null) {
return codecSet.pollFirst();
} else {
return null;
}
```
thus avoiding the allocation of an iterator and the necessity of locking.
The lease counters are only read in unit tests, so this PR stops updating
those outside of testing.
--
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]