@Override public void accept(Partition<T, K, L> partition, T tuple) { if(!initialized_partitions.contains(partition)){ initialized_partitions.add(partition); ScheduledExecutorService ses = partition.getWindow().getScheduledExecutorService(); ses.schedule(() -> partition.evict(), time, unit); } } };
@Override public void accept(T tuple) { window.insert(tuple); }
public Aggregate(Window<T,K, ? extends List<T>> window, BiFunction<List<T>,K, U> aggregator){ this.aggregator = aggregator; BiConsumer<List<T>, K> partProcessor = (tuples, key) -> { U aggregateTuple = aggregator.apply(tuples, key); if (aggregateTuple != null) submit(aggregateTuple); }; window.registerPartitionProcessor(partProcessor); this.window=window; }
@Override public synchronized boolean insert(T tuple) { if (getWindow().getInsertionPolicy().apply(this, tuple)) { getWindow().getContentsPolicy().accept(this, tuple); this.tuples.add(tuple); // Trigger getWindow().getTriggerPolicy().accept(this, tuple); return true; } return true; }
() -> new ArrayList<Integer>()); window.registerPartitionProcessor(new BiConsumer<List<Integer>, Integer>() { @Override public void accept(List<Integer> t, Integer u) { window.registerScheduledExecutorService(new ScheduledThreadPoolExecutor(5)); window.insert(1); }, 0, 10, TimeUnit.MILLISECONDS);
if(initialized.get(0).booleanValue() == false){ initialized.set(0, true); ScheduledExecutorService ses = partition.getWindow().getScheduledExecutorService(); ses.scheduleAtFixedRate(() -> {partition.process();}, 0, 1000, TimeUnit.MILLISECONDS); }}, () -> new InsertionTimeList<Long>()); window.registerPartitionProcessor((tuples, key) -> { if(tuples.size() > 1) diffs.add(tuples.get(tuples.size()-1) - tuples.get(0)); }); window.registerScheduledExecutorService(new ScheduledThreadPoolExecutor(5));
incrementalWindowStates.addLast(new LinkedList<Integer>(tuples)); }; window.registerPartitionProcessor(wp); window.insert(i);
() -> new ArrayList<Integer>()); window.registerPartitionProcessor(new BiConsumer<List<Integer>, Integer>() { @Override public void accept(List<Integer> t, Integer u) { window.registerScheduledExecutorService(new ScheduledThreadPoolExecutor(5));
@Override public void initialize(OpletContext<T,U> context) { super.initialize(context); window.registerScheduledExecutorService(this.getOpletContext().getService(ScheduledExecutorService.class)); }
@Override public <J, U, K> TStream<J> joinLast(Function<T, K> keyer, TStream<U> lastStream, Function<U, K> lastStreamKeyer, BiFunction<T, U, J> joiner) { BiFunction<List<U>,K, Object> processor = Functions.synchronizedBiFunction((list, key) -> null); Window<U, K, LinkedList<U>> window = Windows.lastNProcessOnInsert(1, lastStreamKeyer); Aggregate<U,Object,K> op = new Aggregate<U,Object,K>(window, processor); lastStream.pipe(op); return this.map((tuple) -> { Partition<U, K, ? extends List<U>> part = window.getPartitions().get(keyer.apply(tuple)); if(part == null) return null; J ret; synchronized (part) { U last = part.getContents().get(0); ret = joiner.apply(tuple, last); } return ret; }); }
@Override public synchronized void evict() { Consumer<Partition<T, K, L>> evictDeterminer = window.getEvictDeterminer(); evictDeterminer.accept(this); } }
@Override public synchronized void process() { window.getPartitionProcessor().accept(unmodifiableTuples, key); }
() -> new ArrayList<Integer>()); window.registerPartitionProcessor(new BiConsumer<List<Integer>, Integer>() { @Override public void accept(List<Integer> t, Integer u) { window.registerScheduledExecutorService(new ScheduledThreadPoolExecutor(5)); window.insert(i); }, 0, 1, TimeUnit.MILLISECONDS);
incrementalWindowStates.addLast(new LinkedList<Integer>(tuples)); }; window.registerPartitionProcessor(wp); window.insert(i);
@Override public synchronized boolean insert(T tuple) { if (getWindow().getInsertionPolicy().apply(this, tuple)) { getWindow().getContentsPolicy().accept(this, tuple); this.tuples.add(tuple); // Trigger getWindow().getTriggerPolicy().accept(this, tuple); return true; } return true; }
@Override public void initialize(OpletContext<T,U> context) { super.initialize(context); window.registerScheduledExecutorService(this.getOpletContext().getService(ScheduledExecutorService.class)); }
@Override public <J, U, K> TStream<J> joinLast(Function<T, K> keyer, TStream<U> lastStream, Function<U, K> lastStreamKeyer, BiFunction<T, U, J> joiner) { BiFunction<List<U>,K, Object> processor = Functions.synchronizedBiFunction((list, key) -> null); Window<U, K, LinkedList<U>> window = Windows.lastNProcessOnInsert(1, lastStreamKeyer); Aggregate<U,Object,K> op = new Aggregate<U,Object,K>(window, processor); lastStream.pipe(op); return this.map((tuple) -> { Partition<U, K, ? extends List<U>> part = window.getPartitions().get(keyer.apply(tuple)); if(part == null) return null; J ret; synchronized (part) { U last = part.getContents().get(0); ret = joiner.apply(tuple, last); } return ret; }); }
@Override public synchronized void evict() { Consumer<Partition<T, K, L>> evictDeterminer = window.getEvictDeterminer(); evictDeterminer.accept(this); } }
@Override public synchronized void process() { window.getPartitionProcessor().accept(unmodifiableTuples, key); }
incrementalWindowStates.addLast(new LinkedList<Integer>(tuples)); }; window.registerPartitionProcessor(wp); window.insert(i);