/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 2002-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
static const char stats_usage[] =
"[+PLUGIN?\findex\f]"
"[+DESCRIPTION?The stats query lists the sum, average, unbiased standard"
" deviation, and minimum and maximum range values of the numeric"
" \afield\a operands. If no operands are specified then all numeric"
" fields are assumed. If \b-\b is specified then only records or"
" groups are counted. If any of \b--average\b, \b--count\b,"
" \b--deviation\b, \b--range\b or \b--sum\b are specified then only"
" those values are listed.]"
"[a:average?List the average.]"
"[c:count?List the record count.]"
"[d:deviation?List the unbiased standard deviation.]"
"[g:group?Group by values in \afield\a. More than one \b--group\b may be "
"specified; grouping is done by the tuple of all \afield\a "
"values.]:[field]"
"[l:label?Label the output with \alabel\a.]:[label]"
"[m:maxgroups?Maximum number of groupings. Values beyond \amax\a are"
" listed as \bOVERFLOW\b.]#[max:=100]"
"[p:print?Print summary data according to \aformat\a. The format fields"
" are:]:[format]{\ffields\f}"
"[r:range?List the minimum and maximum values.]"
"[s:sum?List the sum.]"
"\n"
"\n[ field ... ]\n"
"\n"
;
#include <dsslib.h>
#include <ast_float.h>
struct Total_s
{
};
struct Bucket_s
{
};
struct Group_s
{
int string;
int width;
};
struct Field_s
{
};
struct Print_s
{
const char* label;
};
struct State_s
{
char* format;
char* label;
int fields;
int fw;
int groups;
int maxgroups;
int op;
};
{
};
extern Dsslib_t dss_lib_stats;
static int
getop(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
char* s;
char* v;
{
do
{
while (*s == ':')
s++;
for (v = s; *s && *s != ':'; s++);
} while (*s);
}
else
{
for (;;)
{
if (!group)
{
return -1;
}
break;
}
}
return 0;
}
static int
getvalue(Cx_t* cx, Cxinstruction_t* pc, Cxoperand_t* r, Cxoperand_t* a, Cxoperand_t* b, void* data, Cxdisc_t* disc)
{
char* s;
Cxnumber_t u;
int sep;
{
case STATS_AVERAGE:
break;
case STATS_COUNT:
break;
case STATS_DEVIATION:
{
u = -u;
}
else
break;
case STATS_FIELD:
break;
case STATS_GROUP:
{
if (sep)
else
else
{
return -1;
}
}
break;
case STATS_MAX:
break;
case STATS_MIN:
break;
case STATS_SUM:
break;
}
{
}
else
return 0;
}
static int
{
register int n;
{
{
return n;
return -1;
return 1;
}
return -1;
return 1;
}
return 0;
}
static int
{
int all;
int i;
char* s;
{
if (vm)
return -1;
}
{
goto bad;
}
{
goto bad;
}
for (i = 0; i < elementsof(variables); i++)
{
goto bad;
}
for (;;)
{
{
case 'a':
continue;
case 'c':
continue;
case 'd':
continue;
case 'g':
goto bad;
{
goto bad;
}
else
continue;
case 'l':
{
goto bad;
}
continue;
case 'm':
continue;
case 'p':
{
goto bad;
}
continue;
case 'r':
continue;
case 's':
continue;
case '?':
{
}
else
goto bad;
continue;
case ':':
else
goto bad;
continue;
}
break;
}
goto bad;
variable = 0;
do
{
if (all)
{
do
{
if (!variable)
break;
}
continue;
goto bad;
{
goto bad;
}
{
goto bad;
}
else
{
if (all)
{
goto bad;
}
}
{
goto bad;
}
{
{
goto bad;
}
}
{
{
goto bad;
}
if (i < 0)
goto bad;
}
return 0;
bad:
return -1;
}
static int
{
char* s;
int range;
int square;
{
{
return -1;
}
return -1;
{
{
return -1;
}
{
{
return -1;
}
}
}
}
else
{
{
return -1;
if (range)
{
}
if (square)
total++;
}
}
return 0;
}
static void
{
if (n == 0 || ((n >= 0) ? n : -n) >= 1 && n >= FLTMAX_INTMAX_MIN && n <= FLTMAX_UINTMAX_MAX && n == (Cxinteger_t)n)
else
{
if (n >= 0)
}
}
static int
list(Cx_t* cx, register State_t* state, Sfio_t* op, const char* label, register Field_t* field, register Total_t* total, Cxoperand_t* key)
{
Cxnumber_t u;
char* s;
do
{
{
return -1;
}
else
{
if (field)
{
u = -u;
}
{
}
if (label)
{
label = 0;
}
else if (key)
{
{
else
{
return -1;
}
}
key = 0;
}
}
total++;
return 0;
}
static int
{
{
{
group->width = group->variable->format.print ? group->variable->format.print : group->variable->type->format.print ? group->variable->type->format.print : FW;
}
}
{
for (bucket = (Bucket_t*)dtfirst(state->buckets); bucket; bucket = (Bucket_t*)dtnext(state->buckets, bucket))
goto bad;
goto bad;
}
goto bad;
return 0;
bad:
return -1;
}
{
{
"stats",
"collect numeric field value statistics",
CXH,
0,
},
{0}
};
{
"stats",
"stats query"
"[-1lms5P?\n@(#)$Id: dss stats query (AT&T Research) 2011-09-11 $\n]"
CXH,
0,
0,
0,
0,
0,
0,
&queries[0]
};