adoroszlai commented on a change in pull request #3121:
URL: https://github.com/apache/ozone/pull/3121#discussion_r812826098
##########
File path:
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/EpochEntry.java
##########
@@ -64,7 +64,8 @@ public int hashCode() {
@Override
public int compareTo(Object o) {
if (this.epoch == ((EpochEntry<?>)o).epoch) {
- return 0;
+ return Integer.compare(
+ this.cachekey.hashCode(), ((EpochEntry<?>) o).cachekey.hashCode());
Review comment:
I think the basic problem is that table caches use a `NavigableSet` of
`EpochEntry` items:
https://github.com/apache/ozone/blob/239d889344e028d4e08a9c678a837f54a801fccd/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/FullTableCache.java#L55
where each `EpochEntry` is basically a pair:
https://github.com/apache/ozone/blob/239d889344e028d4e08a9c678a837f54a801fccd/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/cache/EpochEntry.java#L31-L32
The problem is that `CACHEKEY` is a generic type that may be `Comparable`
(e.g. `Long` or `String`) or not (e.g. `OzoneTokenIdentifier`). We may try to
make all actual types implement `Comparable`, but that would be lot of work,
unnecessary in my opinion.
I propose to replace `NavigableSet` with a `NavigableMap`:
```
private final NavigableMap<Long, Set<CACHEKEY>> epochEntries;
```
This allows efficient handling of epochs, while avoiding the need to order
the `CACHEKEY` part.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]