keyword search: when done from GUI, use background thread to write results to BB not to block the GUI thread for huge queries

This commit is contained in:
adam-m 2012-02-15 12:33:18 -05:00
parent af4905a7dd
commit c6ce9575cf
2 changed files with 30 additions and 15 deletions

View File

@ -247,8 +247,10 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValue> {
int resID = 0;
Collection<BlackboardArtifact> na = new ArrayList<BlackboardArtifact>();
for (FsContent f : fsContents) {
final Collection<BlackboardArtifact> na = new ArrayList<BlackboardArtifact>();
final int numFsContents = fsContents.size();
int cur = 0;
for (final FsContent f : fsContents) {
//get unique match result files
Map<String, Object> resMap = new LinkedHashMap<String, Object>();
AbstractFsContentNode.fillPropertyMap(resMap, f);
@ -260,10 +262,18 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValue> {
toPopulate.add(new KeyValueContent(f.getName(), resMap, ++resID, f, highlightQueryEscaped));
//write to bb
final boolean sendDataEvent = (cur == numFsContents-1?true:false);
new Thread() {
@Override
public void run() {
na.addAll(tcq.writeToBlackBoard(f));
}
//notify bb viewers
if (sendDataEvent == true) {
IngestManager.fireServiceDataEvent(new ServiceDataEvent(KeywordSearchIngestService.MODULE_NAME, ARTIFACT_TYPE.TSK_KEYWORD_HIT, na));
}
}
}.start();
cur++;
}
return true;
}

View File

@ -153,7 +153,7 @@ public class LuceneQuery implements KeywordSearchQuery {
@Override
public void execute() {
escape();
List<FsContent> matches = performQuery();
final List<FsContent> matches = performQuery();
String pathText = "Keyword query: " + query;
@ -164,6 +164,9 @@ public class LuceneQuery implements KeywordSearchQuery {
searchResultWin.requestActive(); // make it the active top component
//write to bb
new Thread() {
@Override
public void run() {
Collection<BlackboardArtifact> na = new ArrayList<BlackboardArtifact>();
for (FsContent newHit : matches) {
na.addAll(writeToBlackBoard(newHit));
@ -171,6 +174,8 @@ public class LuceneQuery implements KeywordSearchQuery {
//notify bb viewers
IngestManager.fireServiceDataEvent(new ServiceDataEvent(KeywordSearchIngestService.MODULE_NAME, ARTIFACT_TYPE.TSK_KEYWORD_HIT, na));
}
}.start();
}
@Override
public boolean validate() {