Example #1
0
        internal void Initialize(int[] columns, StreamReader stream)
        {
            this.Columns = columns;
            stream.BaseStream.Seek(0, SeekOrigin.Begin);

            // The first line is the column headers, which we don't need.

            var  headerLine = stream.ReadLine();
            long offset     = headerLine.Length + _numberOfLineEndingCharacters;

            // Read the actual data lines.

            string line;

            _index = new SortedDictionary <string, List <long> >();

            while ((line = stream.ReadLine()) != null)
            {
                var         record         = new QuarterlyDatabaseRecord(line);
                var         constructedKey = ConstructKey(columns, record);
                List <long> offsetList;
                if (_index.TryGetValue(constructedKey, out offsetList) == false)
                {
                    offsetList = new List <long>();
                    _index.Add(constructedKey, offsetList);
                }
                offsetList.Add(offset);
                offset += line.Length + _numberOfLineEndingCharacters;
            }
        }
Example #2
0
        private string ConstructKey(int[] columns, QuarterlyDatabaseRecord record)
        {
            var constructedKey = new StringBuilder();

            foreach (int currentColumn in columns)
            {
                constructedKey.Append(record[currentColumn]);
            }
            return(constructedKey.ToString());
        }