Search in sources :

Example 1 with SpillableSessionWindowedStorage

use of org.apache.apex.malhar.lib.window.impl.SpillableSessionWindowedStorage in project apex-malhar by apache.

the class WindowedOperatorTest method createDefaultKeyedWindowedOperator.

private KeyedWindowedOperatorImpl<String, Long, MutableLong, Long> createDefaultKeyedWindowedOperator(boolean forSession) {
    KeyedWindowedOperatorImpl<String, Long, MutableLong, Long> windowedOperator = new KeyedWindowedOperatorImpl<>();
    if (useSpillable) {
        sccImpl = new SpillableComplexComponentImpl(testMeta.timeStore);
        // TODO: We don't yet support Spillable data structures for window state storage because SpillableMapImpl does not yet support iterating over all keys.
        windowStateStorage = new InMemoryWindowedStorage<>();
        if (forSession) {
            SpillableSessionWindowedStorage<String, MutableLong> sws = new SpillableSessionWindowedStorage<>();
            sws.setSpillableComplexComponent(sccImpl);
            keyedDataStorage = sws;
        } else {
            SpillableWindowedKeyedStorage<String, MutableLong> kds = new SpillableWindowedKeyedStorage<>();
            kds.setSpillableComplexComponent(sccImpl);
            keyedDataStorage = kds;
        }
        SpillableWindowedKeyedStorage<String, Long> krs = new SpillableWindowedKeyedStorage<>();
        krs.setSpillableComplexComponent(sccImpl);
        keyedRetractionStorage = krs;
        windowedOperator.addComponent("SpillableComplexComponent", sccImpl);
    } else {
        windowStateStorage = new InMemoryWindowedStorage<>();
        if (forSession) {
            keyedDataStorage = new InMemorySessionWindowedStorage<>();
        } else {
            keyedDataStorage = new InMemoryWindowedKeyedStorage<>();
        }
        keyedRetractionStorage = new InMemoryWindowedKeyedStorage<>();
    }
    windowedOperator.setDataStorage(keyedDataStorage);
    windowedOperator.setRetractionStorage(keyedRetractionStorage);
    windowedOperator.setWindowStateStorage(windowStateStorage);
    windowedOperator.setAccumulation(new SumAccumulation());
    return windowedOperator;
}
Also used : SpillableSessionWindowedStorage(org.apache.apex.malhar.lib.window.impl.SpillableSessionWindowedStorage) SpillableWindowedKeyedStorage(org.apache.apex.malhar.lib.window.impl.SpillableWindowedKeyedStorage) KeyedWindowedOperatorImpl(org.apache.apex.malhar.lib.window.impl.KeyedWindowedOperatorImpl) MutableLong(org.apache.commons.lang3.mutable.MutableLong) MutableLong(org.apache.commons.lang3.mutable.MutableLong) SpillableComplexComponentImpl(org.apache.apex.malhar.lib.state.spillable.SpillableComplexComponentImpl)

Aggregations

SpillableComplexComponentImpl (org.apache.apex.malhar.lib.state.spillable.SpillableComplexComponentImpl)1 KeyedWindowedOperatorImpl (org.apache.apex.malhar.lib.window.impl.KeyedWindowedOperatorImpl)1 SpillableSessionWindowedStorage (org.apache.apex.malhar.lib.window.impl.SpillableSessionWindowedStorage)1 SpillableWindowedKeyedStorage (org.apache.apex.malhar.lib.window.impl.SpillableWindowedKeyedStorage)1 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1