Exemple #1
0
        public int ProcessBatch(IEnumerable <IEnumerable <string> > buffer, int batchSize, ScheduleType scheduleType,
                                BatchArgs batchArgs)
        {
            if (_reader == null)
            {
                throw new InvalidOperationException("CifParser not initialized");
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (batchSize < 1)
            {
                throw new ArgumentException("batchSize must be greater than zero", nameof(batchSize));
            }

            IEnumerable <CifRecordBase> recordDefs     = _recordDefFactory.GetRecordDefs(scheduleType);
            List <List <string> >       internalBuffer = new List <List <string> >();

            string        line       = null;
            List <string> lineValues = new List <string>();

            do
            {
                line = _reader.ReadLine();
                if (line == null)
                {
                    continue;
                }

                lineValues = ParseLine(line, recordDefs);
                if (lineValues.Count > 0)
                {
                    internalBuffer.Add(lineValues);
                }
            } while (line != null && internalBuffer.Count < batchSize);

            ((List <List <string> >)buffer).Clear();
            ((List <List <string> >)buffer).AddRange(internalBuffer);

            return(internalBuffer.Count);
        }
Exemple #2
0
        public int ProcessBatch(IEnumerable <IEnumerable <string> > buffer, int batchSize, ScheduleType scheduleType,
                                BatchArgs batchArgs)
        {
            if (_reader == null)
            {
                throw new InvalidOperationException("CifEditor not initialized");
            }
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }
            if (batchArgs == null)
            {
                throw new ArgumentNullException(nameof(batchArgs));
            }

            _scheduleCriteria = GetScheduleCriteria(batchArgs);

            IEnumerable <CifRecordBase> recordDefs = _recordDefFactory.GetRecordDefs(scheduleType);

            _buffer = new List <string>();

            return(DoProcessBatch(buffer, batchSize, recordDefs));
        }