gengliangwang commented on a change in pull request #27716:
[SPARK-30964][Core][WebUI] Accelerate InMemoryStore with a new index
URL: https://github.com/apache/spark/pull/27716#discussion_r385999609
##########
File path:
common/kvstore/src/main/java/org/apache/spark/util/kvstore/InMemoryStore.java
##########
@@ -230,18 +261,31 @@ public T get(Object key) {
public void put(T value) throws Exception {
data.put(asKey(naturalKey.get(value)), value);
+ if (!naturalParentIndexName.isEmpty()) {
+ Comparable<Object> parentKey =
asKey(getIndexAccessor(naturalParentIndexName).get(value));
+ NaturalKeys children =
+ parentToChildrenMap.computeIfAbsent(parentKey, k -> new
NaturalKeys());
+ children.put(asKey(naturalKey.get(value)), true);
+ }
}
public void delete(Object key) {
data.remove(asKey(key));
+ if (!naturalParentIndexName.isEmpty()) {
+ for (NaturalKeys v : parentToChildrenMap.values()) {
+ if (v.remove(asKey(key))) {
+ break;
+ }
+ }
Review comment:
Well, `parentToChildrenMap` is a concurrent map and checking emptiness
costs time.
The method here is to delete one entry. I think we can make it simple and
keep it this way.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]