0

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

4

1 回答 1

0

您需要一个时间敏感的 UDA。从 CepTimeSensitiveAggregate 继承(参见http://technet.microsoft.com/en-us/library/ee842915.aspx)并且您的生成输出方法将 WindowDescriptor 作为签名的一部分。作为奖励,您还将获得事件的时间标头,因此您无需将此信息作为有效负载的一部分加入队列。虽然有一些边缘用例需要这样做,但在大多数情况下,您不需要它。

于 2014-05-13T17:09:59.260 回答