In
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, a stream is a
sequence
In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is cal ...
of potentially unlimited
data element
In metadata, the term data element is an atomic unit of data that has precise meaning or precise semantics. A data element has:
# An identification such as a data element name
# A clear data element definition
# One or more representation term ...
s made available over time. A stream can be thought of as items on a
conveyor belt 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 because they have potentially unlimited data. Formally, streams are ''
codata'' (potentially unlimited), not data (which is finite).
Functions that operate on a stream producing another stream are known as
filters and can be connected in
pipelines in a manner analogous to
function composition. 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
characters. 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
Object-oriented programming (OOP) is a programming paradigm based on the concept of '' objects''. Objects can contain data (called fields, attributes or properties) and have actions they can perform (called procedures or methods and impl ...
, 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
sequence
In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is cal ...
s and
series.
SRFI 41: Streams
/ref>
* In the Smalltalk standard library and in other programming language
A programming language is a system of notation for writing computer programs.
Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
s as well, a stream is an external iterator. As in Scheme, streams can represent finite or infinite sequences.
* Stream processing
In computer science, stream processing (also known as event stream processing, data stream processing, or distributed stream processing) is a programming paradigm which views Stream (computing), streams, or sequences of events in time, as the centr ...
— in parallel processing, especially in graphic processing, the term stream is applied to hardware as well as software
Software consists of computer programs that instruct the Execution (computing), execution of a computer. Software also includes design documents and specifications.
The history of software is closely tied to the development of digital comput ...
. 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 '' forks'', 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 (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including:
* Descriptive ...
. Here "stream" is used to indicate "variable size data", as opposed to fixed size metadata such as extended attributes, but differs from "stream" as used otherwise, meaning "data available over time, potentially infinite".
See also
* Bitstream
* Codata
* Data stream
* Data stream mining
* Traffic flow (computer networking)
* Network socket
* Streaming algorithm
* Streaming media
Streaming media refers to multimedia delivered through a Computer network, network for playback using a Media player (disambiguation), media player. Media is transferred in a ''stream'' of Network packet, packets from a Server (computing), ...
* Stream processing
In computer science, stream processing (also known as event stream processing, data stream processing, or distributed stream processing) is a programming paradigm which views Stream (computing), streams, or sequences of events in time, as the centr ...
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