public override void Dispose()
            {
                if (!_disposed)
                {
                    var disposableState = _state as IDisposable;
                    var disposableSrc   = _src as IDisposable;
                    var disposableDst   = _dst as IDisposable;
                    if (disposableState != null)
                    {
                        disposableState.Dispose();
                    }
                    if (disposableSrc != null)
                    {
                        disposableSrc.Dispose();
                    }
                    if (disposableDst != null)
                    {
                        disposableDst.Dispose();
                    }

                    _input.Dispose();
                    base.Dispose();
                    _disposed = true;
                }
            }
Example #2
0
        public ISlotCursor GetSlotCursor(int col)
        {
            _host.CheckParam(0 <= col && col < _header.ColumnCount, nameof(col));
            var view = _entries[col].GetViewOrNull();

            if (view == null)
            {
                throw _host.ExceptParam(nameof(col), "Bad call to GetSlotCursor on untransposable column '{0}'",
                                        Schema.GetColumnName(col));
            }
            _host.CheckParam(0 <= col && col < _header.ColumnCount, nameof(col));
            // We don't want the type error, if there is one, to be handled by the get-getter, because
            // at the point we've gotten the interior cursor, but not yet constructed the slot cursor.
            ColumnType cursorType  = TransposeSchema.GetSlotType(col).ItemType;
            IRowCursor inputCursor = view.GetRowCursor(c => true);

            try
            {
                return(Utils.MarshalInvoke(GetSlotCursorCore <int>, cursorType.RawType, inputCursor));
            }
            catch (Exception)
            {
                // We've already verified the types so we shouldn't throw here, in principle, but just
                // be extra careful so we're sure to dispose the input cursor.
                if (inputCursor != null)
                {
                    inputCursor.Dispose();
                }
                throw;
            }
        }
 public void Dispose()
 {
     if (!_disposed)
     {
         _input.Dispose();
         Ch.Dispose();
         _disposed = true;
     }
 }
            protected override bool MoveNextCore()
            {
                Ch.AssertValue(_currentCursor);
                while (!_currentCursor.MoveNext())
                {
                    // Mark the current cursor as finished.
                    _currentCursor.Dispose();
                    _currentCursor = null;
                    if (++_currentSourceIndex >= Sources.Length)
                    {
                        return(false);
                    }
                    _currentCursor   = Sources[_currentSourceIndex].GetRowCursor(c => IsColumnActive(c));
                    _currentIdGetter = _currentCursor.GetIdGetter();
                }

                return(true);
            }
Example #5
0
            protected override bool MoveNextCore()
            {
                // Iterate sub cursor or move to the next file.
                while (_subCursor == null || !_subCursor.MoveNext())
                {
                    // Cleanup old sub cursor
                    if (_subCursor != null)
                    {
                        _subCursor.Dispose();
                        _subCursor = null;
                    }

                    if (!TryGetNextPathAndValues(out string path, out string relativePath, out List <string> values))
                    {
                        return(false);
                    }

                    IDataLoader loader = null;
                    try
                    {
                        // Load the sub cursor and reset the data.
                        loader = _parent.CreateLoaderFromBytes(_parent._subLoaderBytes, new MultiFileSource(path));
                    }
                    catch (Exception e)
                    {
                        Ch.Warning($"Failed to load file {path} due to a loader exception. Moving on to the next file. Ex: {e.Message}");
                        continue;
                    }

                    _subCursor = loader.GetRowCursor(col => _subActive[col]);

                    try
                    {
                        UpdateSubGetters();
                        UpdateColumnValues(relativePath, values);
                    }
                    catch (InvalidOperationException e)
                    {
                        // Failed to load this file so skip.
                        Ch.Warning(MessageSensitivity.Schema, e.Message);
                        if (_subCursor != null)
                        {
                            _subCursor.Dispose();
                            _subCursor = null;
                        }
                    }
                }

                return(true);
            }
 public override void Dispose()
 {
     _leadingCursor.Dispose();
     _trailingCursor.Dispose();
     base.Dispose();
 }
 void IDisposable.Dispose()
 {
     _inputCursor.Dispose();
     GC.SuppressFinalize(this);
 }