I'm teaching a theory-focused randomized algorithms course at the undergraduate level, and have included a section on streaming algorithms. It would be great to get students to implement these algorithms, but I do not know how to simulate a data stream for them. I am aware that some companies have APIs with varying degrees of openness (e.g. Twitter), and I'm aware of big things like IBM InfoSphere Streams, but this seems too hard, since the course is mostly focused on theory. Ideally, I'd like something that continuously produces a stream of numbers or words, and have students write Python code to access the stream, then compute on the sample they take. Are there any freely available tools of this sort? Even, like, a free toy version of IBM InfoSphere Streams?
Java has a Streams API that works with all of its collections. You create a stream with a source, transform or filter it with intermediate operations, and do something with it using a Consumer.
All Collections in Java have a .stream() method that creates a stream from the collection. You can also create streams from files, as well as creating streams of random objects from a Random.
Intermediate operations include filter, which accepts a Predicate as an argument, and map and friends that can transform objects into objects of other types or primitives.
Consumers include facilities to place the contents of a Stream into any Collection, System.out::println, and other pure side-effect operations.
This requires an understanding of lambdas and functional interfaces (our second-trimester course in Java covers these). This mechanism is powerful and succinct, and it does not alter the collection the stream is attached to.