public DataViewRowCursor[] GetRowCursorSet(IEnumerable <DataViewSchema.Column> columnsNeeded, int n, Random rand = null) { DataKind kind; if (_toShake[0].OutputType.IsVector()) { kind = _toShake[0].OutputType.AsVector().ItemType().RawKind(); } else { kind = _toShake[0].OutputType.RawKind(); } var newCols = PredicatePropagation(columnsNeeded); var oldCols = SchemaHelper.ColumnsNeeded(newCols, _input.Schema); switch (kind) { case DataKind.Single: var cursors = _input.GetRowCursorSet(oldCols, n, rand); return(cursors.Select(c => new ShakeInputCursor <TInput, float>(this, c, newCols, _args, _inputCol, _toShake, _shakingValues, (float x, float y) => { return x + y; })).ToArray()); default: throw _host.Except("Not supported RawKind {0}", _toShake[0].OutputType.RawKind()); } }
public DataViewRowCursor GetRowCursor(IEnumerable <DataViewSchema.Column> columnsNeeded, Random rand = null) { //var cols = SchemaHelper.ColumnsNeeded(columnsNeeded, Schema, _args.columns); var cols = SchemaHelper.ColumnsNeeded(columnsNeeded, Source.Schema); var cur = Source.GetRowCursor(cols); return(new AddRandomCursor(this, cur)); }
public DataViewRowCursor GetRowCursor(IEnumerable <DataViewSchema.Column> columnsNeeded, Random rand = null) { ComputeStatistics(); _host.AssertValue(_input, "_input"); var newColumnsNeeded = SchemaHelper.ColumnsNeeded(columnsNeeded, Schema, _args.columns); var oldCols = SchemaHelper.ColumnsNeeded(newColumnsNeeded, _input.Schema); var cursor = _input.GetRowCursor(oldCols, rand); return(new ScalerCursor(cursor, this, newColumnsNeeded)); }
public DataViewRowCursor[] GetRowCursorSet(IEnumerable <DataViewSchema.Column> columnsNeeded, int n, Random rand = null) { ComputeStatistics(); _host.AssertValue(_input, "_input"); var newColumnsNeeded = SchemaHelper.ColumnsNeeded(columnsNeeded, Schema, _args.columns); var oldCols = SchemaHelper.ColumnsNeeded(newColumnsNeeded, _input.Schema); var cursors = _input.GetRowCursorSet(oldCols, n, rand); var res = cursors.Select(c => new ScalerCursor(c, this, newColumnsNeeded)).ToArray(); return(res); }
protected override DataViewRowCursor GetRowCursorCore(IEnumerable <DataViewSchema.Column> columnsNeeded, Random rand = null) { Host.Check(string.IsNullOrEmpty(_sortColumn) || rand == null, "Random access is not allowed on sorted data. (5)"); Host.AssertValue(_transform, "_transform"); int sortColumn = -1; if (!string.IsNullOrEmpty(_sortColumn)) { sortColumn = SchemaHelper.GetColumnIndex(Source.Schema, _sortColumn); } return(_transform.GetRowCursor(SchemaHelper.ColumnsNeeded(columnsNeeded, _transform.Schema, _sortColumn), rand)); }
public override DataViewRowCursor[] GetRowCursorSet(IEnumerable <DataViewSchema.Column> columnsNeeded, int n, Random rand = null) { Host.Check(string.IsNullOrEmpty(_sortColumn) || rand == null, "Random access is not allowed on sorted data. (6)"); Host.AssertValue(_transform, "_transform"); if (string.IsNullOrEmpty(_sortColumn)) { return(_transform.GetRowCursorSet(columnsNeeded, n, rand)); } else { int sortColumn = SchemaHelper.GetColumnIndex(Source.Schema, _sortColumn); return(_transform.GetRowCursorSet(SchemaHelper.ColumnsNeeded(columnsNeeded, _transform.Schema, _sortColumn), n, rand)); } }
public DataViewRowCursor GetRowCursor(IEnumerable <DataViewSchema.Column> columnsNeeded, Random rand = null) { if (columnsNeeded.Where(c => c.Index == _input.Schema.Count).Any()) { var newColumns = SchemaHelper.ColumnsNeeded(columnsNeeded, Schema, _args.columns); var oldColumns = SchemaHelper.ColumnsNeeded(columnsNeeded, _input.Schema); var cursor = _input.GetRowCursor(oldColumns, rand); return(new PolynomialCursor <TInput>(this, cursor, newColumns, _args, _inputCol, _multiplication)); } else { // The new column is not required. We do not need to compute it. But we need to keep the same schema. return(new SameCursor(_input.GetRowCursor(columnsNeeded, rand), this.Schema)); } }
private DataViewRowCursor GetRowCursor(IEnumerable <DataViewSchema.Column> columnsNeeded, Random rand, DelegateGetRowCursor getterCursor) { int index = SchemaHelper.GetColumnIndex(Source.Schema, _parent.InputName); if (columnsNeeded.Where(c => c.Index == index).Any()) { var newCols = SchemaHelper.ColumnsNeeded(columnsNeeded, Schema, index, Schema.Count); var oldCols = SchemaHelper.ColumnsNeeded(newCols, Source.Schema); var cursor = getterCursor(oldCols, rand); return(new MemoryCursor <TSrc, TDst>(this, cursor, index)); } else { // The new column is not required. We do not need to compute it. But we need to keep the same schema. return(new SameCursor(getterCursor(columnsNeeded, rand), Schema)); } }
public DataViewRowCursor[] GetRowCursorSet(IEnumerable <DataViewSchema.Column> columnsNeeded, int n, Random rand = null) { int index = SchemaHelper.GetColumnIndex(Source.Schema, _parent.InputName); if (columnsNeeded.Where(c => c.Index == index).Any()) { var newCols = SchemaHelper.ColumnsNeeded(columnsNeeded, Schema, index, Schema.Count); var oldCols = SchemaHelper.ColumnsNeeded(newCols, Source.Schema); var cursors = Source.GetRowCursorSet(oldCols, n, rand); return(cursors.Select(c => new MemoryCursor <TSrc, TDst>(this, c, index)).ToArray()); } else { // The new column is not required. We do not need to compute it. But we need to keep the same schema. return(Source.GetRowCursorSet(columnsNeeded, n, rand) .Select(c => new SameCursor(c, Schema)) .ToArray()); } }
private DataViewRowCursor GetRowCursor(IEnumerable <DataViewSchema.Column> columnsNeeded, Random rand, DelegateGetRowCursor getterCursor) { ComputeNearestNeighbors(); _host.AssertValue(_input, "_input"); var schema = _input.Schema; if (columnsNeeded.Where(c => c.Index == _input.Schema.Count).Any()) { var newColumns = PredicatePropagation(columnsNeeded); var oldCols = SchemaHelper.ColumnsNeeded(newColumns, schema); var featureIndex = SchemaHelper.GetColumnIndexDC(Schema, _args.column); return(new NearestNeighborsCursor(getterCursor(oldCols, rand), this, newColumns, featureIndex)); } else { // The new column is not required. We do not need to compute it. But we need to keep the same schema. var oldCols = SchemaHelper.ColumnsNeeded(columnsNeeded, schema); return(new SameCursor(getterCursor(oldCols, rand), Schema)); } }
private DataViewRowCursor GetRowCursor(IEnumerable <DataViewSchema.Column> columnsNeeded, Random rand, DelegateGetRowCursor getterCursor) { var kind = _toShake[0].OutputType.IsVector() ? _toShake[0].OutputType.ItemType().RawKind() : _toShake[0].OutputType.RawKind(); var newCols = PredicatePropagation(columnsNeeded); var oldCols = SchemaHelper.ColumnsNeeded(newCols, _input.Schema); switch (kind) { case DataKind.Single: var cursor = getterCursor(oldCols, rand); return(new ShakeInputCursor <TInput, float>(this, cursor, newCols, _args, _inputCol, _toShake, _shakingValues, (float x, float y) => { return x + y; })); default: throw _host.Except("Not supported RawKind {0}", _toShake[0].OutputType.RawKind()); } }
public DataViewRowCursor[] GetRowCursorSet(IEnumerable <DataViewSchema.Column> columnsNeeded, int n, Random rand = null) { ComputeNearestNeighbors(); _host.AssertValue(_input, "_input"); var schema = _input.Schema; if (columnsNeeded.Where(c => c.Index == _input.Schema.Count).Any()) { var newColumns = PredicatePropagation(columnsNeeded); var oldCols = SchemaHelper.ColumnsNeeded(newColumns, schema); var featureIndex = SchemaHelper.GetColumnIndexDC(Schema, _args.column); var res = _input.GetRowCursorSet(oldCols, n, rand) .Select(c => new NearestNeighborsCursor(c, this, newColumns, featureIndex)).ToArray(); return(res); } else { // The new column is not required. We do not need to compute it. But we need to keep the same schema. var oldCols = SchemaHelper.ColumnsNeeded(columnsNeeded, schema); return(_input.GetRowCursorSet(oldCols, n, rand).Select(c => new SameCursor(c, Schema)).ToArray()); } }
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); } }