- java.lang.Object
-
- com.pervasive.datarush.ports.record.DataOrdering
-
public final class DataOrdering extends Object
DataOrdering is the component ofRecordMetadata
that describes how the data is ordered.Operators may declare a required ordering by calling
RecordPort.setRequiredDataOrdering(com.pervasive.datarush.operators.MetadataCalculationContext, com.pervasive.datarush.ports.record.DataOrdering)
. It is the responsibility of the framework to ensure that the specified requirement is met. Operators may also declare their output ordering by callingRecordPort.setOutputDataDistribution(com.pervasive.datarush.operators.MetadataCalculationContext, com.pervasive.datarush.ports.record.DataDistribution)
. This lets the framework know how data is ordered on the operator's output. If there is an mismatch between required and provided metadata, the framework will automatically sort as needed.- See Also:
StreamingOperator#computeMetadata
,IterativeOperator#computeMetadata
-
-
Field Summary
Fields Modifier and Type Field Description static DataOrdering
UNSPECIFIED
The default data ordering if not specified.
-
Constructor Summary
Constructors Constructor Description DataOrdering(SortKey[] keys)
Specify that data is ordered by the given set of keys.DataOrdering(List<SortKey> keys)
Specify that data is ordered by the given set of keys.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AliasSet[]
getAliases()
SortKey[]
getKeys()
Returns the keys that the data is sorted bySortKey[]
getPrefixOrdering(String[] prefix)
Returns a prefix of the current ordering, merged with sort direction information.boolean
isOrdered(SortKey[] desired)
Returns true if data is ordered by the specified ordering or a prefix of the specified ordering.boolean
isOrdered(String[] desired)
Returns true if data is ordered by the specified ordering or a prefix of the specified ordering.boolean
isUnspecified()
Returns whether this is the unspecified data ordering.DataOrdering
remap(FieldRemapping mapping)
Applies the given field remapping to this ordering, changing names as required.String
toString()
-
-
-
Field Detail
-
UNSPECIFIED
public static final DataOrdering UNSPECIFIED
The default data ordering if not specified.
-
-
Constructor Detail
-
DataOrdering
public DataOrdering(List<SortKey> keys)
Specify that data is ordered by the given set of keys.- Parameters:
keys
- specifies field names and ascending vs. descending
-
DataOrdering
public DataOrdering(SortKey[] keys)
Specify that data is ordered by the given set of keys.- Parameters:
keys
- specifies field names and ascending vs. descending
-
-
Method Detail
-
isOrdered
public boolean isOrdered(SortKey[] desired)
Returns true if data is ordered by the specified ordering or a prefix of the specified ordering.- Parameters:
desired
- the desired data ordering- Returns:
- whether the data is ordered by the desired ordering
-
isOrdered
public boolean isOrdered(String[] desired)
Returns true if data is ordered by the specified ordering or a prefix of the specified ordering. This method ignores ascending vs. descending order. If ascending vs. descending is important useisOrdered(SortKey[])
instead.- Parameters:
desired
- the desired data ordering- Returns:
- whether the data is ordered by the desired ordering
-
getAliases
public AliasSet[] getAliases()
-
getKeys
public SortKey[] getKeys()
Returns the keys that the data is sorted by- Returns:
- the keys the date data is sorted by
-
isUnspecified
public boolean isUnspecified()
Returns whether this is the unspecified data ordering. The unspecified data ordering is equivalent to an ordering where there are no sort keys.- Returns:
- whether this is the unspecified data ordering
-
getPrefixOrdering
public SortKey[] getPrefixOrdering(String[] prefix)
Returns a prefix of the current ordering, merged with sort direction information. This is useful for operators that require data be sorted by a specific set of keys but have no specific requirements regarding sort direction. Those operators will first need to test whether data is ordered as desired by callingisOrdered(String[])
. If data is ordered, they will then call this method to determine specific directional information.- Parameters:
prefix
- must be a prefix of the data ordering- Returns:
- a prefix of the current ordering.
- Throws:
IllegalArgumentException
- if the data is not ordered by the given prefix
-
remap
public DataOrdering remap(FieldRemapping mapping)
Applies the given field remapping to this ordering, changing names as required. If any sort keys refer to columns that are dropped as part of the rename, the result ordering will be a prefix of the original. If all sort keys refer to columns that are dropped via the rename, the result will be theUNSPECIFIED
ordering.- Parameters:
mapping
- the field remapping.- Returns:
- this distribution, remapped to the new names.
-
-