Search code examples
emit

What does "emit" mean in general computer science terms?


I just stumbled on what appears to be a generally-known compsci keyword, "emit". But I can't find any clear definition of it in general computer science terms, nor a specific definition of an "emit()" function or keyword in any specific programming language.

I found it here, reading up on MapReduce:

https://en.wikipedia.org/wiki/MapReduce

The context of my additional searches show it has something to do with signaling and/or events. But it seems like it is just assumed that the reader will know what "emit" is and does. For example, this article on MapReduce patterns:

https://highlyscalable.wordpress.com/2012/02/01/mapreduce-patterns/

There's no mention of what "emit" is actually doing, there are only calls to it. It must be different from other forms of returning data, though, such as "return" or simply "printf" or the equivalent, else the calls to "emit" would be calls to "return".

Further searching, I found a bunch of times that some pseudocode form of "emit" appears in the context of MapReduce. And in Node.js. And in Qt. But that's about it.

Context: I'm a (mostly) self-taught web programmer and system administrator. I'm sure this question is covered in compsci 101 (or 201?) but I didn't take that course.


Solution

  • I can think of three contexts in which it's used:

    • Map/Reduce functions, where some input value causes 0 or more output values to go into the Reduce function
    • Tokenizers, where a stream of text is processed, and at various intervals, tokens are emitted
    • Messaging systems

    I think the common thread is the "zero or more". A return provides exactly one value back from a function, whereas an "emit" is a function call that could take place zero times or several times.