Data row/key count
aq_cnt [-h] Global_Opt Input_Spec Count_Spec Output_Spec
Global_Opt:
[-verb] [-stat]
Input_Spec:
[-f[,AtrLst]|-fX[,AtrLst] File [File ...]] [-d ColSpec [ColSpec ...]]
Count_Spec:
[-k KeyName ColName [ColName ...]]
Output_Spec:
[-kx[,AtrLst] File KeyName ColName [ColName ...]]
[-kX[,AtrLst] File KeyName ColName [ColName ...] [STATS:ColName [STATS:ColName ...]]]
[-o[,AtrLst] File]
aq_cnt
counts and reports unique keys in a data set.
Since the program needs to store all the unique keys in memory in order to count them, its capacity is limited by the amount of physical memory in a machine. In case there is a capacity issue, an aq_pp and Udb combination can be used to implement a scalable key counting solution.
-verb
-stat
Print a record count summary line to stderr at the end of processing. The line has the form:
aq_cnt: rec=Count err=Count
-f[,AtrLst]|-fX[,AtrLst] File [File ...]
Set the input attributes and files. See the aq_tool input specifications manual for details.
-f
for a normal key counting operation on the input data.-fX
to merge input data produced by one or more
aq_cnt ... -kX ... commands.Example:
$ aq_cnt ... -f,+1l file1 file2 ...
-d ColSpec [ColSpec ...]
Define the input data columns.
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.STAT
- For -fX only. It represents a corresponding STAT
column in the -kX output to be merged.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_cnt ... -d s:Col1 s,lo:Col2 i,trm:Col3 ...
trm
attribute removes blanks around the value before it is converted to
an internal number.$ aq_cnt ... -d s:Col1 s,lo:Col2 i,trm:Col3 -kX,notitle - - Col1 Col2 stats:Col3 | aq_cnt -fX - -d s:Col1 s:Col2 stats:Col3 -kX - - Col1 Col2 stats:Col3
aq_cnt .. -kX ..
commands as input.$ aq_cnt ... -d s:Col1 s,lo:Col2 i,trm:Col3 -kX,aq - - Col1 Col2 stats:Col3 | aq_cnt -fX,aq - -kX - - Col1 Col2 stats:Col3
aq
attribute.-k KeyName ColName [ColName ...]
KeyName
is a unique label for this key combination.
ColNames
are the columns forming the key.-kx[,AtrLst] File KeyName ColName [ColName ...]
Define a key to count and output the unique key combinations to File
.
See the aq_tool output specifications manual for details
on AtrLst
.
KeyName
is a unique label for this key combination.
If given, the resulting unique key count will be reported in the -o
overall count summary. But if it is a blank or a -
(a single dash),
its count will not be reported there.ColNames
are the columns forming the key.The result in File
has this form:
"KeyCol1","KeyCol2",... Val1,Val2,... ...
-kX[,AtrLst] File KeyName ColName [ColName ...] [STATS:ColName [STATS:ColName ...]]
Define a key to count and output the unique key combinations as well as
their occurrence counts to File
.
See the aq_tool output specifications manual for details
on AtrLst
.
Note that this report may be generated even when this option is not given.
See Default output for details.
KeyName
is a unique label for this key combination.
If given, the resulting unique key count will be reported in the -o
overall count summary. But if it is a blank or a -
(a single dash),
its count will not be reported there.ColNames
are the columns forming the key.
The STATS:ColName
spec is for the extended statistics of an associated
numeric column. The statistics include its sum, average, standard deviation,
minimum and maximum for each unique key combination. They are output as
double precision floating point numbers following the occurrence count..
(a single dot) can be used in place
of the column spec. This will automatically add all the input columns to
the column spec.The result in File
has this form:
"KeyCol1","KeyCol2",...,"Count" Val1,Val2,...,Occurrence ...
If STATS:ColName
are used, the result will be:
"KeyCol1","KeyCol2",...,"Count","StatsCol1.sum","StatsCol1.avg","StatsCol1.stddev","StatsCol1.min","StatsCol1.max",... Val1,Val2,...,Occurrence,Sum1,Avg1,StdDev1,Min1,Max1,... ...
-o[,AtrLst] File
Set the output attributes and file for the overall count summary.
See the aq_tool output specifications manual for details
on AtrLst
.
Note that this report may be generated even when this option is not given.
See Default output for details.
The summary has this form:
"row","KeyName1","KeyName2",... Rows,Count1,Count2,...
where “row” gives the sample count and “KeyNames” (from -k, -kx and -kX) give their unique key counts.
Example:
$ aq_cnt ... -d s:Col1 s:Col2 ip:Col3 ... -k Key1 Col1 -kX File2 Key2 Col3 Col2 ... -o -
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: