Пример #1
0
        public IRowCursor[] GetRowCursorSet(out IRowCursorConsolidator consolidator, Func <int, bool> predicate, int n, IRandom rand = null)
        {
            var host = new ConsoleEnvironment().Register("Estimate n threads");

            n = DataViewUtils.GetThreadCount(host, n);

            if (n <= 1)
            {
                consolidator = null;
                return(new IRowCursor[] { GetRowCursor(predicate, rand) });
            }
            else
            {
                var cursors = Source.GetRowCursorSet(out consolidator, i => predicate(i) || predicate(SchemaHelper.NeedColumn(_columnMapping, i)),
                                                     n, rand);
                for (int i = 0; i < cursors.Length; ++i)
                {
                    cursors[i] = new AddRandomCursor(this, cursors[i]);
                }
                return(cursors);
            }
        }
Пример #2
0
        public DataViewRowCursor[] GetRowCursorSet(IEnumerable <DataViewSchema.Column> columnsNeeded, int n, Random rand = null)
        {
            n = DataViewUtils.GetThreadCount(n);

            if (n <= 1)
            {
                return new DataViewRowCursor[] { GetRowCursor(columnsNeeded, rand) }
            }
            ;
            else
            {
                //var cols = SchemaHelper.ColumnsNeeded(columnsNeeded, Schema, _args.columns);
                var cols = SchemaHelper.ColumnsNeeded(columnsNeeded, Source.Schema);

                var cursors = Source.GetRowCursorSet(cols, n, rand);
                for (int i = 0; i < cursors.Length; ++i)
                {
                    cursors[i] = new AddRandomCursor(this, cursors[i]);
                }
                return(cursors);
            }
        }