Exemplo n.º 1
0
        private IList ReadDictionaryPage(Thrift.PageHeader ph)
        {
            //Dictionary page format: the entries in the dictionary - in dictionary order - using the plain enncoding.

            byte[] data = ReadRawBytes(ph, _inputStream);

            using (var dataStream = new MemoryStream(data))
            {
                using (var dataReader = new BinaryReader(dataStream))
                {
                    IList result = TypeFactory.Create(_schema, _options);
                    _plainReader.Read(dataReader, _schema, result, int.MaxValue);
                    return(result);
                }
            }
        }
        public void Array_of_booleans_writes_and_reads()
        {
            var bools = new List <bool>();

            bools.AddRange(new[] { true, false, true });

            var schema = new SchemaElement <bool>("bool");

            _writer.Write(_bw, schema, bools, out IList extra);

            _ms.Position = 0;

            var boolsRead = new List <bool?>();

            _reader.Read(_br, schema, boolsRead, 3);

            Assert.Equal(bools, boolsRead.Cast <bool>().ToList());
        }
Exemplo n.º 3
0
        private List <int> ReadColumnValues(BinaryReader reader, Thrift.Encoding encoding, IList destination, long maxValues)
        {
            //dictionary encoding uses RLE to encode data

            switch (encoding)
            {
            case Thrift.Encoding.PLAIN:
                _plainReader.Read(reader, _schema, destination, maxValues);
                return(null);

            case Thrift.Encoding.RLE:
                var rleIndexes = new List <int>();
                _rleReader.Read(reader, _schema, rleIndexes, maxValues);
                return(rleIndexes);

            case Thrift.Encoding.PLAIN_DICTIONARY:
                var dicIndexes = new List <int>();
                _dictionaryReader.Read(reader, _schema, dicIndexes, maxValues);
                return(dicIndexes);

            default:
                throw new ParquetException($"encoding {encoding} is not supported."); //todo: replace with own exception type
            }
        }