Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On In this Pagearticle

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Overview

This Snap sorts You can use this Snap to sort a document stream using its values in the order in which they show up in the sort path list. For example, if the sort paths are $first_name and $last_name, then the value at first_name will be used first when sorting.

This Snap uses temporary files to sort the input document streams and is limited by the size of the free disk space in a node. The Snap reads input documents and sorts them in a memory buffer. When the buffer size reaches a certain limit, it writes the data in the buffer into a temporary file, clears the buffer, and reads/sorts more input documents.

The minimum size of the memory buffer is 100MB. You can increase the value in the Maximum memory % field.

...

Snap Type

The Sort Snap is a Transform-type Snap that sorts the input document streams in the memory buffer.

...

Support for Ultra Pipelines 

Does not work in Ultra Pipelines

Limitations and Known Issues

None.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

  • Min: 1

  • Max: 1

  • Mapper

  • Union

The Snap reads input documents and sorts them in a memory buffer.

Output

Document

  • Min: 1

  • Max: 1

  • Mapper

  • Join

This Snap sorts a document stream which show up in the sort path list.

Error

This Snap has at most one document error view and produces zero or more documents in the view

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter while running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:

  • Stop Pipeline Execution: Stops the current pipeline execution when the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

Info
  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon ((blue star)): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon ( (blue star) ): Indicates the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon ((blue star)): Indicates that you can add fields in the fieldset.

  • Remove icon ((blue star)): Indicates that you can remove fields from the fieldset.

Field Name

Field Type

Description

Label*

Default value: Sort
Example: Sort input streams

String

Required.

The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Sort Paths

Required. List

*

Use this field set to provide the list of paths to sort on.

Sort path*

Default Value: None
Example:

 $person

 $person.first_name

String/

Sugesstion

Suggestion

Required. Paths

Paths of values in the document to sort on. For example, if the sort paths are $first_name and $last_name, then the value at first_name is sorted first.

This field supports only scalar values such as string, number, date and so on.

Sort order*

Default value: global
Example: ascending

Dropdown list

Required. Order of

Order of sorting. The available options are:

  • global

  • ascending

  • descending

Note

If you select the option global, the Sort order (Global) property becomes functional for the corresponding Sort path.

Sort order (Global)

Default value: ascending
Example: descending

Dropdown list

Sort the specified values in ascending or descending order.

Null greater

Default value: Not Selected
Example: Selected

Checkbox

If selected, null is considered

Select this checkbox to allow the Snap to consider null value greater than the non-null values. When you select this checkbox,

and

null values

will be

are placed last when sorted in the ascending order.

If selected and
  • When you select this checkbox, and the Sort order is:

    • ascending,

nulls
    • null values appear at the end of the list.

If selected and Sort order is
    • descending,

nulls
    • null values appear at the beginning of the list.

If not selected and
  • When you deselect this checkbox and the Sort order is:

    • ascending,

nulls
    • null values appear at the beginning of the list.

If not selected and Sort order is
    • descending,

nulls
    • null values appear at the end of the list.

Please note that an

An empty string is not considered as null and is always smaller than non-empty strings.

Null-safe access

Default value: Selected (True)  
Example: Deselected

Checkbox

If selected, the Snap considers the

Select this checkbox if you consider the values of non-existent or incorrect sort paths as null. If unselected, the Snap validates each input document to throw errors for non-existent or incorrect sort paths. Clearing this property will result in a lower performance.

Maximum memory

%

Default

value

Value: 10
Example: 20

Integer

Enter

Specify the maximum memory to compute the size of the internal memory buffer for the external merge sort. The value you choose must be in MB or % , which you can specify in the Maximum memory unit. If its unit is %, the value of this property is the percentage of maximum used memory as compared to the maximum system memory.

Sort Snap uses this property value to compute

  • This Snap uses temporary files to sort the input document streams and has a limitation by the size of the

internal memory buffer for the external merge sort. The minimum buffer size is set to 100MB.
  • free disk space in a node. The Snap reads input documents and sorts them in a memory buffer. When the buffer size reaches the value specified, the Snap writes the data in the buffer into a temporary file, clears the buffer, and reads/sorts more input documents.

  • The maximum memory used by Sort Snap is 10 MB when the available memory in the node is lower than 500 MB to avoid out-of-memory crash.

  • If multiple instances of Sort Snap

might be
  • are simultaneously

being
  • executed in the same Snaplex and the system memory size is limited

, it is strongly advised to keep this property value low
  • , we recommend you to specify a lower value in this field.

  • On executing the Snap, the pipeline execution statistics display the following memory-related statistics:
    Free disk space, Available memory and Average document size.

Maximum memory unit

Default Value: %

Example: MB

Dropdown

Select the appropriate unit for the Maximum memory property.

  • %

  • MB

The buffer size ranges from 10 MB to 10 GB.

Minimum memory (MB)

Default value: 500
Example750

String/Expression

If the available memory is less than this property value while processing input documents, the Snap stops to fetch the next input document until more memory is available. This feature is disabled if this property value is 0.

Minimum free disc space (MB)

Default value: 500
Example750

String/Expression

If the free disc space is less than this property value, the Snap stops processing input documents until more free disc space is available. This feature is disabled if this property value is 0.

Out-of-resource timeout (minutes)

Default value: 30
Example20

String/Expression

If the Snap pauses longer than this property value while waiting for more memory available, it throws an exception to prevent the system from running out of memory or disk space.

Snap Execution

Dropdown list

Multiexcerpt include macronameSnap_Execution_IntroducedpageAnaplan Read

Select one of the three modes in which the Snap executes. Available options are:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during Pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during Pipeline runtime.

  • Execute only: Performs full execution of the Snap during Pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Multiexcerpt include macro
nameTemporary Files
pageJoin

Examples

Insert excerpt
Transform Snap PackTransform Snap Packnopaneltrue

Troubleshooting:

Error

Reason

Resolution

Failed to sort data at the input document.

Insufficient free disk space to stage sort data into temporary files.

Increase the free disk space.

Input document does not contain sort path.

If Null-safe access is false, all input documents should contain keys for sort paths.

Address the reported issue.

Example

...

Sort fields in ascending and descending order

The example pipeline demonstrates how to sort the data by age and last name from a JSON file in ascending and descending order.

...

  1. Configure the JSON Generator Snap with multiple records.

    Image Added

2. Configure the Sort Snap to sort the Age in descending order and the Last Name as global. Further, set the Sort order (Global) as ascending.

...

3. Validate the Snap. The Sort Snap displays the following output, with Age in descending order and, further, the Last Name in ascending order.

...

Download the Pipeline.

Downloads

Attachments
patterns*.slp, *.zip

Snap Pack History

Related Links