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_r385198544
##########
File path:
common/kvstore/src/main/java/org/apache/spark/util/kvstore/InMemoryStore.java
##########
@@ -322,15 +370,28 @@ private static Object
indexValueForEntity(KVTypeInfo.Accessor getter, Object ent
*/
private List<T> copyElements() {
if (parent != null) {
- KVTypeInfo.Accessor parentGetter = ti.getParentAccessor(index);
- Preconditions.checkArgument(parentGetter != null, "Parent filter for
non-child index.");
- Comparable<?> parentKey = asKey(parent);
-
- return elements.stream()
- .filter(e -> compare(e, parentGetter, parentKey) == 0)
- .collect(Collectors.toList());
+ Comparable<Object> parentKey = asKey(parent);
+ if (!naturalParentIndexName.isEmpty() &&
+ naturalParentIndexName.equals(ti.getParentIndexName(index))) {
+ NaturalKeys children =
+ parentToChildrenMap.computeIfAbsent(parentKey, k -> new
NaturalKeys());
+ ArrayList<T> elements = new ArrayList<>();
+ for (Comparable<Object> naturalKey : children.keySet()) {
+ data.computeIfPresent(naturalKey, (k, v) -> {
Review comment:
is this faster than `data.values().stream()...`?
----------------------------------------------------------------
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]