6865 changes to address feedback and help performance

This commit is contained in:
William Schaefer 2020-09-23 17:55:30 -04:00
parent 1fd17fa521
commit 14de7eda35
2 changed files with 10 additions and 16 deletions

View File

@ -57,30 +57,23 @@ class DomainSearchCacheLoader extends CacheLoader<SearchKey, Map<GroupKey, List<
@Override @Override
public Map<GroupKey, List<Result>> load(SearchKey key) throws DiscoveryException, SQLException, TskCoreException { public Map<GroupKey, List<Result>> load(SearchKey key) throws DiscoveryException, SQLException, TskCoreException {
List<Result> domainResults = getResultDomainsFromDatabase(key); List<Result> domainResults = getResultDomainsFromDatabase(key);
//manually add the attributes for filters which use alternate non filters and could be used by grouping or sorting
DiscoveryAttributes.FrequencyAttribute freqAttr = new DiscoveryAttributes.FrequencyAttribute();
freqAttr.addAttributeToResults(domainResults, key.getSleuthkitCase(), key.getCentralRepository());
// Apply secondary in memory filters
for (AbstractFilter filter : key.getFilters()) {
if (filter.useAlternateFilter()) {
domainResults = filter.applyAlternateFilter(domainResults, key.getSleuthkitCase(), key.getCentralRepository());
}
}
// Grouping by CR Frequency, for example, will require further processing // Grouping by CR Frequency, for example, will require further processing
// in order to make the correct decision. The attribute types that require // in order to make the correct decision. The attribute types that require
// more information implement their logic by overriding `addAttributeToResults`. // more information implement their logic by overriding `addAttributeToResults`.
List<AttributeType> searchAttributes = new ArrayList<>(); List<AttributeType> searchAttributes = new ArrayList<>();
searchAttributes.add(key.getGroupAttributeType()); searchAttributes.add(key.getGroupAttributeType());
searchAttributes.addAll(key.getFileSortingMethod().getRequiredAttributes()); searchAttributes.addAll(key.getFileSortingMethod().getRequiredAttributes());
for (AttributeType attr : searchAttributes) { for (AttributeType attr : searchAttributes) {
attr.addAttributeToResults(domainResults, attr.addAttributeToResults(domainResults,
key.getSleuthkitCase(), key.getCentralRepository()); key.getSleuthkitCase(), key.getCentralRepository());
} }
// Apply secondary in memory filters
for (AbstractFilter filter : key.getFilters()) {
if (filter.useAlternateFilter()) {
domainResults = filter.applyAlternateFilter(domainResults, key.getSleuthkitCase(), key.getCentralRepository());
}
}
// Sort the ResultDomains by the requested criteria. // Sort the ResultDomains by the requested criteria.
final SearchResults searchResults = new SearchResults( final SearchResults searchResults = new SearchResults(
key.getGroupSortingType(), key.getGroupSortingType(),

View File

@ -116,9 +116,6 @@ public class SearchFiltering {
resultList.add(new ResultFile(abstractFile)); resultList.add(new ResultFile(abstractFile));
} }
//manually add the attributes for filters which use alternate non filters and could be used by grouping or sorting
DiscoveryAttributes.FrequencyAttribute freqAttr = new DiscoveryAttributes.FrequencyAttribute();
freqAttr.addAttributeToResults(resultList, caseDb, centralRepoDb);
// Now run any non-SQL filters. // Now run any non-SQL filters.
for (AbstractFilter filter : filters) { for (AbstractFilter filter : filters) {
if (filter.useAlternateFilter()) { if (filter.useAlternateFilter()) {
@ -652,6 +649,10 @@ public class SearchFiltering {
@Override @Override
public List<Result> applyAlternateFilter(List<Result> currentResults, SleuthkitCase caseDb, public List<Result> applyAlternateFilter(List<Result> currentResults, SleuthkitCase caseDb,
CentralRepository centralRepoDb) throws DiscoveryException { CentralRepository centralRepoDb) throws DiscoveryException {
// Set the frequency for each file
DiscoveryAttributes.FrequencyAttribute freqAttr = new DiscoveryAttributes.FrequencyAttribute();
freqAttr.addAttributeToResults(currentResults, caseDb, centralRepoDb);
// If the frequency matches the filter, add the file to the results // If the frequency matches the filter, add the file to the results
List<Result> frequencyResults = new ArrayList<>(); List<Result> frequencyResults = new ArrayList<>();
for (Result file : currentResults) { for (Result file : currentResults) {