Skip to content

Commit

Permalink
MergeTagsFunction implements Func1 instead of Guava Function
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Burman committed May 25, 2015
1 parent d7d7de7 commit 1e475ec
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import org.slf4j.LoggerFactory;

import rx.Observable;
import rx.functions.Func1;
import rx.subjects.PublishSubject;

/**
Expand Down Expand Up @@ -304,10 +305,10 @@ private boolean isEmbeddedCassandraServer() {
}

private static class MergeTagsFunction<T extends MetricData> implements
Function<List<Map<MetricId, Set<T>>>, Map<MetricId, Set<T>>> {
Func1<List<Map<MetricId, Set<T>>>, Map<MetricId, Set<T>>> {

@Override
public Map<MetricId, Set<T>> apply(List<Map<MetricId, Set<T>>> taggedDataMaps) {
public Map<MetricId, Set<T>> call(List<Map<MetricId, Set<T>>> taggedDataMaps) {
if (taggedDataMaps.isEmpty()) {
return Collections.emptyMap();
}
Expand Down Expand Up @@ -797,25 +798,22 @@ public Observable<ResultSet> tagAvailabilityData(Availability metric,

@Override
public Observable<Map<MetricId, Set<GaugeData>>> findGaugeDataByTags(String tenantId, Map<String, String> tags) {
MergeTagsFunction f = new MergeTagsFunction();

return Observable.from(tags.entrySet())
.flatMap(e -> dataAccess.findGaugeDataByTag(tenantId, e.getKey(), e.getValue()))
.map(TaggedGaugeDataMapper::apply)
.toList()
.map(r -> f.apply(r));
.map(new MergeTagsFunction<>());
}

@Override
public Observable<Map<MetricId, Set<AvailabilityData>>> findAvailabilityByTags(String tenantId,
Map<String, String> tags) {
MergeTagsFunction f = new MergeTagsFunction();

return Observable.from(tags.entrySet())
.flatMap(e -> dataAccess.findAvailabilityByTag(tenantId, e.getKey(), e.getValue()))
.map(TaggedAvailabilityMapper::apply)
.toList()
.map(r -> f.apply(r));
.map(new MergeTagsFunction<>());
}

@Override
Expand Down

0 comments on commit 1e475ec

Please sign in to comment.