예제 #1
0
        public unsafe void OnNext(StreamMessage <CompoundGroupKey <TOuterKey, TInnerKey>, TInnerResult> batch)
        {
            outPool.Get(out StreamMessage <TOuterKey, TResult> tmp);
            tmp.AllocatePayload();
            outPool.GetKey(out tmp.key);
            tmp.hash = batch.hash.MakeWritable(outPool.intPool);
            var count = batch.Count;

            tmp.vsync     = batch.vsync;
            tmp.vother    = batch.vother;
            tmp.bitvector = batch.bitvector;

            fixed(long *srcbv = batch.bitvector.col)
            fixed(int *desthash = tmp.hash.col)
            {
                var srckey  = batch.key.col;
                var destkey = tmp.key.col;

                for (int i = 0; i < count; i++)
                {
                    if ((srcbv[i >> 6] & (1L << (i & 0x3f))) != 0)
                    {
                        if (batch.vother.col[i] == long.MinValue)
                        {
                            destkey[i]  = srckey[i].outerGroup;
                            desthash[i] = batch.hash.col[i];
                            tmp.bitvector.col[i >> 6] |= 1L << (i & 0x3f);
                        }
                        continue;
                    }
                    destkey[i]  = srckey[i].outerGroup;
                    tmp[i]      = resultSelector(srckey[i].innerGroup, batch[i]);
                    desthash[i] = this.outerHashCode(destkey[i]);
                }
            }

            tmp.Count = count;
            tmp.Seal();

            Observer.OnNext(tmp);

            batch.ReleasePayload();
            batch.key.Return();
            batch.Return();
        }
예제 #2
0
        public unsafe void OnNext(StreamMessage <TInnerKey, TInnerResult> batch)
        {
            outPool.Get(out StreamMessage <Empty, TResult> tmp);
            tmp.AllocatePayload();
            outPool.GetKey(out tmp.key);
            tmp.hash = batch.hash.MakeWritable(outPool.intPool);
            var count = batch.Count;

            tmp.vsync     = batch.vsync;
            tmp.vother    = batch.vother;
            tmp.bitvector = batch.bitvector;

            fixed(long *srcbv = batch.bitvector.col)
            fixed(int *desthash = tmp.hash.col)
            {
                var srckey  = batch.key.col;
                var destkey = tmp.key.col;

                Array.Clear(tmp.hash.col, 0, count);

                var unit = Empty.Default;

                for (int i = 0; i < count; i++)
                {
                    if ((srcbv[i >> 6] & (1L << (i & 0x3f))) != 0)
                    {
                        continue;
                    }
                    destkey[i] = unit;
                    tmp[i]     = resultSelector(srckey[i], batch[i]);
                }
            }

            tmp.Count = count;
            tmp.Seal();

            Observer.OnNext(tmp);

            batch.ReleasePayload();
            batch.key.Return();
            batch.Return();
        }