diff --git a/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java b/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java index dbce6c96..8a7ed48f 100644 --- a/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java +++ b/jedai-core/src/main/java/org/scify/jedai/blockbuilding/AbstractBlockBuilding.java @@ -28,6 +28,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -108,19 +109,24 @@ public double getTotalNoOfEntities() { protected void indexEntities(Map index, List entities) { int counter = 0; for (EntityProfile profile : entities) { + final Set allKeys = new HashSet<>(); for (Attribute attribute : profile.getAttributes()) { for (String key : getBlockingKeys(attribute.getValue())) { String normalizedKey = key.trim().toLowerCase(); if (0 < normalizedKey.length()) { - TIntList entityList = index.get(normalizedKey); - if (entityList == null) { - entityList = new TIntArrayList(); - index.put(normalizedKey, entityList); - } - entityList.add(counter); + allKeys.add(normalizedKey); } } } + + for (String key : allKeys) { + TIntList entityList = index.get(key); + if (entityList == null) { + entityList = new TIntArrayList(); + index.put(key, entityList); + } + entityList.add(counter); + } counter++; } }