Ejemplo n.º 1
0
        public ChoParquetReader(Stream inStream, ChoParquetRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(inStream, "Stream");

            Configuration = configuration;
            Init();

            if (inStream is MemoryStream)
            {
                _streamReader = new Lazy <StreamReader>(() => new StreamReader(inStream));
            }
            else
            {
                _streamReader = new Lazy <StreamReader>(() =>
                {
                    if (Configuration.DetectEncodingFromByteOrderMarks == null)
                    {
                        return(new StreamReader(inStream, Configuration.GetEncoding(inStream), false, Configuration.BufferSize));
                    }
                    else
                    {
                        return(new StreamReader(inStream, Encoding.Default, Configuration.DetectEncodingFromByteOrderMarks.Value, Configuration.BufferSize));
                    }
                });
            }
            //_closeStreamOnDispose = true;
        }
Ejemplo n.º 2
0
        public ChoParquetWriter(StreamWriter streamWriter, ChoParquetRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(streamWriter, "StreamWriter");

            Configuration = configuration;
            Init();

            _streamWriter = new Lazy <StreamWriter>(() => streamWriter);
        }
Ejemplo n.º 3
0
        public ChoParquetReader(ParquetReader parquetReader, ChoParquetRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(parquetReader, "ParquetReader");

            Configuration = configuration;
            Init();

            _parquetReader = parquetReader;
        }
Ejemplo n.º 4
0
        private void Init()
        {
            var recordType = typeof(T).GetUnderlyingType();
            if (Configuration == null)
                Configuration = new ChoParquetRecordConfiguration(recordType);

            _writer = new ChoParquetRecordWriter(recordType, Configuration);
            _writer.RowsWritten += NotifyRowsWritten;
        }
Ejemplo n.º 5
0
        private void Init()
        {
            if (Configuration == null)
            {
                Configuration = new ChoParquetRecordConfiguration(typeof(T));
            }

            _writer              = new ChoParquetRecordWriter(typeof(T), Configuration);
            _writer.RowsWritten += NotifyRowsWritten;
        }
Ejemplo n.º 6
0
        public ChoParquetRecordReader(Type recordType, ChoParquetRecordConfiguration configuration) : base(recordType, false)
        {
            ChoGuard.ArgumentNotNull(configuration, "Configuration");
            Configuration = configuration;

            _callbackRecordFieldRead     = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldRead>(recordType);
            _callbackFileRead            = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileRead>(recordType);
            _callbackRecordRead          = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordRead>(recordType);
            _callbackRecordSeriablizable = ChoMetadataObjectCache.CreateMetadataObject <IChoRecordFieldSerializable>(recordType);
        }
