Cell vs Cell.Stream

All other topics related to TunedIT, data mining, machine learning, research, applications, ...

Cell vs Cell.Stream

Postby sebov » Fri Oct 16, 2009 5:58 pm

My another question is about the difference between the two mentioned in the subject. What is the purpose of the Stream class?
As I can see the Cell object and its output Stream are tightly connected - in such a sense that both have next(), close() methods (and Cell's methods invoke Stream methods).

What is the proper way of using them? E.g. on the http://www.mimuw.edu.pl/%7Emwojnars/debellor/example.html page one can see usage of next(), close() on the Cell object. But internally (in the source code of RseslibClassifier) you are using the Stream object. Is that the main difference that externally should I use Cell's methods and internally (e.g. while implementing a Cell's subclass) Cell.Stream's methods?


Sebastian
sebov
 
Posts: 5
Joined: Fri Oct 09, 2009 6:45 pm

Re: Cell vs Cell.Stream

Postby Marcin » Fri Oct 16, 2009 6:31 pm

Sebastian,

sebov wrote:What is the purpose of the Stream class?

Stream class encapsulates communication between two cells. In this way, the receiving cell doesn't need direct access to the source cell (Cell.source is a private field), which increases safety - when you implement a Cell subclass there's no way to make any illegal operation on the source cell.
Stream class is also a preparation for multi-input/multi-output cells that are planned in the future - with Stream object in hand, the receiving cell doesn't have to know from which output the stream is generated. The index of the output will be encapsulated in the Stream instance.

sebov wrote:As I can see the Cell object and its output Stream are tightly connected - in such a sense that both have next(), close() methods (and Cell's methods invoke Stream methods). What is the proper way of using them?

Methods in Cell are shorthands for corresponding methods in Stream. For example:
Code: Select all
cell.open();
cell.next();

is equivalent to:
Code: Select all
Stream stream = cell.open();
stream.next();

so you have one object less to care about.
Internally (in Cell subclass) you have no choice but to use Stream.* methods, because you don't have direct access to the source cell. Externally you can choose whichever approach you prefer.
-Marcin
Marcin
 
Posts: 115
Joined: Fri Oct 09, 2009 6:45 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron