mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 05:11:04 +00:00
Removed ScalableValue from Extractor and Aggregator making them more
generic
This commit is contained in:
1 parent
b9add70773
commit
6c3266fd52
8 files changed
+32
-44
No files matched your search
@@ -2,10 +2,8 @@ package com.sap.sailing.datamining;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sap.sailing.domain.confidence.ScalableValue;
|
||||
|
||||
public interface Aggregator<ValueType, AveragesTo> {
|
||||
public interface Aggregator<ExtractedType, AggregatedType> {
|
||||
|
||||
public ScalableValue<ValueType, AveragesTo> aggregate(Collection<ScalableValue<ValueType, AveragesTo>> data);
|
||||
public AggregatedType aggregate(Collection<ExtractedType> data);
|
||||
|
||||
}
|
||||
@@ -2,12 +2,10 @@ package com.sap.sailing.datamining;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sap.sailing.domain.confidence.ScalableValue;
|
||||
public interface Extractor<DataType, ExtractedType> {
|
||||
|
||||
public interface Extractor<DataType, ValueType, AveragesTo> {
|
||||
public Collection<ExtractedType> extract(Collection<DataType> data);
|
||||
|
||||
public Collection<ScalableValue<ValueType, AveragesTo>> extract(Collection<DataType> data);
|
||||
|
||||
public ScalableValue<ValueType, AveragesTo> extract(DataType dataEntry);
|
||||
public ExtractedType extract(DataType dataEntry);
|
||||
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package com.sap.sailing.datamining;
|
||||
import com.sap.sailing.datamining.shared.QueryResult;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
|
||||
public interface Query<DataType, ValueType, AveragesTo> {
|
||||
public interface Query<DataType, AggregatedType> {
|
||||
|
||||
public QueryResult<ValueType, AveragesTo> run(RacingEventService racingEventService);
|
||||
public QueryResult<AggregatedType> run(RacingEventService racingEventService);
|
||||
|
||||
}
|
||||
+4
-5
@@ -4,15 +4,14 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sap.sailing.datamining.Extractor;
|
||||
import com.sap.sailing.domain.confidence.ScalableValue;
|
||||
|
||||
public abstract class AbstractExtractor<DataType, ValueType, AveragesTo> implements Extractor<DataType, ValueType, AveragesTo> {
|
||||
public abstract class AbstractExtractor<DataType, ExtractedType> implements Extractor<DataType, ExtractedType> {
|
||||
|
||||
@Override
|
||||
public Collection<ScalableValue<ValueType, AveragesTo>> extract(Collection<DataType> data) {
|
||||
Collection<ScalableValue<ValueType, AveragesTo>> extractedData = new ArrayList<ScalableValue<ValueType,AveragesTo>>();
|
||||
public Collection<ExtractedType> extract(Collection<DataType> data) {
|
||||
Collection<ExtractedType> extractedData = new ArrayList<ExtractedType>();
|
||||
for (DataType dataEntry : data) {
|
||||
ScalableValue<ValueType, AveragesTo> extractedDataEntry = extract(dataEntry);
|
||||
ExtractedType extractedDataEntry = extract(dataEntry);
|
||||
if (extractedDataEntry != null) {
|
||||
extractedData.add(extractedDataEntry);
|
||||
}
|
||||
|
||||
+6
-8
@@ -4,20 +4,18 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sap.sailing.datamining.Extractor;
|
||||
import com.sap.sailing.domain.base.ScalableInteger;
|
||||
import com.sap.sailing.domain.confidence.ScalableValue;
|
||||
|
||||
public class DataAmountExtractor<DataType> implements Extractor<DataType, Integer, Integer> {
|
||||
public class DataAmountExtractor<DataType> implements Extractor<DataType, Integer> {
|
||||
|
||||
@Override
|
||||
public Collection<ScalableValue<Integer, Integer>> extract(Collection<DataType> data) {
|
||||
Collection<ScalableValue<Integer, Integer>> extractedData = new ArrayList<ScalableValue<Integer, Integer>>();
|
||||
extractedData.add(new ScalableInteger(data.size()));
|
||||
public Collection<Integer> extract(Collection<DataType> data) {
|
||||
Collection<Integer> extractedData = new ArrayList<Integer>();
|
||||
extractedData.add(data.size());
|
||||
return extractedData;
|
||||
}
|
||||
|
||||
public ScalableValue<Integer, Integer> extract(DataType dataEntry) {
|
||||
return new ScalableInteger(1);
|
||||
public Integer extract(DataType dataEntry) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,19 +13,18 @@ import com.sap.sailing.datamining.Query;
|
||||
import com.sap.sailing.datamining.shared.GroupKey;
|
||||
import com.sap.sailing.datamining.shared.QueryResult;
|
||||
import com.sap.sailing.datamining.shared.QueryResultImpl;
|
||||
import com.sap.sailing.domain.confidence.ScalableValue;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
|
||||
public class QueryImpl<DataType, ValueType, AveragesTo> implements Query<DataType, ValueType, AveragesTo> {
|
||||
public class QueryImpl<DataType, ExtractedType, AggregatedType> implements Query<DataType, AggregatedType> {
|
||||
|
||||
private DataRetriever<DataType> retriever;
|
||||
private Filter<DataType> filter;
|
||||
private Grouper<DataType> grouper;
|
||||
|
||||
private Extractor<DataType, ValueType, AveragesTo> extractor;
|
||||
private Aggregator<ValueType, AveragesTo> aggregator;
|
||||
private Extractor<DataType, ExtractedType> extractor;
|
||||
private Aggregator<ExtractedType, AggregatedType> aggregator;
|
||||
|
||||
public QueryImpl(DataRetriever<DataType> retriever, Filter<DataType> filter, Grouper<DataType> grouper, Extractor<DataType, ValueType, AveragesTo> extractor, Aggregator<ValueType, AveragesTo> aggregator) {
|
||||
public QueryImpl(DataRetriever<DataType> retriever, Filter<DataType> filter, Grouper<DataType> grouper, Extractor<DataType, ExtractedType> extractor, Aggregator<ExtractedType, AggregatedType> aggregator) {
|
||||
this.retriever = retriever;
|
||||
this.filter = filter;
|
||||
this.grouper = grouper;
|
||||
@@ -34,13 +33,13 @@ public class QueryImpl<DataType, ValueType, AveragesTo> implements Query<DataTyp
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResult<ValueType, AveragesTo> run(RacingEventService racingEventService) {
|
||||
public QueryResult<AggregatedType> run(RacingEventService racingEventService) {
|
||||
Collection<DataType> filteredData = filter.filter(retriever.retrieveData(racingEventService));
|
||||
QueryResultImpl<ValueType, AveragesTo> result = new QueryResultImpl<ValueType, AveragesTo>(filteredData.size());
|
||||
QueryResultImpl<AggregatedType> result = new QueryResultImpl<AggregatedType>(filteredData.size());
|
||||
Map<GroupKey, Collection<DataType>> groupedFixes = grouper.group(filteredData);
|
||||
for (Entry<GroupKey, Collection<DataType>> groupEntry : groupedFixes.entrySet()) {
|
||||
Collection<ScalableValue<ValueType,AveragesTo>> extractedData = extractor.extract(groupEntry.getValue());
|
||||
ScalableValue<ValueType, AveragesTo> aggregatedData = aggregator.aggregate(extractedData);
|
||||
Collection<ExtractedType> extractedData = extractor.extract(groupEntry.getValue());
|
||||
AggregatedType aggregatedData = aggregator.aggregate(extractedData);
|
||||
result.addResult(groupEntry.getKey(), aggregatedData);
|
||||
}
|
||||
return result;
|
||||
|
||||
+2
-4
@@ -3,12 +3,10 @@ package com.sap.sailing.datamining.shared;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.domain.confidence.ScalableValue;
|
||||
|
||||
|
||||
public interface QueryResult<ValueType, AveragesTo> extends Serializable {
|
||||
public interface QueryResult<AggregatedType> extends Serializable {
|
||||
|
||||
public int getDataSize();
|
||||
public Map<GroupKey, ScalableValue<ValueType, AveragesTo>> getResults();
|
||||
public Map<GroupKey, AggregatedType> getResults();
|
||||
|
||||
}
|
||||
+5
-7
@@ -3,12 +3,10 @@ package com.sap.sailing.datamining.shared;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.domain.confidence.ScalableValue;
|
||||
|
||||
public class QueryResultImpl<ValueType, AveragesTo> implements QueryResult<ValueType, AveragesTo> {
|
||||
public class QueryResultImpl<AggregatedType> implements QueryResult<AggregatedType> {
|
||||
private static final long serialVersionUID = 351213515082955565L;
|
||||
|
||||
private Map<GroupKey, ScalableValue<ValueType, AveragesTo>> results;
|
||||
private Map<GroupKey, AggregatedType> results;
|
||||
private int gpsFixAmount;
|
||||
|
||||
@Deprecated
|
||||
@@ -19,7 +17,7 @@ public class QueryResultImpl<ValueType, AveragesTo> implements QueryResult<Value
|
||||
|
||||
public QueryResultImpl(int gpsFixAmount) {
|
||||
this.gpsFixAmount = gpsFixAmount;
|
||||
results = new HashMap<GroupKey, ScalableValue<ValueType, AveragesTo>>();
|
||||
results = new HashMap<GroupKey, AggregatedType>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,11 +26,11 @@ public class QueryResultImpl<ValueType, AveragesTo> implements QueryResult<Value
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<GroupKey, ScalableValue<ValueType, AveragesTo>> getResults() {
|
||||
public Map<GroupKey, AggregatedType> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void addResult(GroupKey key, ScalableValue<ValueType, AveragesTo> value) {
|
||||
public void addResult(GroupKey key, AggregatedType value) {
|
||||
results.put(key, value);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user