public class Rank extends AbstractExecutableRecordPipeline
Three different rank modes are supported:
A new output field is created to contain the result of the ranking. The field
is named "rank" by default. The name of the rank field can be set using
setOutputField(String)
.
Modifier and Type | Class and Description |
---|---|
static class |
Rank.RankMode
Definition of the supported rank modes.
|
input, output
Constructor and Description |
---|
Rank()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeMetadata(StreamingMetadataContext ctx)
Implementations must adhere to the following contracts
|
protected void |
execute(ExecutionContext ctx)
Executes the operator.
|
RecordPort |
getInput()
Gets the record port providing the input data to the operation.
|
Rank.RankMode |
getMode()
Get the mode used for ranking.
|
RecordPort |
getOutput()
Gets the record port providing the output from the operation.
|
String |
getOutputField()
Get the name of the output ranking field.
|
List<String> |
getPartitionBy()
Get the list of fields used to partition the input data.
|
List<SortKey> |
getRankBy()
Get the list of fields used for ranking within each partition.
|
void |
setMode(Rank.RankMode mode)
Set the ranking mode.
|
void |
setOutputField(String outputField)
Set the name of the output field that will contain the ranking
order for each record.
|
void |
setPartitionBy(List<String> partitionKeys)
Set the fields used for partitioning the input data.
|
void |
setPartitionBy(String... partitionKeys)
Set the fields used for partitioning the input data.
|
void |
setRankBy(List<SortKey> rankBy)
Set the list of fields to use for ranking.
|
void |
setRankBy(SortKey... rankBy)
Set the list of fields to use for ranking.
|
void |
setRankBy(String... rankBy)
Set the list of fields to use for ranking.
|
cloneForExecution, getNumInputCopies, getPortSettings, handleInactiveOutput
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disableParallelism, getInputPorts, getOutputPorts
public Rank()
public RecordPort getInput()
AbstractExecutableRecordPipeline
getInput
in interface PipelineOperator<RecordPort>
getInput
in class AbstractExecutableRecordPipeline
public RecordPort getOutput()
AbstractExecutableRecordPipeline
getOutput
in interface PipelineOperator<RecordPort>
getOutput
in class AbstractExecutableRecordPipeline
public void setPartitionBy(List<String> partitionKeys)
partitionKeys
- list of fields to use for partitioningpublic void setPartitionBy(String... partitionKeys)
partitionKeys
- list of fields to use for partitioningpublic List<String> getPartitionBy()
public void setRankBy(SortKey... rankBy)
rankBy
- list of fields used to rank the datapublic void setRankBy(String... rankBy)
rankBy
- list of fields used to rank the data along with sort orderpublic void setRankBy(List<SortKey> rankBy)
rankBy
- list of fields used to rank the datapublic List<SortKey> getRankBy()
public void setMode(Rank.RankMode mode)
mode
- rank modepublic Rank.RankMode getMode()
public void setOutputField(String outputField)
outputField
- name of the ranking results fieldpublic String getOutputField()
protected 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 execute(ExecutionContext ctx)
ExecutableOperator
execute
in class ExecutableOperator
ctx
- context in which to lookup physical ports bound to logical portsCopyright © 2016 Actian Corporation. All rights reserved.