- 
- All Implemented Interfaces:
- LogicalOperator,- PipelineOperator<RecordPort>,- RecordPipelineOperator
 
 public class Rank extends AbstractExecutableRecordPipeline Rank data using the given rank mode. The data is grouped by the given partition field(s) and is sorted within the grouping by the ranking field(s). An example is to rank employees by salary per department. To rank the highest to lowest salary within department: partition by the department and rank by the salary in descending sort order.Three different rank modes are supported: - STANDARD: also known as competition ranking, items with the same ranking values have the same rank and then a gap is left in the ranking numbers; for example: 1224
- DENSE: items that compare equal receive the same ranking, items following receive the next ordinal ranking (i.e. ranks are not skipped); for example: 1223
- ORDINAL: each item receives a distinct ranking, starting at 1 and increasing by one producing essentially a row number within the partition; for example: 1234
 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).
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classRank.RankModeDefinition of the supported rank modes.
 - 
Field Summary- 
Fields inherited from class com.pervasive.datarush.operators.AbstractExecutableRecordPipelineinput, output
 
- 
 - 
Constructor SummaryConstructors Constructor Description Rank()Default constructor.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcomputeMetadata(StreamingMetadataContext ctx)Implementations must adhere to the following contractsprotected voidexecute(ExecutionContext ctx)Executes the operator.RecordPortgetInput()Gets the record port providing the input data to the operation.Rank.RankModegetMode()Get the mode used for ranking.RecordPortgetOutput()Gets the record port providing the output from the operation.StringgetOutputField()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.voidsetMode(Rank.RankMode mode)Set the ranking mode.voidsetOutputField(String outputField)Set the name of the output field that will contain the ranking order for each record.voidsetPartitionBy(String... partitionKeys)Set the fields used for partitioning the input data.voidsetPartitionBy(List<String> partitionKeys)Set the fields used for partitioning the input data.voidsetRankBy(SortKey... rankBy)Set the list of fields to use for ranking.voidsetRankBy(String... rankBy)Set the list of fields to use for ranking.voidsetRankBy(List<SortKey> rankBy)Set the list of fields to use for ranking.- 
Methods inherited from class com.pervasive.datarush.operators.ExecutableOperatorcloneForExecution, getNumInputCopies, getPortSettings, handleInactiveOutput
 - 
Methods inherited from class com.pervasive.datarush.operators.AbstractLogicalOperatordisableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface com.pervasive.datarush.operators.LogicalOperatordisableParallelism, getInputPorts, getOutputPorts
 
- 
 
- 
- 
- 
Method Detail- 
getInputpublic RecordPort getInput() Description copied from class:AbstractExecutableRecordPipelineGets the record port providing the input data to the operation.- Specified by:
- getInputin interface- PipelineOperator<RecordPort>
- Overrides:
- getInputin class- AbstractExecutableRecordPipeline
- Returns:
- the input port for the operation
 
 - 
getOutputpublic RecordPort getOutput() Description copied from class:AbstractExecutableRecordPipelineGets the record port providing the output from the operation.- Specified by:
- getOutputin interface- PipelineOperator<RecordPort>
- Overrides:
- getOutputin class- AbstractExecutableRecordPipeline
- Returns:
- the output port for the operation
 
 - 
setPartitionBypublic void setPartitionBy(List<String> partitionKeys) Set the fields used for partitioning the input data.- Parameters:
- partitionKeys- list of fields to use for partitioning
 
 - 
setPartitionBypublic void setPartitionBy(String... partitionKeys) Set the fields used for partitioning the input data.- Parameters:
- partitionKeys- list of fields to use for partitioning
 
 - 
getPartitionBypublic List<String> getPartitionBy() Get the list of fields used to partition the input data.- Returns:
- list of fields to use for partitioning
 
 - 
setRankBypublic void setRankBy(SortKey... rankBy) Set the list of fields to use for ranking. The data within each partition is sorted by the specified order. This specifies the set of fields used to calculate the rating within each partitioned group.- Parameters:
- rankBy- list of fields used to rank the data
 
 - 
