cloud-fan 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_r385613040
##########
File path:
common/kvstore/src/main/java/org/apache/spark/util/kvstore/InMemoryStore.java
##########
@@ -205,23 +211,48 @@ public void accept(Comparable<Object> key, T value) {
private final KVTypeInfo ti;
private final KVTypeInfo.Accessor naturalKey;
private final ConcurrentMap<Comparable<Object>, T> data;
+ private final String naturalParentIndexName;
+ // A mapping from parent to the natural keys of its children.
+ // For example, a mapping from a stage ID to all the task IDs in the stage.
+ private final ConcurrentMap<Comparable<Object>, NaturalKeys>
parentToChildrenMap;
private InstanceList(Class<?> klass) {
this.ti = new KVTypeInfo(klass);
this.naturalKey = ti.getAccessor(KVIndex.NATURAL_INDEX_NAME);
this.data = new ConcurrentHashMap<>();
+ this.naturalParentIndexName =
ti.getParentIndexName(KVIndex.NATURAL_INDEX_NAME);
+ this.parentToChildrenMap = new ConcurrentHashMap<>();
}
KVTypeInfo.Accessor getIndexAccessor(String indexName) {
return ti.getAccessor(indexName);
}
int countingRemoveAllByIndexValues(String index, Collection<?>
indexValues) {
Review comment:
since there is no document, I still have problems understanding it.
The basic idea is: if the `index` is natural index, we can just look it up
in O(1). For other index, we have to do linear scan, extract keys and find
matches.
The extension here: if the `index` is parent of natural index, get the
children natural indexes and do O(1) lookup.
However, seems the basic idea is missing? Shall we avoid linear scan if
`index` is natural index?
----------------------------------------------------------------
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]