Skip to content

Commit

Permalink
Conflict rate formula update
Browse files Browse the repository at this point in the history
  • Loading branch information
artur committed Jan 17, 2024
1 parent 5251238 commit eca7671
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Map;

public interface GetCollectionStatistics {
Map<String, Double> getSizeStatistics(FilterCriteria filterCriteria);
Map<String, Double> getStatistics(FilterCriteria filterCriteria);

double getConflictRate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ public GetCollectionStatisticsImpl(CharacterisationResultGateway characterisatio
}

@Override
public Map<String, Double> getSizeStatistics(FilterCriteria filterCriteria) {
Map<String, Double> sizeStatistics = characterisationResultGateway.getSizeStatistics(filterCriteria);
public Map<String, Double> getStatistics(FilterCriteria filterCriteria) {
Map<String, Double> sizeStatistics = characterisationResultGateway.getCollectionStatistics(filterCriteria);
return sizeStatistics;
}

@Override
public double getConflictRate() {
return characterisationResultGateway.getConflictRate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public interface CharacterisationResultGateway {
*/
List<CharacterisationResult> getConflictsByFilepath(String filepath);

Map<String, Double> getSizeStatistics(FilterCriteria filterCriteria);
Map<String, Double> getCollectionStatistics(FilterCriteria filterCriteria);

List<PropertyValueStatistic> getPropertyValueDistribution(Property property, FilterCriteria<CharacterisationResult> filter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,25 +158,19 @@ public List<CharacterisationResult> getConflictsByFilepath(String filepath) {
}

@Override
public Map<String, Double> getSizeStatistics(FilterCriteria filterCriteria) {
public Map<String, Double> getCollectionStatistics(FilterCriteria filterCriteria) {
Map<String, Double> result = new HashMap<>();

double[] sizeStatistics = characterisationResultViewRepository.getSizeStatistics(filterCriteria);
result.put("totalSize", sizeStatistics[0]);
Long minSize = characterisationResultViewRepository.getMinSize();
result.put("minSize", sizeStatistics[1]);
Long maxSize = characterisationResultViewRepository.getMaxSize();
result.put("maxSize", sizeStatistics[2]);

Long avgSize = characterisationResultViewRepository.getAvgSize();
result.put("avgSize", sizeStatistics[3]);

Long totalCount = characterisationResultViewRepository.getTotalCount();
result.put("totalCount", sizeStatistics[4]);

double conflictRate = this.getConflictRate();
result.put("conflictRate", conflictRate);

double[] conflictStatistics = characterisationResultViewRepository.getConflictStatistics(filterCriteria);
result.put("conflictRate", conflictStatistics[1]);
result.put("conflictCount", conflictStatistics[0]);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public interface CustomCharacterisationResultViewRepository {

List<Object[]> getObjects(FilterCriteria filterCriteria);

double[] getConflictStatistics(FilterCriteria filterCriteria);

List<String[]> getRandomSamples(FilterCriteria filterCriteria, int sampleSize);

List<String[]> getSelectiveFeatureDistributionSamples(FilterCriteria filterCriteria, List<Property> properties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import rocks.artur.domain.FilterCriteria;
import rocks.artur.domain.Property;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -82,7 +81,7 @@ public List<Object[]> getObjects(FilterCriteria filterCriteria) {
}

@Override
public double[] getSizeStatistics(FilterCriteria filterCriteria){
public double[] getSizeStatistics(FilterCriteria filterCriteria) {
String subquery = "select distinct FILEPATH from CHARACTERISATIONRESULTVIEW ";
if (filterCriteria != null) {
subquery = filterJPA.convert(filterCriteria);
Expand All @@ -108,6 +107,38 @@ public double[] getSizeStatistics(FilterCriteria filterCriteria){
return result;
}


@Override
public double[] getConflictStatistics(FilterCriteria filterCriteria) {
String subquery = "select distinct FILEPATH from CHARACTERISATIONRESULTVIEW ";
if (filterCriteria != null) {
subquery = filterJPA.convert(filterCriteria);
}

String query = String.format(
"select count(distinct t.FILEPATH) as count " +
"from CHARACTERISATIONRESULTVIEW t " +
"join (%s) c on t.FILEPATH=c.FILEPATH " +
"where t.PROPERTY_VALUE='CONFLICT'", subquery);

Long conflictsCount = (Long) entityManager.createNativeQuery(query).getSingleResult();


String query2 = String.format(
"select count(distinct t.FILEPATH) as count " +
"from CHARACTERISATIONRESULTVIEW t " +
"join (%s) c on t.FILEPATH=c.FILEPATH ", subquery);

Long totalCount = (Long) entityManager.createNativeQuery(query2).getSingleResult();

double rate = 0d;
if (totalCount != 0) {
rate = (double) conflictsCount / totalCount;
}
double[] result = new double[]{conflictsCount, rate};
return result;
}

@Override
public List<String[]> getRandomSamples(FilterCriteria filterCriteria, int sampleSize) {
String subquery = "select distinct FILEPATH from CHARACTERISATIONRESULTVIEW ";
Expand Down Expand Up @@ -181,5 +212,4 @@ public List<String[]> getSelectiveFeatureDistributionSamples(FilterCriteria filt
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public List<Property> getConflictsPerObject(
public Map<String, Double> getCollectionStatistics(@RequestParam(name = "filter", required = false) @Parameter(name = "filter", description = "Filter", example = "FORMAT=\"Portable Document Format\"") String filter) throws ParseException {
CriteriaParser parser = new CriteriaParser();
FilterCriteria filterCriteria = parser.parse(filter);
Map<String, Double> sizeStatistics = getCollectionStatistics.getSizeStatistics(filterCriteria);
Map<String, Double> sizeStatistics = getCollectionStatistics.getStatistics(filterCriteria);
return sizeStatistics;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void getCollectionStatisticsWithoutFilterTest() throws ParseException {
String typeFilter = "FORMAT=\"Portable Document Format\"";
CriteriaParser parser = new CriteriaParser();
FilterCriteria parse = parser.parse(typeFilter);
Map<String, Double> sizeStatistics = characterisationResultGatewaySqlImpl.getSizeStatistics(null);
Map<String, Double> sizeStatistics = characterisationResultGatewaySqlImpl.getCollectionStatistics(null);
Assert.assertEquals(10047.0, sizeStatistics.get("totalSize"), 0.1);
System.out.println(sizeStatistics);
}
Expand All @@ -112,7 +112,7 @@ void getCollectionStatisticsWithFilterTest() throws ParseException {
String typeFilter = "FORMAT=\"Portable Document Format\"";
CriteriaParser parser = new CriteriaParser();
FilterCriteria parse = parser.parse(typeFilter);
Map<String, Double> sizeStatistics = characterisationResultGatewaySqlImpl.getSizeStatistics(parse);
Map<String, Double> sizeStatistics = characterisationResultGatewaySqlImpl.getCollectionStatistics(parse);
Assert.assertEquals(4.0, sizeStatistics.get("totalSize"), 0.1);
System.out.println(sizeStatistics);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const PropertyValueDistribution = (payload) => {
}, [filter]);

let filterClick = (property, event) => {
if (event.indexValue == "...others") {
if (event.indexValue == ".etc") {
return;
}
let newCondition = null;
Expand Down

0 comments on commit eca7671

Please sign in to comment.