setRankBypublic void setRankBy(String... rankBy) Set the list of fields to use for ranking. The data within each partition is sorted by the specified order. This specifies the set of fields used to calculate the rating within each partitioned group. The rank order can be a list of fields with the sort order specified (optional) as 'asc' or 'desc'.- Parameters:
- rankBy- list of fields used to rank the data along with sort order
 
 - 
setRankBypublic void setRankBy(List<SortKey> rankBy) Set the list of fields to use for ranking. The data within each partition is sorted by the specified order. This specifies the set of fields used to calculate the rating within each partitioned group.- Parameters:
- rankBy- list of fields used to rank the data
 
 - 
getRankBypublic List<SortKey> getRankBy() Get the list of fields used for ranking within each partition.- Returns:
- list of ranking fields
 
 - 
setModepublic void setMode(Rank.RankMode mode) Set the ranking mode. Ordinal ranking is used by default.- Parameters:
- mode- rank mode
 
 - 
getModepublic Rank.RankMode getMode() Get the mode used for ranking.- Returns:
- rank mode
 
 - 
setOutputFieldpublic void setOutputField(String outputField) Set the name of the output field that will contain the ranking order for each record.- Parameters:
- outputField- name of the ranking results field
 
 - 
getOutputFieldpublic String getOutputField() Get the name of the output ranking field.- Returns:
- name of the ranking results field
 
 - 
computeMetadataprotected void computeMetadata(StreamingMetadataContext ctx) Description copied from class:StreamingOperatorImplementations must adhere to the following contractsGeneralRegardless of input ports/output port types, all implementations must do the following:- Validation. Validation of configuration should always be performed first.
- Declare parallelizability.. Implementations must declare parallelizability by calling StreamingMetadataContext.parallelize(ParallelismStrategy).
 Input record portsImplementations with input record ports must declare the following:- Required data ordering: Implementations that have data ordering requirements must declare them by calling
- Required data distribution (only applies to parallelizable operators): Implementations that have data distribution requirements must declare them by calling
 RecordPort#setRequiredDataOrdering, otherwise data may arrive in any order.RecordPort#setRequiredDataDistribution, otherwise data will arrive in anunspecified partial distribution.RecordPort#getSourceDataDistributionandRecordPort#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.Output record portsImplementations with output record ports must declare the following:- Type: Implementations must declare their output type by calling
    RecordPort#setType.
 - Output data ordering: Implementations that can make guarantees as to their output
    ordering may do so by calling RecordPort#setOutputDataOrdering
- Output data distribution (only applies to parallelizable operators): Implementations that can make guarantees as to their output
    distribution may do so by calling RecordPort#setOutputDataDistribution
 Input model portsIn general, there is nothing special to declare for input model ports. Models are implicitly duplicated to all partitions when going from non-parallel to parallel operators. The case of a model going from a parallel to a non-parallel node is a special case of a "model reducer" operator. In the case of a model reducer, the downstream operator, must declare the following:- Merge handler: Model reducers must declare a merge handler by
     calling AbstractModelPort#setMergeHandler.
 MergeModelis a convenient, re-usable model reducer, parameterized with a merge-handler.Output model portsSimpleModelPort'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:- pmmlModelSpec: Implementations must declare the PMML model spec
     by calling PMMLPort.setPMMLModelSpec.
 - Specified by:
- computeMetadatain class- StreamingOperator
- Parameters:
- ctx- the context
 
 - 
executeprotected void execute(ExecutionContext ctx) Description copied from class:ExecutableOperatorExecutes the operator. Implementations should adhere to the following contracts:- Following execution, all input ports must be at end-of-data.
- Following execution, all output ports must be at end-of-data.
 - Specified by:
- executein class- ExecutableOperator
- Parameters:
- ctx- context in which to lookup physical ports bound to logical ports
 
 
- 
 
-