Skip to content

Instantly share code, notes, and snippets.

View ddebrunner's full-sized avatar

Dan Debrunner ddebrunner

View GitHub Profile
@ddebrunner
ddebrunner / CascadeWindows.java
Created March 5, 2019 21:17
Cascading windows in Apache Beam.
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Random;
import java.util.function.Supplier;
@ddebrunner
ddebrunner / sse.py
Last active April 22, 2019 23:41
Server-sent events as a IBM Streams topology source.
from streamsx.topology.topology import Topology
import streamsx.topology.context
from sseclient import SSEClient
class SSEReader(object):
"""
Read Server-sent events.
Includes checkpointing/consistent region support
so that recovery from a checkpoint starts at the last
@ddebrunner
ddebrunner / fibs.py
Created April 23, 2019 17:13
Use of functools.lru_cache in an IBM Streams Python topology.
from functools import lru_cache
# Example taken from: https://docs.python.org/3/library/functools.html#functools.lru_cache
#
# With this example the cache will be Python VM wide, thus if
# multiple map(fibs.fib) were invoked in the topology they
# wouldbe sharing the same cache.
@lru_cache()
def fib(n):
@ddebrunner
ddebrunner / @lru_cache metrics.png
Last active April 23, 2019 19:15
Use of functools.lru_cache with Streams metrics in an IBM Streams Python topology.
@lru_cache metrics.png