diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java index 8f553dff2a..047ed4ed4d 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/AbstractCommonAttributeSearcher.java @@ -130,9 +130,9 @@ public abstract class AbstractCommonAttributeSearcher { } } - static Map collateMatchesByNumberOfInstances(Map commonFiles) { + static TreeMap collateMatchesByNumberOfInstances(Map commonFiles) { //collate matches by number of matching instances - doing this in sql doesnt seem efficient - Map instanceCollatedCommonFiles = new TreeMap<>(); + TreeMap instanceCollatedCommonFiles = new TreeMap<>(); for (CommonAttributeValue md5Metadata : commonFiles.values()) { Integer size = md5Metadata.getDataSources().size(); diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java index c1d2dcb481..9eda2b4020 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/CommonAttributeCountSearchResults.java @@ -25,6 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.TreeMap; import java.util.logging.Level; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; @@ -41,7 +42,7 @@ final public class CommonAttributeCountSearchResults { private static final Logger LOGGER = Logger.getLogger(CommonAttributeCountSearchResults.class.getName()); // maps instance count to list of attribute values. - private final Map instanceCountToAttributeValues; + private final TreeMap instanceCountToAttributeValues; private final int percentageThreshold; private final int resultTypeId; @@ -58,7 +59,7 @@ final public class CommonAttributeCountSearchResults { */ CommonAttributeCountSearchResults(Map metadata, int percentageThreshold, CorrelationAttributeInstance.Type resultType) { //wrap in a new object in case any client code has used an unmodifiable collection - this.instanceCountToAttributeValues = new HashMap<>(metadata); + this.instanceCountToAttributeValues = new TreeMap<>(metadata); this.percentageThreshold = percentageThreshold; this.resultTypeId = resultType.getId(); } @@ -73,7 +74,7 @@ final public class CommonAttributeCountSearchResults { */ CommonAttributeCountSearchResults(Map metadata, int percentageThreshold) { //wrap in a new object in case any client code has used an unmodifiable collection - this.instanceCountToAttributeValues = new HashMap<>(metadata); + this.instanceCountToAttributeValues = new TreeMap<>(metadata); this.percentageThreshold = percentageThreshold; this.resultTypeId = CorrelationAttributeInstance.FILES_TYPE_ID; } diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java index 52f2cec276..e2dc8e616b 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/InterCaseSearchResultsProcessor.java @@ -29,6 +29,7 @@ import java.util.HashSet; import java.util.Set; import java.util.List; import java.util.Map; +import java.util.TreeMap; import java.util.logging.Level; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; @@ -173,7 +174,7 @@ final class InterCaseSearchResultsProcessor { } catch (EamDbException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error accessing EamDb processing CaseInstancesTable.", ex); } - return new HashMap<>(); + return new TreeMap<>(); } /** @@ -205,7 +206,7 @@ final class InterCaseSearchResultsProcessor { } catch (EamDbException | TskCoreException ex) { LOGGER.log(Level.SEVERE, "Error accessing EamDb processing CaseInstancesTable.", ex); } - return new HashMap<>(); + return new TreeMap<>(); } /** @@ -248,7 +249,7 @@ final class InterCaseSearchResultsProcessor { */ private class InterCaseByCountCallback implements CaseDbAccessManager.CaseDbAccessQueryCallback, InstanceTableCallback { - private final Map instanceCollatedCommonFiles = new HashMap<>(); + private final TreeMap instanceCollatedCommonFiles = new TreeMap<>(); private final int caseID; private final int targetCase; @@ -311,7 +312,7 @@ final class InterCaseSearchResultsProcessor { } Map getInstanceCollatedCommonFiles() { - return Collections.unmodifiableMap(instanceCollatedCommonFiles); + return Collections.unmodifiableSortedMap(instanceCollatedCommonFiles); } } diff --git a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java index f48d23d030..21ac1bb18b 100644 --- a/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java +++ b/Core/src/org/sleuthkit/autopsy/commonpropertiessearch/IntraCaseCommonAttributeSearcher.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException; @@ -137,7 +138,7 @@ public abstract class IntraCaseCommonAttributeSearcher extends AbstractCommonAtt } } - Map instanceCollatedCommonFiles = collateMatchesByNumberOfInstances(commonFiles); + TreeMap instanceCollatedCommonFiles = collateMatchesByNumberOfInstances(commonFiles); return new CommonAttributeCountSearchResults(instanceCollatedCommonFiles, this.frequencyPercentageThreshold); }