コード例 #1
0
        /// <summary>
        /// Creates an instance from input stream
        /// </summary>
        /// <param name="input">Input stream, must be readable and seekable</param>
        /// <param name="parquetOptions">Optional reader options</param>
        /// <param name="readerOptions">The reader options.</param>
        /// <exception cref="ArgumentNullException">input</exception>
        /// <exception cref="ArgumentException">stream must be readable and seekable - input</exception>
        /// <exception cref="IOException">not a Parquet file (size too small)</exception>
        public ParquetReader3(Stream input, ParquetOptions parquetOptions = null, ReaderOptions readerOptions = null) : base(input)
        {
            _input = input ?? throw new ArgumentNullException(nameof(input));
            if (!input.CanRead || !input.CanSeek)
            {
                throw new ArgumentException("stream must be readable and seekable", nameof(input));
            }
            if (_input.Length <= 8)
            {
                throw new IOException("not a Parquet file (size too small)");
            }

            ValidateFile();
            _parquetOptions = parquetOptions ?? new ParquetOptions();
            _readerOptions  = readerOptions ?? new ReaderOptions();

            //read metadata instantly, now
            _meta   = ReadMetadata();
            _footer = new ThriftFooter(_meta);

            InitRowGroupReaders();
        }
コード例 #2
0
 /// <summary>
 /// Reads <see cref="DataSet"/> from an open stream
 /// </summary>
 /// <param name="source">Input stream</param>
 /// <param name="formatOptions">Parquet options, optional.</param>
 /// <param name="readerOptions">Reader options, optional</param>
 /// <returns><see cref="DataSet"/></returns>
 public static DataSet Read(Stream source, ParquetOptions formatOptions = null, ReaderOptions readerOptions = null)
 {
     using (var reader = new ParquetReader(source, formatOptions, readerOptions))
     {
         return(reader.Read());
     }
 }
コード例 #3
0
 /// <summary>
 /// Reads the file
 /// </summary>
 /// <param name="fullPath">The full path.</param>
 /// <param name="formatOptions">Optional reader options.</param>
 /// <param name="readerOptions">The reader options.</param>
 /// <returns><see cref="DataSet"/></returns>
 public static DataSet ReadFile(string fullPath, ParquetOptions formatOptions = null, ReaderOptions readerOptions = null)
 {
     using (Stream fs = System.IO.File.OpenRead(fullPath))
     {
         using (var reader = new ParquetReader(fs, formatOptions, readerOptions))
         {
             return(reader.Read());
         }
     }
 }