Search in sources :

Example 1 with SellerPrice

use of org.apache.beam.sdk.nexmark.model.SellerPrice in project beam by apache.

the class Query6Model method relevantResults.

@Override
protected Iterable<TimestampedValue<SellerPrice>> relevantResults(Iterable<TimestampedValue<SellerPrice>> results) {
    // Find the last (in processing time) reported average price for each seller.
    Map<Long, TimestampedValue<SellerPrice>> finalAverages = new TreeMap<>();
    for (TimestampedValue<SellerPrice> obj : results) {
        Assert.assertTrue("have SellerPrice", obj.getValue() instanceof SellerPrice);
        SellerPrice sellerPrice = (SellerPrice) obj.getValue();
        finalAverages.put(sellerPrice.seller, TimestampedValue.of(sellerPrice, obj.getTimestamp()));
    }
    return finalAverages.values();
}
Also used : TimestampedValue(org.apache.beam.sdk.values.TimestampedValue) TreeMap(java.util.TreeMap) SellerPrice(org.apache.beam.sdk.nexmark.model.SellerPrice)

Aggregations

TreeMap (java.util.TreeMap)1 SellerPrice (org.apache.beam.sdk.nexmark.model.SellerPrice)1 TimestampedValue (org.apache.beam.sdk.values.TimestampedValue)1