-
Notifications
You must be signed in to change notification settings - Fork 15
Home
Mahmoud Ben Hassine edited this page Oct 7, 2015
·
13 revisions
XStream (uniX Stream) is an extension of the Java 8 Stream API to process data pipelines the Unix way. It provides a set of components that mimic most of Unix processing commands.
- 100% compatibles with Java 8 Streams
- Intuitive, flexible and extensible API
- A toolbox of reusable data-science components
- No dependencies
- Free and open source
You can use XSteam in two ways:
Stream<String> stream = Stream.of("foo", "bar", "bar", "baz");
XStream.unixify(stream)
.grep("a")
.sort()
.uniq()
.nl()
.to(stdOut());
// prints:
// 1 bar
// 2 baz
// cat input.txt | grep a | sort | uniq | nl > output.txt
XStream.cat("input.txt")
.pipe(grep("a"))
.pipe(sort())
.pipe(uniq())
.pipe(nl())
.to(file("output.txt"));
XStream provides a toolbox of reusable components that mimic Unix's text utilities (and more). Components are inspired by the Unix philosophy and are intended to be:
- Small
- Portable
- Do one thing and do it well
- Side-effect free
You will find in this wiki a complete reference of all built-in components (see sidebar).
The Stage
interface represents a stage of the pipeline:
public interface Stage<I,O> {
Stream<O> apply(Stream<I> input);
}
All built-in components are implemented as filters/transformers through this interface. You can implement this interface to contribute your own your components.
UnixStream is created with passion by Mahmoud Ben Hassine