diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java index e595307b65..5d8e23e9c9 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java @@ -242,6 +242,8 @@ public class KeywordSearchResultFactory extends ChildFactory { return false; } + List tempList = new ArrayList<>(); + //execute the query and get fscontents matching Map> tcqRes; try { @@ -311,8 +313,13 @@ public class KeywordSearchResultFactory extends ChildFactory { } final String highlightQueryEscaped = getHighlightQuery(tcq, literal_query, tcqRes, f); - toPopulate.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, highlightQueryEscaped, tcq, previewChunk, tcqRes)); + tempList.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, highlightQueryEscaped, tcq, previewChunk, tcqRes)); } + + // Add all the nodes to toPopulate at once. Minimizes node creation + // EDT threads, which can slow and/or hang the UI on large queries. + toPopulate.addAll(tempList); + //write to bb //cannot reuse snippet in ResultWriter //because for regex searches in UI we compress results by showing a file per regex once (even if multiple term hits) @@ -449,15 +456,22 @@ public class KeywordSearchResultFactory extends ChildFactory { int resID = 0; final KeywordSearchQuery origQuery = thing.getQuery(); - + + List tempList = new ArrayList<>(); + for (final AbstractFile f : uniqueMatches.keySet()) { final int previewChunkId = uniqueMatches.get(f); Map resMap = new LinkedHashMap<>(); if (f.getType() == TSK_DB_FILES_TYPE_ENUM.FS) { AbstractFsContentNode.fillPropertyMap(resMap, (FsContent) f); } - toPopulate.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, keywordQuery, thing.getQuery(), previewChunkId, matchesRes)); + tempList.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, keywordQuery, thing.getQuery(), previewChunkId, matchesRes)); } + + // Add all the nodes to toPopulate at once. Minimizes node creation + // EDT threads, which can slow and/or hang the UI on large queries. + toPopulate.addAll(tempList); + //write to bb new ResultWriter(matchesRes, origQuery, "").execute();