Azavea.Open.DAO.Util.CachingDataReader.CachingDataReader C# (CSharp) Method

CachingDataReader() protected method

Create the data reader.
protected CachingDataReader ( DataReaderConfig config ) : System
config DataReaderConfig The column indexes in the data, keyed by column name. This may include /// columns not in the mapping.
return System
        protected CachingDataReader(DataReaderConfig config)
        {
            _config = config;
            _indexesByName = config.IndexesByName;
            // It is possible to be skipping columns, so figure out the highest
            // column index and we'll assume there are that many columns.  It's easier
            // that way than mapping column 5 to 3 when reading just because we skipped a couple.
            int maxColNum = 0;
            foreach (int index in _indexesByName.Values)
            {
                if (index > maxColNum)
                {
                    maxColNum = index;
                }
            }
            _numCols = maxColNum + 1;

            // This will have nulls for skipped columns.
            _namesByIndex = new string[_numCols];
            foreach (KeyValuePair<string, int> indexByName in _indexesByName)
            {
                _namesByIndex[indexByName.Value] = indexByName.Key;
            }
            _valsByIndex = new object[_numCols];
        }