SMILA (incubation) API documentation

org.eclipse.smila.taskworker.input
Class Inputs

java.lang.Object
  extended by org.eclipse.smila.taskworker.io.IODataObjects
      extended by org.eclipse.smila.taskworker.input.Inputs

public class Inputs
extends IODataObjects

Returned by TaskContext.getInputs() this class provides access to the data objects associated by a task to the input slots of a worker. It can create different kinds of Input wrappers on these data objects that make access for the workers easier. You can create only a single input wrapper for each data object. On the second call, only null will be returned.

See Also:
StreamInput, RecordInput, KvoInput

Constructor Summary
Inputs(java.util.Map<java.lang.String,java.util.List<BulkInfo>> dataObjects, ObjectStoreService objectStore)
          create instance.
 
Method Summary
 void addInputCounters(java.util.Map<java.lang.String,java.lang.Number> counters)
          aggregate counters of input slots.
 void closeAll()
          close all input wrapper objects.
<T extends Input>
T
getAsInput(java.lang.String slotName, java.lang.Class<T> inputClass)
          Generic method to create input wrapper for the first data object in a slot.
<T extends Input>
T
getAsInput(java.lang.String slotName, int index, java.lang.Class<T> inputClass)
          Generic method to create input wrappers.
 RecordInput getAsRecordInput(java.lang.String slotName)
           
 RecordInput getAsRecordInput(java.lang.String slotName, int index)
           
 StreamInput getAsStreamInput(java.lang.String slotName)
           
 StreamInput getAsStreamInput(java.lang.String slotName, int index)
           
 
Methods inherited from class org.eclipse.smila.taskworker.io.IODataObjects
addCounters, canCreate, getDataObject, getDataObject, getDataObjectCount, getIOData, getObjectStore, putIOData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Inputs

public Inputs(java.util.Map<java.lang.String,java.util.List<BulkInfo>> dataObjects,
              ObjectStoreService objectStore)
create instance.

Method Detail

getAsInput

public <T extends Input> T getAsInput(java.lang.String slotName,
                                      java.lang.Class<T> inputClass)
Generic method to create input wrapper for the first data object in a slot. See getAsInput(String, int, Class) for details, this method just calls this method with index = 0

Returns:
first data object in given slot prepared for custom access. Null, if slot is not set, or an input wrapper has already been created earlier.
Throws:
java.lang.IllegalArgumentException - if the inputClass cannot be instantiated.

getAsInput

public <T extends Input> T getAsInput(java.lang.String slotName,
                                      int index,
                                      java.lang.Class<T> inputClass)
Generic method to create input wrappers. Any predefined subclass of Input can be used as well as custom defined class if you need it (be sure to implement the necessary constructor). For example, to get an Key-Value-Object wrapper for the first object in slot "kvoInputSlot", use KVOInput kvo = taskContext.getInputs().getAsInput("kvoInputSlot", KVOInput.class);

Returns:
n-th data object in given slot prepared for custom access. Null, if slot is not set, has less objects, or a wrapper has already been created earlier.
Throws:
java.lang.IllegalArgumentException - if the inputClass cannot be instantiated.
See Also:
StreamInput, RecordInput, KvoInput

getAsStreamInput

public StreamInput getAsStreamInput(java.lang.String slotName)
Returns:
first data object in given slot prepared for stream access. Null, if slot is not set, or a wrapper has already been created earlier.

getAsStreamInput

public StreamInput getAsStreamInput(java.lang.String slotName,
                                    int index)
Returns:
n-th data object in given slot prepared for stream access. Null, if slot is not set, has less objects, or a wrapper has already been created earlier.

getAsRecordInput

public RecordInput getAsRecordInput(java.lang.String slotName)
Returns:
first data object in given slot prepared for record access. Null, if slot is not set,or a wrapper has already been created earlier.

getAsRecordInput

public RecordInput getAsRecordInput(java.lang.String slotName,
                                    int index)
Returns:
n-th data object in given slot prepared for record access. Null, if slot is not set, has less objects, or a wrapper has already been created earlier.

closeAll

public void closeAll()
close all input wrapper objects. Called by the WorkerManager after the task has been finished.


addInputCounters

public void addInputCounters(java.util.Map<java.lang.String,java.lang.Number> counters)
aggregate counters of input slots. Called by the WorkerManager after the task has been finished.


SMILA (incubation) API documentation