In-memory record sort
aq_ord [-h] Global_Opt Input_Spec Sort_Spec Output_Spec
Global_Opt:
[-verb] [-stat]
Input_Spec:
[-f[,AtrLst] File [File ...]] [-d ColSpec [ColSpec ...]]
Sort_Spec:
-sort[,AtrLst] ColTyp:ColNum | -sort[,AtrLst] ColName [ColName ...]
Output_Spec:
[-o[,AtrLst] File] [-c ColName [ColName ...]]
aq_ord
sorts input records according to the value of the sort columns.
Sort is done in memory, so it is fast.
However, the entire data set must fit into a single machine’s main memory.
The program offers two sort modes. One is fast and simple but less flexible.
The other requires more processing overhead but is more versatile.
Raw sort mode
In this mode, raw input rows are stored in memory as-is. Column values are not interpreted except for the sort column. Advantages are:
Disadvantages are:
Parsed sort mode
In this mode, a column spec must be defined. Columns are converted before they are stored in memory - numeric and IP address types are stored in binary forms, string type is hashed and the pointer to the hash entry is stored. Advantages are:
Disadvantages are:
-verb
-stat
Print a record count summary line to stderr at the end of processing. The line has the form:
aq_ord: rec=Count err=Count
-f[,AtrLst] File [File ...]
Set the input attributes and files. See the aq_tool input specifications manual for details.
Example:
$ aq_ord ... -f,+1l file1 file2 ...
-d ColSpec [ColSpec ...]
Optionally define the input data columns.
Only needed in Parsed sort mode.
See the aq_tool input specifications manual for details.
In general, ColSpec
has the form Type[,AtrLst]:ColName
.
Supported Types
are:
S
- String.F
- Double precision floating point.L
- 64-bit unsigned integer.LS
- 64-bit signed integer.I
- 32-bit unsigned integer.IS
- 32-bit signed integer.IP
- v4/v6 address.Optional AtrLst
is a comma separated list of column specific attributes.
ColName
is the column name (case insensitive). It can contain up to
31 alphanumeric and ‘_’ characters. Its first character cannot be a digit.
Example:
$ aq_ord ... -d s:Col1 s,lo:Col2 i,trm:Col3 ...
trm
attribute removes blanks around the value before it is converted to
an internal number.-sort[,AtrLst] ColTyp:ColNum
Define the Raw sort mode sort column.
ColTyp
specifies the sort column’s data type. See -d for a list of
types,``X`` is not supported.
ColNum
specifies the column number (one-based) of the sort column in
each row.
Optional AtrLst
is a comma separated list containing:
dec
- Sort in descending order. Default order is ascending.
Descending sort is done by inverting the ascending sort result.Example:
$ aq_ord ... -sort s:2
-sort[,AtrLst] ColName [ColName ...]
Define the Parsed sort mode sort columns.
ColNames
must already be defined under -d.
Optional AtrLst
is a comma separated list containing:
dec
- Sort in descending order. Default order is ascending.
Descending sort is done by inverting the ascending sort result.Example:
$ aq_ord ... -d i:Col1 s:Col2 ... -sort Col2 Col1
[-o[,AtrLst] File] [-c ColName [ColName ...]]
Output data rows.
Optional “-o[,AtrLst] File
” sets the output attributes and file.
See the aq_tool output specifications manual for details.
In the Raw sort mode, most output attributes have no effect since
the records cannot be altered (only their order).
The -c
option is not applicable either.
In the Parsed sort mode,
optional “-c ColName [ColName ...]
” selects the columns to output.
ColName
refers to a column defined under -d.
A ColName
can be preceeded with a ~
(or !
) negation mark.
This means that the column is to be excluded.
Without -c
, all columns are selected by default.
If -c
is specified without a previous -o
, output to stdout is
assumed.
Multiple sets of “-o ... -c ...
” can be specified.
Example:
$ aq_ord ... -d s:Col1 s:Col2 s:Col3 ... -o,esc,noq - -c Col2 Col1
If successful, the program exits with status 0. Otherwise, the program exits with a non-zero status code along error messages printed to stderr. Applicable exit codes are: