An instance contains four generic fields of predefined name: "data", "target", "name", and "source". "Data" holds the data represented `by the instance, "target" is often a label associated with the instance, "name" is a short identifying name for the instance (such as a filename), and "source" is human-readable sourceinformation, (such as the original text).
Each field has no predefined type, and may change type as the instance is processed. For example, the data field may start off being a string that represents a file name and then be processed by a {@link cc.mallet.pipe.Pipe} into a CharSequencerepresenting the contents of the file, and eventually to a feature vector holding indices into an {@link cc.mallet.types.Alphabet} holding words found in the file.It is up to each pipe which fields in the Instance it modifies; the most common case is that the pipe modifies the data field.
Generally speaking, there are two modes of operation for Instances. (1) An instance gets created and passed through a Pipe, and the resulting data/target/name/source fields are used. This is generally done for training instances. (2) An instance gets created with raw values in its slots, then different users of the instance call newPipedCopy() with their respective different pipes. This might be done for test instances at "performance" time.
Rather than store an {@link cc.mallet.types.Alphabet} in the Instance,we obtain it through the Pipe instance variable, because the Pipe also indicates where the data came from and how to interpret the Alphabet.
Instances can be made immutable if locked. Although unlocked Instances are mutable, typically the only code that changes the values in the four slots is inside Pipes.
Note that constructing an instance with a pipe argument means "Construct the instance and then run it through the pipe". {@link cc.mallet.types.InstanceList} uses this methodwhen adding instances through a pipeInputIterator. @see Pipe @see Alphabet @see InstanceList @author Andrew McCallum mccallum@cs.umass.edu
The Instance
data type.
Represents an Amazon EC2 instance.
Allows the application to dynamically obtain instances of beans with a specified combination of required type and qualifiers.
In certain situations, injection is not the most convenient way to obtain a contextual reference. For example, it may not be used when:
In these situations, an instance of the Instance may be injected:
@Inject Instance<PaymentProcessor> paymentProcessor;
Any combination of qualifiers may be specified at the injection point:
@Inject @PayBy(CHEQUE) Instance<PaymentProcessor> chequePaymentProcessor;
Or, the {@link javax.enterprise.inject.Any @Any} qualifier may be used, allowing the application to specify qualifiersdynamically:
@Inject @Any Instance<PaymentProcessor> anyPaymentProcessor;
Finally, the {@link javax.enterprise.inject.New @New} qualifier may be used, allowing the application to obtain a{@link javax.enterprise.inject.New @New} qualified bean:
@Inject @New(ChequePaymentProcessor.class) Instance<PaymentProcessor> chequePaymentProcessor;
For an injected Instance:
The inherited {@link javax.inject.Provider#get()} method returns a contextual references for the unique bean that matches therequired type and required qualifiers and is eligible for injection into the class into which the parent Instance was injected, or throws an {@link javax.enterprise.inject.UnsatisfiedResolutionException} or{@link javax.enterprise.inject.AmbiguousResolutionException}.
PaymentProcessor pp = chequePaymentProcessor.get();
The inherited {@link java.lang.Iterable#iterator()} method returns an iterator over contextual references for beans thatmatch the required type and required qualifiers and are eligible for injection into the class into which the parent Instance was injected.
for (PaymentProcessor pp : anyPaymentProcessor) pp.test();@see javax.inject.Provider#get() @see java.lang.Iterable#iterator() @see javax.enterprise.util.AnnotationLiteral @see javax.enterprise.util.TypeLiteral @author Gavin King @param < T> the required bean type
The following features are supported:
Currently the only sub-interface is {@link ObjectAdapter}. However, the intention is for associations, actions and action parameters to also inherit from this interface.
All methods that change an instance are safe, ie. a change of an instance does not affect any other instances. All methods that change an instance's attribute values clone the attribute value vector before it is changed. If your application heavily modifies instance values, it may be faster to create a new instance from scratch. @author Eibe Frank (eibe@cs.waikato.ac.nz) @version $Revision: 1.25 $
All methods that change an instance are safe, ie. a change of an instance does not affect any other instances. All methods that change an instance's attribute values clone the attribute value vector before it is changed. If your application heavily modifies instance values, it may be faster to create a new instance from scratch. @author Eibe Frank (eibe@cs.waikato.ac.nz) @version $Revision: 5970 $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|