I have a problem I am stuck for two days now. Maybe someone of you guys can help me.
I try to get the starttime of a window passed to a user defined aggregate. Unfortunately I don't know how to do this. The way I thought it should work looks like that:
var tot = from row in tumblingWin
select new
{
value = row.UserDefinedAggregate<Dataclass, Total2, double>(new StartBoundsConfig
{
Winstart = row.WinStart().Ticks
}) * processinginterval,
};
And the UDA looks like this:
public class Total2: CepAggregate<Dataclass,double>
{
private Dataclass lastone; //keep it, if needed for next window
private StartBoundsConfig _conf;
public Total2(StartBoundsConfig config)
{
_conf = config;
}
public override double GenerateOutput(IEnumerable<Dataclass> events)
{
//TODO check if value on window start => if not use last from previous as starting value
bool checkfirst = true;
long result = 0;
long tsone = 0;
foreach (var evts in events)
{
if (checkfirst == true)
{
tsone = evts.Gentime.Ticks;
checkfirst = false;
}
else
{
long tstwo = evts.Gentime.Ticks;
long delta = tstwo - tsone;
long value = (long) evts.Value;
result += delta*value;
tsone = tstwo;
}
lastone = evts;
}
return result;
}
}
I tried to pass the window start to the config of the UDA and read it from there. Has anyone an idea why this doesn't work that way and how I could get the starttime of the window passed to the UDA to use it for calculation there?
I am very grateful for any hint.
Joe