Although Pipe does not have any "abstract methods", in order to use a Pipe subclass you must override either the {@link pipe} method or the {@link newIteratorFrom} method.The former is appropriate when the pipe's processing of an Instance is strictly one-to-one. For every Instance coming in, there is exactly one Instance coming out. The later is appropriate when the pipe's processing may result in more or fewer Instances than arrive through its source iterator.
A pipe operates on an {@link cc.mallet.types.Instance}, which is a carrier of data. A pipe reads from and writes to fields in the Instance when it is requested to process the instance. It is up to the pipe which fields in the Instance it reads from and writes to, but usually a pipe will read its input from and write its output to the "data" field of an instance.
A pipe doesn't have any direct notion of input or output - it merely modifies instances that are handed to it. A set of helper classes, which implement the interface {@link Iterator A pipe is frequently used in conjunction with an {@link cc.mallet.types.InstanceList} As instances are addedto the list, they are processed by the pipe associated with the instance list and the processed Instance is kept in the list. In one common usage, a {@link cc.mallet.pipe.iterator.FileIterator} is given a list of directories to operate over.The FileIterator walks through each directory, creating an instance for each file and putting the data from the file in the data field of the instance. The directory of the file is stored in the target field of the instance. The FileIterator feeds instances to an InstanceList, which processes the instances through its associated pipe and keeps the results. Pipes can be hierachically composed. In a typical usage, a SerialPipe is created, which holds other pipes in an ordered list. Piping an instance through a SerialPipe means piping the instance through each of the child pipes in sequence. A pipe holds two separate Alphabets: one for the symbols (feature names) encountered in the data fields of the instances processed through the pipe, and one for the symbols (e.g. class labels) encountered in the target fields.
@author Andrew McCallum mccallum@cs.umass.edu
Note that access to such resource often needs to be synchronized, since multiple copies of pipelines may execute concurrently.
If such information is read-only, it can be stored as instance variables of a pipe, and its reference copied as pipes get copied. (The only difference between this and per-thread state is that you just won't allocate new things when pipes get copied here.)
static is always there for you to use.
JAX-WS has a notion of {@link LogicalHandler} and {@link SOAPHandler}, and we intend to have one {@link Pipe} implementation that invokes all the{@link LogicalHandler}s and another {@link Pipe} implementation that invokesall the {@link SOAPHandler}s. Those implementations need to convert a {@link Message}into an appropriate format, but grouping all the handlers together eliminates the intermediate {@link Message} instanciation between such handlers.
This grouping also allows such implementations to follow the event notifications to handlers (i.e. {@link Handler#close(MessageContext)} method.
TODO: Possible types of pipe: creator: create message from wire to SAAJ SOAP message to cached representation directly to JAXB beans transformer: transform message from one representation to another JAXB beans to encoded SOAP message StAX writing + JAXB bean to encoded SOAP message modifier: modify message add SOAP header blocks security processing header block processor: process certain SOAP header blocks outbound initiator: input from the client Manage input e.g. JAXB beans and associated with parts of the SOAP message inbound invoker: invoke the service Inkoke SEI, e.g. EJB or SEI in servlet.@see AbstractPipeImpl @see AbstractFilterPipeImpl @deprecated Use {@link Tube}.
Note that access to such resource often needs to be synchronized, since multiple copies of pipelines may execute concurrently.
If such information is read-only, it can be stored as instance variables of a pipe, and its reference copied as pipes get copied. (The only difference between this and per-thread state is that you just won't allocate new things when pipes get copied here.)
static is always there for you to use.
JAX-WS has a notion of {@link LogicalHandler} and {@link SOAPHandler}, and we intend to have one {@link Pipe} implementation that invokes all the{@link LogicalHandler}s and another {@link Pipe} implementation that invokesall the {@link SOAPHandler}s. Those implementations need to convert a {@link Message}into an appropriate format, but grouping all the handlers together eliminates the intermediate {@link Message} instanciation between such handlers.
This grouping also allows such implementations to follow the event notifications to handlers (i.e. {@link Handler#close(MessageContext)} method.
TODO: Possible types of pipe: creator: create message from wire to SAAJ SOAP message to cached representation directly to JAXB beans transformer: transform message from one representation to another JAXB beans to encoded SOAP message StAX writing + JAXB bean to encoded SOAP message modifier: modify message add SOAP header blocks security processing header block processor: process certain SOAP header blocks outbound initiator: input from the client Manage input e.g. JAXB beans and associated with parts of the SOAP message inbound invoker: invoke the service Inkoke SEI, e.g. EJB or SEI in servlet.@see AbstractPipeImpl @see AbstractFilterPipeImpl @deprecated Use {@link Tube}.
final Pipe p = Pipe.createLocalToRemote(); channel.callAsync(new Callable() { public Object call() { InputStream in = p.getIn(); ... read from in ... } }); OutputStream out = p.getOut(); ... write to out ...
A pipe consists of a pair of channels: A writable {@link Pipe.SinkChannel sink} channel and a readable {@link Pipe.SourceChannel source}channel. Once some bytes are written to the sink channel they can be read from source channel in exactlyAthe order in which they were written.
Whether or not a thread writing bytes to a pipe will block until another thread reads those bytes, or some previously-written bytes, from the pipe is system-dependent and therefore unspecified. Many pipe implementations will buffer up to a certain number of bytes between the sink and source channels, but such buffering should not be assumed.
@author Mark Reinhold @author JSR-51 Expert Group @since 1.4详细文档,请见 {@link WindowContainer} @author 王志亮 [qieqie.wang@gmail.com]
You can use the same Pipe-object for both ends of a process-pipeline. But you cannot use the same Pipe-object as an OutputConsumer and ErrorConsumer at the same time.
@version $Revision: 1.8 $ @author $Author: bablokb $ @since 0.95
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|