Exemple #1
0
        public SortInDataFrameTransform(IHostEnvironment env, Arguments args, IDataView input)
            : base(env, RegistrationName, input)
        {
            Host.CheckValue(args, "args");
            Host.CheckUserArg(!args.numThreads.HasValue || args.numThreads.Value > 0, "numThreads cannot be negative.");

            if (!string.IsNullOrEmpty(args.sortColumn))
            {
                var schema = input.Schema;
                int index  = SchemaHelper.GetColumnIndex(schema, args.sortColumn);
                var type   = schema[index].Type;
                Host.Check(!type.IsVector(), "sortColumn cannot be a vector.");
            }

            _reverse    = args.reverse;
            _sortColumn = args.sortColumn;
            _numThreads = args.numThreads;
            _transform  = CreateTemplatedTransform();
        }
Exemple #2
0
        private SortInDataFrameTransform(IHost host, ModelLoadContext ctx, IDataView input) : base(host, input)
        {
            Host.CheckValue(input, "input");
            Host.CheckValue(ctx, "ctx");

            _sortColumn = ctx.Reader.ReadString();
            Host.AssertValue(_sortColumn);
            var schema = input.Schema;
            int index  = SchemaHelper.GetColumnIndex(schema, _sortColumn);
            var type   = schema[index].Type;

            Host.Check(!type.IsVector(), "sortColumn cannot be a vector.");
            _reverse    = ctx.Reader.ReadBoolean();
            _numThreads = ctx.Reader.ReadInt32();
            if (_numThreads < 0)
            {
                _numThreads = null;
            }
            _transform = CreateTemplatedTransform();
        }