mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Single keyword search: make bb writes more efficient in a single background thread
This commit is contained in:
parent
0d735e3413
commit
e78134ca37
@ -223,7 +223,7 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueQuery> {
|
|||||||
|
|
||||||
//execute the query and get fscontents matching
|
//execute the query and get fscontents matching
|
||||||
Map<String, List<FsContent>> tcqRes = tcq.performQuery();
|
Map<String, List<FsContent>> tcqRes = tcq.performQuery();
|
||||||
Set<FsContent> fsContents = new HashSet<FsContent>();
|
final Set<FsContent> fsContents = new HashSet<FsContent>();
|
||||||
for (String key : tcqRes.keySet()) {
|
for (String key : tcqRes.keySet()) {
|
||||||
fsContents.addAll(tcqRes.get(key));
|
fsContents.addAll(tcqRes.get(key));
|
||||||
}
|
}
|
||||||
@ -276,9 +276,7 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueQuery> {
|
|||||||
final String theListName = listName;
|
final String theListName = listName;
|
||||||
|
|
||||||
int resID = 0;
|
int resID = 0;
|
||||||
final Collection<BlackboardArtifact> na = new ArrayList<BlackboardArtifact>();
|
|
||||||
final int numFsContents = fsContents.size();
|
|
||||||
int cur = 0;
|
|
||||||
for (final FsContent f : fsContents) {
|
for (final FsContent f : fsContents) {
|
||||||
//get unique match result files
|
//get unique match result files
|
||||||
Map<String, Object> resMap = new LinkedHashMap<String, Object>();
|
Map<String, Object> resMap = new LinkedHashMap<String, Object>();
|
||||||
@ -289,24 +287,25 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueQuery> {
|
|||||||
setCommonProperty(resMap, CommonPropertyTypes.CONTEXT, snippet);
|
setCommonProperty(resMap, CommonPropertyTypes.CONTEXT, snippet);
|
||||||
}
|
}
|
||||||
toPopulate.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, highlightQueryEscaped, tcq));
|
toPopulate.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, highlightQueryEscaped, tcq));
|
||||||
|
}
|
||||||
|
//write to bb
|
||||||
|
new Thread() {
|
||||||
|
|
||||||
//write to bb
|
@Override
|
||||||
final boolean sendDataEvent = (cur == numFsContents - 1 ? true : false); //send a single bulk notification after the last write
|
public void run() {
|
||||||
new Thread() {
|
final Collection<BlackboardArtifact> na = new ArrayList<BlackboardArtifact>();
|
||||||
|
for (final FsContent f : fsContents) {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Collection<KeywordWriteResult> written = tcq.writeToBlackBoard(f, theListName);
|
Collection<KeywordWriteResult> written = tcq.writeToBlackBoard(f, theListName);
|
||||||
for (KeywordWriteResult w : written) {
|
for (KeywordWriteResult w : written) {
|
||||||
na.add(w.getArtifact());
|
na.add(w.getArtifact());
|
||||||
}
|
}
|
||||||
if (sendDataEvent == true && !na.isEmpty()) {
|
|
||||||
IngestManager.fireServiceDataEvent(new ServiceDataEvent(KeywordSearchIngestService.MODULE_NAME, ARTIFACT_TYPE.TSK_KEYWORD_HIT, na));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.start();
|
if (!na.isEmpty()) {
|
||||||
cur++;
|
IngestManager.fireServiceDataEvent(new ServiceDataEvent(KeywordSearchIngestService.MODULE_NAME, ARTIFACT_TYPE.TSK_KEYWORD_HIT, na));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -377,36 +376,37 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueQuery> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//get unique match result files
|
//get unique match result files
|
||||||
Set<FsContent> uniqueMatches = new LinkedHashSet<FsContent>();
|
final Set<FsContent> uniqueMatches = new LinkedHashSet<FsContent>();
|
||||||
uniqueMatches.addAll(matches);
|
uniqueMatches.addAll(matches);
|
||||||
|
|
||||||
int resID = 0;
|
int resID = 0;
|
||||||
int cur = 0;
|
|
||||||
final KeywordSearchQuery origQuery = thing.getQuery();
|
final KeywordSearchQuery origQuery = thing.getQuery();
|
||||||
final int numFsContents = uniqueMatches.size();
|
|
||||||
final Collection<BlackboardArtifact> na = new ArrayList<BlackboardArtifact>();
|
|
||||||
for (final FsContent f : uniqueMatches) {
|
for (final FsContent f : uniqueMatches) {
|
||||||
Map<String, Object> resMap = new LinkedHashMap<String, Object>();
|
Map<String, Object> resMap = new LinkedHashMap<String, Object>();
|
||||||
AbstractFsContentNode.fillPropertyMap(resMap, (File) f);
|
AbstractFsContentNode.fillPropertyMap(resMap, (File) f);
|
||||||
toPopulate.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, keywordQuery, thing.getQuery()));
|
toPopulate.add(new KeyValueQueryContent(f.getName(), resMap, ++resID, f, keywordQuery, thing.getQuery()));
|
||||||
|
|
||||||
//write to bb
|
}
|
||||||
final boolean sendDataEvent = (cur == numFsContents - 1 ? true : false); //send a single bulk notification after the last write
|
//write to bb
|
||||||
new Thread() {
|
new Thread() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
final Collection<BlackboardArtifact> na = new ArrayList<BlackboardArtifact>();
|
||||||
|
for (final FsContent f : uniqueMatches) {
|
||||||
Collection<KeywordWriteResult> written = origQuery.writeToBlackBoard(f, "");
|
Collection<KeywordWriteResult> written = origQuery.writeToBlackBoard(f, "");
|
||||||
for (KeywordWriteResult w : written) {
|
for (KeywordWriteResult w : written) {
|
||||||
na.add(w.getArtifact());
|
na.add(w.getArtifact());
|
||||||
}
|
}
|
||||||
if (sendDataEvent == true && !na.isEmpty()) {
|
|
||||||
IngestManager.fireServiceDataEvent(new ServiceDataEvent(KeywordSearchIngestService.MODULE_NAME, ARTIFACT_TYPE.TSK_KEYWORD_HIT, na));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.start();
|
if (!na.isEmpty()) {
|
||||||
cur++;
|
IngestManager.fireServiceDataEvent(new ServiceDataEvent(KeywordSearchIngestService.MODULE_NAME, ARTIFACT_TYPE.TSK_KEYWORD_HIT, na));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}.start();
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -417,17 +417,6 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueQuery> {
|
|||||||
final Content content = thingContent.getContent();
|
final Content content = thingContent.getContent();
|
||||||
final String query = thingContent.getQueryStr();
|
final String query = thingContent.getQueryStr();
|
||||||
|
|
||||||
Core core = null;
|
|
||||||
try {
|
|
||||||
core = KeywordSearch.getServer().getCore();
|
|
||||||
} catch (SolrServerException ex) {
|
|
||||||
logger.log(Level.INFO, "Could not get Solr core", ex);
|
|
||||||
}
|
|
||||||
if (core == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Node kvNode = new KeyValueNode(thingContent, Children.LEAF, Lookups.singleton(content));
|
Node kvNode = new KeyValueNode(thingContent, Children.LEAF, Lookups.singleton(content));
|
||||||
//wrap in KeywordSearchFilterNode for the markup content
|
//wrap in KeywordSearchFilterNode for the markup content
|
||||||
HighlightedMatchesSource highlights = new HighlightedMatchesSource(content, query, !thingContent.getQuery().isEscaped());
|
HighlightedMatchesSource highlights = new HighlightedMatchesSource(content, query, !thingContent.getQuery().isEscaped());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user