public RandCursor(AppendRowsDataView parent, Func <int, bool> needCol, IRandom rand, int[] counts) : base(parent) { Ch.AssertValue(needCol); Ch.AssertValue(rand); _rand = rand; Ch.AssertValue(counts); Ch.Assert(Sources.Length == counts.Length); _cursorSet = new IRowCursor[counts.Length]; for (int i = 0; i < counts.Length; i++) { Ch.Assert(counts[i] >= 0); _cursorSet[i] = parent._sources[i].GetRowCursor(needCol, RandomUtils.Create(_rand)); } _sampler = new MultinomialWithoutReplacementSampler(Ch, counts, rand); _currentSourceIndex = -1; for (int c = 0; c < Getters.Length; c++) { if (needCol(c)) { Getters[c] = CreateGetter(c); } } }
public RandCursor(AppendRowsDataView parent, IEnumerable <Schema.Column> columnsNeeded, Random rand, int[] counts) : base(parent) { Ch.AssertValue(rand); _rand = rand; Ch.AssertValue(counts); Ch.Assert(Sources.Length == counts.Length); _cursorSet = new RowCursor[counts.Length]; for (int i = 0; i < counts.Length; i++) { Ch.Assert(counts[i] >= 0); _cursorSet[i] = parent._sources[i].GetRowCursor(columnsNeeded, RandomUtils.Create(_rand)); } _sampler = new MultinomialWithoutReplacementSampler(Ch, counts, rand); _currentSourceIndex = -1; foreach (var col in columnsNeeded) { Getters[col.Index] = CreateGetter(col.Index); } }