mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
4381 loop over keyset for property tables instead of all properties
This commit is contained in:
parent
f687446658
commit
d99863e770
@ -95,7 +95,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
|
|
||||||
defaultCorrelationTypes = CorrelationAttributeInstance.getDefaultCorrelationTypes();
|
defaultCorrelationTypes = CorrelationAttributeInstance.getDefaultCorrelationTypes();
|
||||||
defaultCorrelationTypes.forEach((type) -> {
|
defaultCorrelationTypes.forEach((type) -> {
|
||||||
bulkArtifacts.put(type.getDbTableName(), new ArrayList<>());
|
bulkArtifacts.put(EamDbUtil.correlationTypeToInstanceTableName(type), new ArrayList<>());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1207,7 +1207,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized (bulkArtifacts) {
|
synchronized (bulkArtifacts) {
|
||||||
bulkArtifacts.get(eamArtifact.getCorrelationType().getDbTableName()).add(eamArtifact);
|
bulkArtifacts.get(EamDbUtil.correlationTypeToInstanceTableName(eamArtifact.getCorrelationType())).add(eamArtifact);
|
||||||
bulkArtifactsCount++;
|
bulkArtifactsCount++;
|
||||||
|
|
||||||
if (bulkArtifactsCount >= bulkArtifactsThreshold) {
|
if (bulkArtifactsCount >= bulkArtifactsThreshold) {
|
||||||
@ -1240,9 +1240,8 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CorrelationAttributeInstance.Type type : artifactTypes) {
|
for (String tableName : bulkArtifacts.keySet()) {
|
||||||
|
|
||||||
String tableName = EamDbUtil.correlationTypeToInstanceTableName(type);
|
|
||||||
String sql
|
String sql
|
||||||
= "INSERT INTO "
|
= "INSERT INTO "
|
||||||
+ tableName
|
+ tableName
|
||||||
@ -1253,66 +1252,65 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
|
|
||||||
bulkPs = conn.prepareStatement(sql);
|
bulkPs = conn.prepareStatement(sql);
|
||||||
|
|
||||||
Collection<CorrelationAttributeInstance> eamArtifacts = bulkArtifacts.get(type.getDbTableName());
|
Collection<CorrelationAttributeInstance> eamArtifacts = bulkArtifacts.get(tableName);
|
||||||
if (eamArtifacts != null) {
|
for (CorrelationAttributeInstance eamArtifact : eamArtifacts) {
|
||||||
for (CorrelationAttributeInstance eamArtifact : eamArtifacts) {
|
|
||||||
|
|
||||||
if (!eamArtifact.getCorrelationValue().isEmpty()) {
|
if (!eamArtifact.getCorrelationValue().isEmpty()) {
|
||||||
|
|
||||||
if (eamArtifact.getCorrelationCase() == null) {
|
if (eamArtifact.getCorrelationCase() == null) {
|
||||||
throw new EamDbException("CorrelationAttributeInstance case is null for: "
|
throw new EamDbException("CorrelationAttributeInstance case is null for: "
|
||||||
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
||||||
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
||||||
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue());
|
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue());
|
||||||
}
|
}
|
||||||
if (eamArtifact.getCorrelationDataSource() == null) {
|
if (eamArtifact.getCorrelationDataSource() == null) {
|
||||||
throw new EamDbException("CorrelationAttributeInstance data source is null for: "
|
throw new EamDbException("CorrelationAttributeInstance data source is null for: "
|
||||||
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
||||||
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
||||||
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue());
|
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue());
|
||||||
}
|
}
|
||||||
if (eamArtifact.getKnownStatus() == null) {
|
if (eamArtifact.getKnownStatus() == null) {
|
||||||
throw new EamDbException("CorrelationAttributeInstance known status is null for: "
|
throw new EamDbException("CorrelationAttributeInstance known status is null for: "
|
||||||
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
||||||
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
||||||
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue()
|
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue()
|
||||||
+ "\n\tEam Instance: "
|
+ "\n\tEam Instance: "
|
||||||
+ "\n\t\tCaseId: " + eamArtifact.getCorrelationDataSource().getCaseID()
|
+ "\n\t\tCaseId: " + eamArtifact.getCorrelationDataSource().getCaseID()
|
||||||
+ "\n\t\tDeviceID: " + eamArtifact.getCorrelationDataSource().getDeviceID());
|
+ "\n\t\tDeviceID: " + eamArtifact.getCorrelationDataSource().getDeviceID());
|
||||||
}
|
|
||||||
|
|
||||||
if (eamArtifact.getCorrelationValue().length() < MAX_VALUE_LENGTH) {
|
|
||||||
bulkPs.setString(1, eamArtifact.getCorrelationCase().getCaseUUID());
|
|
||||||
bulkPs.setLong(2, eamArtifact.getCorrelationDataSource().getDataSourceObjectID());
|
|
||||||
bulkPs.setInt(3, eamArtifact.getCorrelationDataSource().getCaseID());
|
|
||||||
bulkPs.setString(4, eamArtifact.getCorrelationValue());
|
|
||||||
bulkPs.setString(5, eamArtifact.getFilePath());
|
|
||||||
bulkPs.setByte(6, eamArtifact.getKnownStatus().getFileKnownValue());
|
|
||||||
if ("".equals(eamArtifact.getComment())) {
|
|
||||||
bulkPs.setNull(7, Types.INTEGER);
|
|
||||||
} else {
|
|
||||||
bulkPs.setString(7, eamArtifact.getComment());
|
|
||||||
}
|
|
||||||
bulkPs.setLong(8, eamArtifact.getFileObjectId());
|
|
||||||
bulkPs.addBatch();
|
|
||||||
} else {
|
|
||||||
logger.log(Level.WARNING, ("Artifact value too long for central repository."
|
|
||||||
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
|
||||||
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
|
||||||
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue())
|
|
||||||
+ "\n\tEam Instance: "
|
|
||||||
+ "\n\t\tCaseId: " + eamArtifact.getCorrelationDataSource().getCaseID()
|
|
||||||
+ "\n\t\tDeviceID: " + eamArtifact.getCorrelationDataSource().getDeviceID()
|
|
||||||
+ "\n\t\tFilePath: " + eamArtifact.getFilePath());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (eamArtifact.getCorrelationValue().length() < MAX_VALUE_LENGTH) {
|
||||||
|
bulkPs.setString(1, eamArtifact.getCorrelationCase().getCaseUUID());
|
||||||
|
bulkPs.setLong(2, eamArtifact.getCorrelationDataSource().getDataSourceObjectID());
|
||||||
|
bulkPs.setInt(3, eamArtifact.getCorrelationDataSource().getCaseID());
|
||||||
|
bulkPs.setString(4, eamArtifact.getCorrelationValue());
|
||||||
|
bulkPs.setString(5, eamArtifact.getFilePath());
|
||||||
|
bulkPs.setByte(6, eamArtifact.getKnownStatus().getFileKnownValue());
|
||||||
|
if ("".equals(eamArtifact.getComment())) {
|
||||||
|
bulkPs.setNull(7, Types.INTEGER);
|
||||||
|
} else {
|
||||||
|
bulkPs.setString(7, eamArtifact.getComment());
|
||||||
|
}
|
||||||
|
bulkPs.setLong(8, eamArtifact.getFileObjectId());
|
||||||
|
bulkPs.addBatch();
|
||||||
|
} else {
|
||||||
|
logger.log(Level.WARNING, ("Artifact value too long for central repository."
|
||||||
|
+ "\n\tCorrelationArtifact ID: " + eamArtifact.getID()
|
||||||
|
+ "\n\tCorrelationArtifact Type: " + eamArtifact.getCorrelationType().getDisplayName()
|
||||||
|
+ "\n\tCorrelationArtifact Value: " + eamArtifact.getCorrelationValue())
|
||||||
|
+ "\n\tEam Instance: "
|
||||||
|
+ "\n\t\tCaseId: " + eamArtifact.getCorrelationDataSource().getCaseID()
|
||||||
|
+ "\n\t\tDeviceID: " + eamArtifact.getCorrelationDataSource().getDeviceID()
|
||||||
|
+ "\n\t\tFilePath: " + eamArtifact.getFilePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bulkPs.executeBatch();
|
|
||||||
bulkArtifacts.get(type.getDbTableName()).clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bulkPs.executeBatch();
|
||||||
|
bulkArtifacts.get(tableName).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
TimingMetric timingMetric = HealthMonitor.getTimingMetric("Correlation Engine: Bulk insert");
|
TimingMetric timingMetric = HealthMonitor.getTimingMetric("Correlation Engine: Bulk insert");
|
||||||
HealthMonitor.submitTimingMetric(timingMetric);
|
HealthMonitor.submitTimingMetric(timingMetric);
|
||||||
|
|
||||||
@ -3297,7 +3295,7 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
statement.execute(String.format(addValueIndexTemplate, wirelessNetworksTableInstanceName, wirelessNetworksTableInstanceName));
|
statement.execute(String.format(addValueIndexTemplate, wirelessNetworksTableInstanceName, wirelessNetworksTableInstanceName));
|
||||||
statement.execute(String.format(addKnownStatusIndexTemplate, wirelessNetworksTableInstanceName, wirelessNetworksTableInstanceName));
|
statement.execute(String.format(addKnownStatusIndexTemplate, wirelessNetworksTableInstanceName, wirelessNetworksTableInstanceName));
|
||||||
|
|
||||||
//create a new mac_address_instances table and add indexes for its columns
|
//create a new mac_address_instances table and add indexes for its columns
|
||||||
statement.execute(String.format(addSsidTableTemplate, macAddressTableInstanceName, macAddressTableInstanceName));
|
statement.execute(String.format(addSsidTableTemplate, macAddressTableInstanceName, macAddressTableInstanceName));
|
||||||
statement.execute(String.format(addCaseIdIndexTemplate, macAddressTableInstanceName, macAddressTableInstanceName));
|
statement.execute(String.format(addCaseIdIndexTemplate, macAddressTableInstanceName, macAddressTableInstanceName));
|
||||||
statement.execute(String.format(addDataSourceIdIndexTemplate, macAddressTableInstanceName, macAddressTableInstanceName));
|
statement.execute(String.format(addDataSourceIdIndexTemplate, macAddressTableInstanceName, macAddressTableInstanceName));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user