Exemple #1
0
            public Cursor(StatefulFilterTransform <TSrc, TDst, TState> parent, RowCursor <TSrc> input, Func <int, bool> predicate)
                : base(parent.Host)
            {
                Ch.AssertValue(input);
                Ch.AssertValue(predicate);

                _parent = parent;
                _input  = input;

                _src   = new TSrc();
                _dst   = new TDst();
                _state = new TState();

                CursorChannelAttribute.TrySetCursorChannel(_parent.Host, _src, Ch);
                CursorChannelAttribute.TrySetCursorChannel(_parent.Host, _dst, Ch);
                CursorChannelAttribute.TrySetCursorChannel(_parent.Host, _state, Ch);

                if (parent._initStateAction != null)
                {
                    parent._initStateAction(_state);
                }

                var appendedDataView = new DataViewConstructionUtils.SingleRowLoopDataView <TDst>(parent.Host, _parent._addedSchema);

                appendedDataView.SetCurrentRowObject(_dst);

                Func <int, bool> appendedPredicate =
                    col =>
                {
                    col = _parent._bindings.AddedColumnIndices[col];
                    return(predicate(col));
                };

                _appendedRow = appendedDataView.GetRowCursor(appendedPredicate);
            }
            public Cursor(StatefulFilterTransform <TSrc, TDst, TState> parent, RowCursor <TSrc> input, IEnumerable <DataViewSchema.Column> columnsNeeded)
                : base(parent.Host)
            {
                Ch.AssertValue(input);
                Ch.AssertValue(columnsNeeded);

                _parent = parent;
                _input  = input;

                _src   = new TSrc();
                _dst   = new TDst();
                _state = new TState();

                CursorChannelAttribute.TrySetCursorChannel(_parent.Host, _src, Ch);
                CursorChannelAttribute.TrySetCursorChannel(_parent.Host, _dst, Ch);
                CursorChannelAttribute.TrySetCursorChannel(_parent.Host, _state, Ch);

                parent._initStateAction?.Invoke(_state);

                var appendedDataView = new DataViewConstructionUtils.SingleRowLoopDataView <TDst>(parent.Host, _parent._addedSchema);

                appendedDataView.SetCurrentRowObject(_dst);

                var columnNames = columnsNeeded.Select(c => c.Name);

                _appendedRow = appendedDataView.GetRowCursor(appendedDataView.Schema.Where(c => !c.IsHidden && columnNames.Contains(c.Name)));
            }
Exemple #3
0
        /// <summary>
        /// The 'reapply' constructor.
        /// </summary>
        private StatefulFilterTransform(IHostEnvironment env, StatefulFilterTransform <TSrc, TDst, TState> transform, IDataView newSource)
        {
            _host.AssertValue(transform);
            _host.AssertValue(newSource);
            _source      = newSource;
            _filterFunc  = transform._filterFunc;
            _typedSource = TypedCursorable <TSrc> .Create(_host, newSource, false, transform._inputSchemaDefinition);

            _addedSchema = transform._addedSchema;
            _bindings    = new ColumnBindings(newSource.Schema, DataViewConstructionUtils.GetSchemaColumns(_addedSchema));
        }