Exemplo n.º 1
0
        private void TestHashTransformVectorHelper(ArrayDataViewBuilder builder, uint[][] results)
        {
            var srcView = builder.GetDataView();
            var col     = new HashTransformer.Column();

            col.Name     = "F1V";
            col.HashBits = 5;
            col.Seed     = 42;
            var args = new HashTransformer.Arguments();

            args.Column = new HashTransformer.Column[] { col };

            var hashTransform = HashTransformer.Create(Env, args, srcView);

            using (var cursor = hashTransform.GetRowCursor(c => true))
            {
                var            resultGetter = cursor.GetGetter <VBuffer <uint> >(1);
                VBuffer <uint> resultRow    = new VBuffer <uint>();
                foreach (var r in results)
                {
                    Assert.True(cursor.MoveNext());
                    resultGetter(ref resultRow);

                    Assert.True(resultRow.Length == r.Length);
                    for (int i = 0; i < r.Length; i++)
                    {
                        Assert.True(resultRow.GetItemOrDefault(i) == r[i]);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void TestHashTransformHelper <T>(T[] data, uint[] results, NumberType type)
        {
            var builder = new ArrayDataViewBuilder(Env);

            builder.AddColumn("F1", type, data);
            var srcView = builder.GetDataView();

            var col = new HashTransformer.Column();

            col.Name     = "F1";
            col.HashBits = 5;
            col.Seed     = 42;
            var args = new HashTransformer.Arguments();

            args.Column = new HashTransformer.Column[] { col };

            var hashTransform = HashTransformer.Create(Env, args, srcView);

            using (var cursor = hashTransform.GetRowCursor(c => true))
            {
                var  resultGetter = cursor.GetGetter <uint>(1);
                uint resultRow    = 0;
                foreach (var r in results)
                {
                    Assert.True(cursor.MoveNext());
                    resultGetter(ref resultRow);
                    Assert.True(resultRow == r);
                }
            }
        }