In
computer science, a stream is a
sequence of
data elements made available over time. A stream can be thought of as items on a
conveyor belt
A conveyor belt is the carrying medium of a belt conveyor system (often shortened to belt conveyor). A belt conveyor system is one of many types of conveyor systems. A belt conveyor system consists of two or more pulleys (sometimes referred to ...
being processed one at a time rather than in large batches.
Streams are processed differently from
batch data – normal functions cannot operate on streams as a whole, as they have potentially unlimited data, and formally, streams are ''
codata
The Committee on Data of the International Science Council (CODATA) was established in 1966 as the Committee on Data for Science and Technology, originally part of the International Council of Scientific Unions, now part of the International ...
'' (potentially unlimited), not data (which is finite). Functions that operate on a stream, producing another stream, are known as
filters
Filter, filtering or filters may refer to:
Science and technology
Computing
* Filter (higher-order function), in functional programming
* Filter (software), a computer program to process a data stream
* Filter (video), a software component tha ...
, and can be connected in
pipelines, analogously to
function composition
In mathematics, function composition is an operation that takes two functions and , and produces a function such that . In this operation, the function is applied to the result of applying the function to . That is, the functions and ...
. Filters may operate on one item of a stream at a time, or may base an item of output on multiple items of input, such as a
moving average.
Examples
The term "stream" is used in a number of similar ways:
* "Stream editing", as with
sed,
awk, and
perl. Stream editing processes a file or files, in-place, without having to load the file(s) into a user interface. One example of such use is to do a search and replace on all the files in a directory, from the command line.
* On
Unix and related systems based on the
C language, a stream is a source or
sink of data, usually individual bytes or
character
Character or Characters may refer to:
Arts, entertainment, and media Literature
* ''Character'' (novel), a 1936 Dutch novel by Ferdinand Bordewijk
* ''Characters'' (Theophrastus), a classical Greek set of character sketches attributed to The ...
s. Streams are an abstraction used when reading or writing files, or communicating over
network sockets. The
standard streams are three streams made available to all programs.
* I/O devices can be interpreted as streams, as they produce or consume potentially unlimited data over time.
* In
object-oriented programming, input streams are generally implemented as
iterators.
* In the
Scheme language and some others, a stream is a
lazily evaluated or ''delayed'' sequence of data elements. A stream can be used similarly to a list, but later elements are only calculated when needed. Streams can therefore represent infinite
sequences and
series.
SRFI 41: Streams
/ref>
* In the Smalltalk
Smalltalk is an object-oriented, dynamically typed reflective programming language. It was designed and created in part for educational use, specifically for constructionist learning, at the Learning Research Group (LRG) of Xerox PARC by Alan Ka ...
standard library
In computer programming, a standard library is the library made available across implementations of a programming language. These libraries are conventionally described in programming language specifications; however, contents of a language's as ...
and in other programming languages as well, a stream is an external iterator. As in Scheme, streams can represent finite or infinite sequences.
* Stream processing — in parallel processing, especially in graphic processing, the term stream is applied to hardware as well as software. There it defines the quasi-continuous flow of data that is processed in a dataflow programming language as soon as the program state meets the starting condition of the stream.
Applications
Streams can be used as the underlying data type for channels in interprocess communication.
Other uses
The term "stream" is also applied to file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
''forks
In cutlery or kitchenware, a fork (from la, furca 'pitchfork') is a utensil, now usually made of metal, whose long handle terminates in a head that branches into several narrow and often slightly curved tines with which one can spear foods ei ...
'', where multiple sets of data are associated with a single filename. Most often, there is one main stream that makes up the normal file data, while additional streams contain metadata
Metadata is "data that provides information about other data", but not the content of the data, such as the text of a message or the image itself. There are many distinct types of metadata, including:
* Descriptive metadata – the descriptive ...
. Here "stream" is used to indicate "variable size data", as opposed to fixed size metadata such as extended attributes Extended file attributes are file system features that enable users to associate computer files with metadata not interpreted by the filesystem, whereas regular attributes have a purpose strictly defined by the filesystem (such as permissions or ...
, but differs from "stream" as used otherwise, meaning "data available over time, potentially infinite".
See also
* Bitstream
* Codata
The Committee on Data of the International Science Council (CODATA) was established in 1966 as the Committee on Data for Science and Technology, originally part of the International Council of Scientific Unions, now part of the International ...
* Data stream
* Data stream mining Data Stream Mining (also known as stream learning) is the process of extracting knowledge structures from continuous, rapid data records. A data stream is an ordered sequence of instances that in many applications of data stream mining can be read o ...
* Flow (computer networking)
In packet switching networks, traffic flow, packet flow or ''network flow'' is a sequence of packets from a source computer to a destination, which may be another host, a multicast group, or a broadcast domain. RFC 2722 defines traffic flow as "an ...
* Network socket
* Streaming algorithm
* Streaming media
Streaming media is multimedia that is delivered and consumed in a continuous manner from a source, with little or no intermediate storage in network elements. ''Streaming'' refers to the delivery method of content, rather than the content it ...
* Stream processing
References
External links
An Approximate L1-Difference Algorithm for Massive Data Streams, 1995 Feigenbaum et al.
{{Data types
Computer data
Inter-process communication
ja:ストリーム (プログラミング)
ru:Поток данных
tr:Stream