public CursorType(InfiniteLoopViewCursorDataFrame view, Func <int, bool> needCol, IRowCursor otherValues)
 {
     _needCol           = needCol;
     _view              = view;
     _state             = CursorState.NotStarted;
     _otherValues       = otherValues;
     _wait              = true;
     _position          = 0;
     _batch             = 1;
     _container         = null;
     _positionDataFrame = -1;
     _columnsSchema     = _view._columnsSchema;
     _columns           = new Dictionary <int, int>();
     for (int i = 0; i < view.ReplacedCol.Length; ++i)
     {
         _columns[view.ReplacedCol[i]] = i;
     }
 }
Beispiel #2
0
 public CursorType(InfiniteLoopViewCursorDataFrame view, IEnumerable <DataViewSchema.Column> columnsNeeded,
                   DataViewRowCursor otherValues, int start, int inc)
 {
     _columnsNeeded     = columnsNeeded;
     _start             = start;
     _inc               = inc;
     _view              = view;
     _state             = CursorState.NotStarted;
     _otherValues       = otherValues;
     _wait              = true;
     _position          = -1;
     _batch             = 1;
     _container         = null;
     _positionDataFrame = -1;
     _columnsSchema     = _view._columnsSchema;
     _columns           = new Dictionary <int, int>();
     for (int i = 0; i < view.ReplacedCol.Length; ++i)
     {
         _columns[view.ReplacedCol[i]] = i;
     }
 }
Beispiel #3
0
        ValueMapper <DataFrame, DataFrame> GetMapperRow()
        {
            var firstView = _sourceToReplace ?? DataViewHelper.GetFirstView(_transform);
            var schema    = firstView.Schema;

            var inputView = new InfiniteLoopViewCursorDataFrame(null, firstView.Schema);

            // This is extremely time consuming as the transform is serialized and deserialized.
            var outputView = _sourceToReplace == _transform.Source
                                ? ApplyTransformUtils.ApplyTransformToData(_computeEnv, _transform, inputView)
                                : ApplyTransformUtils.ApplyAllTransformsToData(_computeEnv, _transform, inputView, _sourceToReplace);

            // We assume all columns are needed, otherwise they should be removed.
            using (var cur = outputView.GetRowCursor(i => true))
            {
                var getRowFiller = DataFrame.GetRowFiller(cur);

                return((in DataFrame src, ref DataFrame dst) =>
                {
                    if (dst is null)
                    {
                        dst = new DataFrame(outputView.Schema, src.Length);
                    }
                    else if (!dst.CheckSharedSchema(outputView.Schema))
                    {
                        throw _env.Except($"DataFrame does not share the same schema, expected {SchemaHelper.ToString(outputView.Schema)}.");
                    }
                    dst.Resize(src.Length);

                    inputView.Set(src);
                    for (int i = 0; i < src.Length; ++i)
                    {
                        cur.MoveNext();
                        getRowFiller(dst, i);
                    }
                });