Ejemplo n.º 7
0
        public ChoParquetWriter(string filePath, ChoParquetRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _streamWriter         = new Lazy <StreamWriter>(() => new StreamWriter(filePath, false, Configuration.GetEncoding(filePath), Configuration.BufferSize));
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 8
0
        public ChoParquetReader(string filePath, ChoParquetRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _sr = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 9
0
        public ChoParquetWriter(Stream inStream, ChoParquetRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(inStream, "Stream");

            Configuration = configuration;
            Init();

            if (inStream is MemoryStream)
                _streamWriter = new StreamWriter(inStream);
            else
                _streamWriter = new StreamWriter(inStream, Configuration.Encoding, Configuration.BufferSize);
            //_closeStreamOnDispose = true;
        }
Ejemplo n.º 10
0
        private void Init()
        {
            var recordType = typeof(T).GetUnderlyingType();

            if (Configuration == null)
            {
                Configuration = new ChoParquetRecordConfiguration(recordType);
            }
            else
            {
                Configuration.RecordType = recordType;
            }

            _writer              = new ChoParquetRecordWriter(recordType, Configuration);
            _writer.RowsWritten += NotifyRowsWritten;
            _writer.NewRowGroup += OnNewRowGroup;
        }
Ejemplo n.º 11
0
        public ChoParquetReader(Stream inStream, ChoParquetRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNull(inStream, "Stream");

            Configuration = configuration;
            Init();

            if (inStream is MemoryStream)
            {
                _sr = new StreamReader(inStream);
            }
            else
            {
                _sr = new StreamReader(inStream, Configuration.GetEncoding(inStream), false, Configuration.BufferSize);
            }
            //_closeStreamOnDispose = true;
        }
Ejemplo n.º 12
0
        private void Init()
        {
            _enumerator = new Lazy <IEnumerator <T> >(() => GetEnumerator());
            if (Configuration == null)
            {
                Configuration = new ChoParquetRecordConfiguration(typeof(T));
            }
            else
            {
                Configuration.RecordType = typeof(T);
            }

            Configuration.RecordType      = Configuration.RecordType.GetUnderlyingType();
            Configuration.IsDynamicObject = Configuration.RecordType.IsDynamicType();
            _prevCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = Configuration.Culture;
        }
Ejemplo n.º 13
0
        private void Init()
        {
            _enumerator = new Lazy <IEnumerator <T> >(() => GetEnumerator());

            var recordType = typeof(T).GetUnderlyingType();

            if (Configuration == null)
            {
                Configuration = new ChoParquetRecordConfiguration(recordType);
            }
            else
            {
                Configuration.RecordType = recordType;
            }
            Configuration.IsDynamicObject = Configuration.RecordType.IsDynamicType();

            if (!ChoETLFrxBootstrap.IsSandboxEnvironment)
            {
                _prevCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture;
                System.Threading.Thread.CurrentThread.CurrentCulture = Configuration.Culture;
            }
        }
Ejemplo n.º 14
0
 public ChoParquetWriter(ChoParquetRecordConfiguration configuration = null)
 {
     Configuration = configuration;
     Init();
 }
        internal void Validate(ChoParquetRecordConfiguration config)
        {
            try
            {
                if (!AltFieldNames.IsNullOrWhiteSpace())
                {
                    AltFieldNamesArray = AltFieldNames.SplitNTrim();
                }

                if (FieldName.IsNullOrWhiteSpace())
                {
                    FieldName = Name;
                }
                if (FieldPosition <= 0)
                {
                    throw new ChoRecordConfigurationException("Invalid '{0}' field position specified. Must be > 0.".FormatString(FieldPosition));
                }
                if (FillChar != null)
                {
                    if (FillChar.Value == ChoCharEx.NUL)
                    {
                        throw new ChoRecordConfigurationException("Invalid '{0}' FillChar specified.".FormatString(FillChar));
                    }
                    if (config.EOLDelimiter.Contains(FillChar.Value))
                    {
                        throw new ChoRecordConfigurationException("FillChar [{0}] can't be one of EOLDelimiter characters [{1}]".FormatString(FillChar, config.EOLDelimiter));
                    }
                }
                if (config.Comments != null)
                {
                    if ((from comm in config.Comments
                         where comm.Contains(FillChar.ToNString(' '))
                         select comm).Any())
                    {
                        throw new ChoRecordConfigurationException("One of the Comments contains FillChar. Not allowed.");
                    }
                    if ((from comm in config.Comments
                         where comm.Contains(config.EOLDelimiter)
                         select comm).Any())
                    {
                        throw new ChoRecordConfigurationException("One of the Comments contains EOLDelimiter. Not allowed.");
                    }
                }

                if (Size != null && Size.Value <= 0)
                {
                    throw new ChoRecordConfigurationException("Size must be > 0.");
                }
                if (ErrorMode == null)
                {
                    ErrorMode = config.ErrorMode; // config.ErrorMode;
                }
                if (IgnoreFieldValueMode == null)
                {
                    IgnoreFieldValueMode = config.IgnoreFieldValueMode;
                }
                if (QuoteField == null)
                {
                    QuoteField = config.QuoteAllFields;
                }
                if (NullValue == null)
                {
                    NullValue = config.NullValue;
                }
            }
            catch (Exception ex)
            {
                throw new ChoRecordConfigurationException("Invalid configuration found at '{0}' field.".FormatString(Name), ex);
            }
        }