com.kolibrifx.plovercrest.server.folds.FoldCombinators Maven / Gradle / Ivy
Show all versions of plovercrest-server Show documentation
/*
* Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
*/
package com.kolibrifx.plovercrest.server.folds;
import com.kolibrifx.plovercrest.server.streams.folds.HistoricalCombinatorStrategy;
import com.kolibrifx.plovercrest.server.streams.folds.LiveCombinatorStrategy;
public final class FoldCombinators {
private FoldCombinators() {
}
/**
* Returns a {@link FoldCombinator} suited for live data. It will produce new combinations as
* long as any of the inputs are updated. A live combinator should not be active when importing
* historical data to one of its input tables.
*
* This combinator will repeatedly pick the earliest timestamp from each input feed to produce
* combinations. It will keep producing combinations until all of the inputs have run out
* of data.
*
* For instance, given two input tables A and B with the following timestamps:
*
* - A: 10, 30
* - B: 20, 40
*
*
* Will produce the following combinations:
*
* - (A:10, B:20)
* - (A:30, B:20)
* - (A:30, B:40)
*
*
* If input A now receives two new elements with timestamps 35 and 45, the next
* combinations are:
*
* - (A:35, B:40)
*
- (A:45, B:40)
*
*/
public static FoldCombinator live() {
return new LiveCombinatorStrategy();
}
/**
* Returns a {@link FoldCombinator} suited for historical data. This guarantees that the fold
* receives all timestamps in order across tables, at the cost of potential delays when one or
* more of the inputs run out of data.
*
* This combinator will repeatedly pick the earliest timestamp from each input feed to produce
* combinations. As soon as one of the inputs run out of elements, it will stop producing
* combinations.
*
* For instance, given two input tables A and B with the following timestamps:
*
* - A: 10, 30
* - B: 20, 40
*
*
* Will produce the following combinations:
*
* - (A:10, B:20)
* - (A:30, B:20)
*
*
* The combination (A:30, B:40) is not generated (yet) since this can break the timestamp
* order guarantee. If input A now receives two new elements with timestamps 35 and 45,
* the next combinations are:
*
* - (A:35, B:20)
*
- (A:35, B:40)
*
*/
public static FoldCombinator historical() {
return new HistoricalCombinatorStrategy();
}
}