コード例 #1
0
        public override IEnumerable <IRow> Extract(IUnstructuredReader input, IUpdatableRow output)
        {
            var parser = new InternalParser(output.Schema, this.expressions);

            foreach (Stream current in input.Split((byte)'\n'))
            {
                var row = parser.ParseEvent(output, current);
                if (row != null)
                {
                    yield return(row);
                }
            }
        }
コード例 #2
0
        public override IEnumerable <IRow> Extract(IUnstructuredReader input, IUpdatableRow output)
        {
            var  parser = new InternalParser(output.Schema, this.expressions);
            int  idxParseError;
            bool hasParseError = HasColumnOfType(output.Schema, "ParseError", typeof(string), out idxParseError);

            foreach (Stream current in input.Split((byte)'\n'))
            {
                IRow row;
                try
                {
                    if (hasParseError)
                    {
                        output.Set <string>(idxParseError, null);
                    }

                    row = parser.ParseEvent(output, current);
                }
                catch (Exception e)
                {
                    if (hasParseError)
                    {
                        output.Set <string>(idxParseError, $"ParseError: {e.Message}");
                        row = output.AsReadOnly();
                    }
                    else
                    {
                        row = null;
                    }
                }
                if (row != null)
                {
                    yield return(row);
                }
            }
        }