microsoft / Trill

Trill is a single-node query processor for temporal or streaming data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullReferenceException in Columnar Mode

wassim-k opened this issue · comments

The following code throws a null reference exception when running in columnar mode.
It seems to occur whenever I add the nested GroupApply, is there a known limitation there am I doing something wrong in the code?

The error occurs in the code generated by Trill on the following line:

    public unsafe void OnNext(StreamMessage<CompoundGroupKey<Microsoft.StreamProcessing.CompoundGroupKey<Microsoft.StreamProcessing.Empty, System.String>, System.String>, System.Double> batch)
    {
        GeneratedBatch_2 inputBatch = batch as GeneratedBatch_2;

        StreamMessage<Microsoft.StreamProcessing.CompoundGroupKey<Microsoft.StreamProcessing.Empty, System.String>, System.Double> tmp; // Need this type to call Get with so the right subtype will be returned
        outPool.Get(out tmp);

        ...

        var srckey = batch.key.col;
        var destkey = tmp.key.col; // <== key is null 

Reproduction

public struct Payload
{
    public string Name;
    public string GroupId;
    public int Reading;
}

public struct Result
{
    public string Name;
    public double Average;
}

public void Run()
{
    var array = new Payload[]
    {
        new Payload { GroupId = "GA", Name = "A", Reading = 1 },
        new Payload { GroupId = "GA", Name = "B", Reading = 2 },
        new Payload { GroupId = "GA", Name = "C", Reading = 3 },
    };

    Observable
        .Interval(TimeSpan.FromMilliseconds(500))
        .Select(i => array[i])
        .Take(array.Length)
        .ToAtemporalStreamable(TimelinePolicy.WallClock())
        .GroupApply(
            e => e.GroupId,
            byGroup => byGroup.GroupApply(
                            b => b.Name,
                            byName => byName
                                    .TumblingWindowLifetime(TimeSpan.FromSeconds(3).Ticks)
                                    .Average(e => e.Reading)),
            (g, avg) => new Result { Name = g.Key, Average = avg })
        .ToStreamEventObservable()
        .Where(e => e.IsData)
        .Subscribe(b =>
        {
            Console.WriteLine($"Kind: {b.Kind}, Time: {new DateTime(b.StartTime):hh:mm:ss}, Name: {b.Payload.Name}, Average: {b.Payload.Average}");
        });
}
commented

This is now fixed

Thanks @peterfreiling for the very quick fix.

@peterfreiling when can I expect this fix to be available as a nuget package?