public RowCursor(IChannelProvider provider, int poolRows, IRowCursor input, IRandom rand) : base(provider) { Ch.AssertValue(input); Ch.AssertValue(rand); Ch.Assert(_blockSize > 0); Ch.Assert(_bufferDepth > 0); Ch.Assert(poolRows > 0); _poolRows = poolRows; _input = input; _rand = rand; _pipeIndices = Utils.GetIdentityPermutation(_poolRows - 1 + _bufferDepth * _blockSize); int colLim = Schema.ColumnCount; int numActive = 0; _colToActivesIndex = new int[colLim]; for (int c = 0; c < colLim; ++c) { _colToActivesIndex[c] = _input.IsColumnActive(c) ? numActive++ : -1; } _pipes = new ShufflePipe[numActive + (int)ExtraIndex.Lim]; _getters = new Delegate[numActive]; for (int c = 0; c < colLim; ++c) { int ia = _colToActivesIndex[c]; if (ia < 0) { continue; } _pipes[ia] = ShufflePipe.Create(_pipeIndices.Length, input.Schema.GetColumnType(c), RowCursorUtils.GetGetterAsDelegate(input, c)); _getters[ia] = CreateGetterDelegate(c); } var idPipe = _pipes[numActive + (int)ExtraIndex.Id] = ShufflePipe.Create(_pipeIndices.Length, NumberType.UG, input.GetIdGetter()); _idGetter = CreateGetterDelegate <UInt128>(idPipe); // Initially, after the preamble to MoveNextCore, we want: // liveCount=0, deadCount=0, circularIndex=0. So we set these // funky values accordingly. _pipeIndex = _circularIndex = _pipeIndices.Length - 1; _deadCount = -1; _liveCount = 1; // Set up the producer worker. _toConsume = new BufferBlock <int>(); _toProduce = new BufferBlock <int>(); // First request the pool - 1 + block size rows, to get us going. PostAssert(_toProduce, _poolRows - 1 + _blockSize); // Queue up the remaining capacity. for (int i = 1; i < _bufferDepth; ++i) { PostAssert(_toProduce, _blockSize); } _producerTask = LoopProducerWorker(); }
public bool IsColumnActive(int col) { if (col < _inputCursor.Schema.ColumnCount) { return(_inputCursor.IsColumnActive(col)); } return(true); }
public bool IsColumnActive(int col) { Contracts.CheckParam(0 <= col && col < Schema.ColumnCount, nameof(col)); bool isSrc; int iCol = _parent._bindings.MapColumnIndex(out isSrc, col); if (isSrc) { return(_input.IsColumnActive(iCol)); } return(_appendedRow.IsColumnActive(iCol)); }
public bool IsColumnActive(int col) { Ch.CheckParam(0 <= col && col < _colToActivesIndex.Length, nameof(col)); Ch.Assert((_colToActivesIndex[col] >= 0) == _input.IsColumnActive(col)); return(_input.IsColumnActive(col)); }
public bool IsColumnActive(int col) { return(_columns.ContainsKey(col) || _needCol(col) || (_otherValues != null && _otherValues.IsColumnActive(col))); }
protected bool CheckSameValues(IRowCursor curs1, IDataView view2, bool exactTypes = true, bool exactDoubles = true, bool checkId = true) { Contracts.Assert(curs1.Schema.ColumnCount == view2.Schema.ColumnCount); // Get a cursor for each column. int colLim = curs1.Schema.ColumnCount; var cursors = new IRowCursor[colLim]; try { for (int col = 0; col < colLim; col++) { // curs1 should have all columns active (for simplicity of the code here). Contracts.Assert(curs1.IsColumnActive(col)); cursors[col] = view2.GetRowCursor(c => c == col); } // Get the comparison delegates for each column. Func <bool>[] comps = new Func <bool> [colLim]; // We have also one ID comparison delegate for each cursor. Func <bool>[] idComps = new Func <bool> [cursors.Length]; for (int col = 0; col < colLim; col++) { Contracts.Assert(cursors[col] != null); var type1 = curs1.Schema.GetColumnType(col); var type2 = cursors[col].Schema.GetColumnType(col); if (!EqualTypes(type1, type2, exactTypes)) { Fail("Different types"); return(Failed()); } comps[col] = GetColumnComparer(curs1, cursors[col], col, type1, exactDoubles); ValueGetter <UInt128> idGetter; idComps[col] = checkId ? GetIdComparer(curs1, cursors[col], out idGetter) : null; } for (; ;) { bool f1 = curs1.MoveNext(); for (int col = 0; col < colLim; col++) { bool f2 = cursors[col].MoveNext(); if (f1 != f2) { if (f1) { Fail("Left has more rows at position: {0}", curs1.Position); } else { Fail("Right {0} has more rows at position: {1}", col, cursors[2].Position); } return(Failed()); } } if (!f1) { return(true); } for (int col = 0; col < colLim; col++) { Contracts.Assert(curs1.Position == cursors[col].Position); var comp = comps[col]; if (comp != null && !comp()) { Fail("Different values in column {0} of row {1}", col, curs1.Position); return(Failed()); } comp = idComps[col]; if (comp != null && !comp()) { Fail("Different values in ID values for column {0} cursor of row {1}", col, curs1.Position); return(Failed()); } } } } finally { for (int col = 0; col < colLim; col++) { var c = cursors[col]; if (c != null) { c.Dispose(); } } } }
public bool IsColumnActive(int col) { return(col == _view._column || _needCol(col) || (_otherValues != null && _otherValues.IsColumnActive(col))); }
protected bool CheckSameValues(IRowCursor curs1, IRowCursor curs2, bool exactTypes, bool exactDoubles, bool checkId, bool checkIdCollisions = true) { Contracts.Assert(curs1.Schema.ColumnCount == curs2.Schema.ColumnCount); // Get the comparison delegates for each column. int colLim = curs1.Schema.ColumnCount; Func <bool>[] comps = new Func <bool> [colLim]; for (int col = 0; col < colLim; col++) { var f1 = curs1.IsColumnActive(col); var f2 = curs2.IsColumnActive(col); if (f1 && f2) { var type1 = curs1.Schema.GetColumnType(col); var type2 = curs2.Schema.GetColumnType(col); if (!EqualTypes(type1, type2, exactTypes)) { Fail("Different types"); return(Failed()); } comps[col] = GetColumnComparer(curs1, curs2, col, type1, exactDoubles); } } ValueGetter <UInt128> idGetter = null; Func <bool> idComp = checkId ? GetIdComparer(curs1, curs2, out idGetter) : null; HashSet <UInt128> idsSeen = null; if (checkIdCollisions && idGetter == null) { idGetter = curs1.GetIdGetter(); } long idCollisions = 0; UInt128 id = default(UInt128); for (; ;) { bool f1 = curs1.MoveNext(); bool f2 = curs2.MoveNext(); if (f1 != f2) { if (f1) { Fail("Left has more rows at position: {0}", curs1.Position); } else { Fail("Right has more rows at position: {0}", curs2.Position); } return(Failed()); } if (!f1) { if (idCollisions > 0) { Fail("{0} id collisions among {1} items", idCollisions, Utils.Size(idsSeen) + idCollisions); } return(idCollisions == 0); } else if (checkIdCollisions) { idGetter(ref id); if (!Utils.Add(ref idsSeen, id)) { if (idCollisions == 0) { idCollisions++; } } } Contracts.Assert(curs1.Position == curs2.Position); for (int col = 0; col < colLim; col++) { var comp = comps[col]; if (comp != null && !comp()) { Fail("Different values in column {0} of row {1}", col, curs1.Position); return(Failed()); } if (idComp != null && !idComp()) { Fail("Different values in ID of row {0}", curs1.Position); return(Failed()); } } } }
public bool IsColumnActive(int col) { return(col >= _inputCursor.Schema.ColumnCount || _inputCursor.IsColumnActive(col)); }
public bool IsColumnActive(int col) { return(_cursor.IsColumnActive(col)); }
public bool IsColumnActive(int col) { // The column is active if is active in the input view or if it the new vector with the polynomial features. return(col >= _inputCursor.Schema.ColumnCount || _inputCursor.IsColumnActive(col)); }
public bool IsColumnActive(int col) { // The column is active if is active in the input view or if it the new vector with the polynomial features. return(_predicate(col) && _inputCursor.IsColumnActive(col)); }