public final class ExternalRecordSource extends ExecutableOperator implements RecordSourceOperator
LogicalGraphInstance#start()
. For example:
//create the graphLogicalGraph
graph= LogicalGraphFactory.newLogicalGraph(); //the type of the sourceRecordTokenType
type= record( TokenTypeConstant.DOUBLE("field1"), TokenTypeConstant.DOUBLE("field2")); //create the external source, adding to the graph ExternalRecordSource source= graph.add
(new ExternalRecordSource(type)); //add some other operator op= graph.add(...); //connect source to another operator in the graph graph.connect
(source.getInput(),op.getInput()); //compile the graphLogicalGraphInstance
instance= graph.compile
(); //*always* call start to start in background, not run since run will deadlock!! instance.start
(); //produce some data in this threadRecordOutput
rout= source.getInput(); while (...) { ... rout.push(); } //push end of data rout.pushEndOfData
(); //after calling pushEndOfData, join on the graph //don't join before since it will deadlock! instance.join
();
NOTE: this operator is non-parallel
Constructor and Description |
---|
ExternalRecordSource()
Default constructor; prior to graph compilation
setOutputType(RecordTokenType)
must be specified. |
ExternalRecordSource(RecordTokenType outputType)
Creates a new record source of the given type.
|
Modifier and Type | Method and Description |
---|---|
protected ExecutableOperator |
cloneForExecution()
Performs a deep copy of the operator for execution.
|
protected void |
computeMetadata(StreamingMetadataContext ctx)
Implementations must adhere to the following contracts
|
protected void |
execute(ExecutionContext ctx)
Executes the operator.
|
RecordOutput |
getInput()
Returns the external port that an external application can use to send
data to this sink.
|
RecordPort |
getOutput()
Gets the record port providing the output data from the source.
|
RecordTokenType |
getOutputType()
Returns the output record type of this sink
|
protected void |
notifyError(Throwable e)
Called to notify the operator that the graph terminated abnormally
either before the operator had a chance to run or while the operator
is running.
|
void |
setOutputType(RecordTokenType outputType)
Sets the output record type of this sink
|
getNumInputCopies, getPortSettings, handleInactiveOutput
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disableParallelism, getInputPorts, getOutputPorts
public ExternalRecordSource()
setOutputType(RecordTokenType)
must be specified.public ExternalRecordSource(RecordTokenType outputType)
outputType
- the record type of the sourcepublic RecordOutput getInput()
public RecordPort getOutput()
RecordSourceOperator
getOutput
in interface RecordSourceOperator
getOutput
in interface SourceOperator<RecordPort>
public RecordTokenType getOutputType()
public void setOutputType(RecordTokenType outputType)
outputType
- the output record type of this sinkprotected void computeMetadata(StreamingMetadataContext ctx)
StreamingOperator
StreamingMetadataContext.parallelize(ParallelismStrategy)
.
RecordPort#setRequiredDataOrdering
, otherwise data may arrive in any order.
RecordPort#setRequiredDataDistribution
, otherwise data will arrive in an unspecified partial distribution
.
RecordPort#getSourceDataDistribution
and RecordPort#getSourceDataOrdering
. These should be
viewed as a hints to help chose a more efficient algorithm. In such cases, though, operators must
still declare data ordering and data distribution requirements; otherwise there is no guarantee that
data will arrive sorted/distributed as required.
RecordPort#setType
.RecordPort#setOutputDataOrdering
RecordPort#setOutputDataDistribution
AbstractModelPort#setMergeHandler
.MergeModel
is a convenient, re-usable model reducer, parameterized with
a merge-handler.
SimpleModelPort
's have no associated metadata and therefore there is
never any output metadata to declare. PMMLPort
's, on the other hand,
do have associated metadata. For all PMMLPorts, implementations must declare
the following:
PMMLPort.setPMMLModelSpec
.
computeMetadata
in class StreamingOperator
ctx
- the contextprotected void notifyError(Throwable e)
AbstractLogicalOperator
CompositeOperator
, this method will
be invoked if any of the componentsnotifyError
in class AbstractLogicalOperator
e
- the error that occuredprotected ExecutableOperator cloneForExecution()
ExecutableOperator
cloneForExecution
in class ExecutableOperator
protected void execute(ExecutionContext ctx)
ExecutableOperator
execute
in class ExecutableOperator
ctx
- context in which to lookup physical ports bound to logical portsCopyright © 2021 Actian Corporation. All rights reserved.