1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18#include <gtest/gtest.h>
19
20#include <string>
21
22#include "parquet/file_reader.h"
23#include "parquet/properties.h"
24
25namespace parquet {
26
27using schema::ColumnPath;
28
29namespace test {
30
31TEST(TestReaderProperties, Basics) {
32 ReaderProperties props;
33
34 ASSERT_EQ(DEFAULT_BUFFER_SIZE, props.buffer_size());
35 ASSERT_EQ(DEFAULT_USE_BUFFERED_STREAM, props.is_buffered_stream_enabled());
36}
37
38TEST(TestWriterProperties, Basics) {
39 std::shared_ptr<WriterProperties> props = WriterProperties::Builder().build();
40
41 ASSERT_EQ(DEFAULT_PAGE_SIZE, props->data_pagesize());
42 ASSERT_EQ(DEFAULT_DICTIONARY_PAGE_SIZE_LIMIT, props->dictionary_pagesize_limit());
43 ASSERT_EQ(DEFAULT_WRITER_VERSION, props->version());
44}
45
46TEST(TestWriterProperties, AdvancedHandling) {
47 WriterProperties::Builder builder;
48 builder.compression("gzip", Compression::GZIP);
49 builder.compression("zstd", Compression::ZSTD);
50 builder.compression(Compression::SNAPPY);
51 builder.encoding(Encoding::DELTA_BINARY_PACKED);
52 builder.encoding("delta-length", Encoding::DELTA_LENGTH_BYTE_ARRAY);
53 std::shared_ptr<WriterProperties> props = builder.build();
54
55 ASSERT_EQ(Compression::GZIP, props->compression(ColumnPath::FromDotString("gzip")));
56 ASSERT_EQ(Compression::ZSTD, props->compression(ColumnPath::FromDotString("zstd")));
57 ASSERT_EQ(Compression::SNAPPY,
58 props->compression(ColumnPath::FromDotString("delta-length")));
59 ASSERT_EQ(Encoding::DELTA_BINARY_PACKED,
60 props->encoding(ColumnPath::FromDotString("gzip")));
61 ASSERT_EQ(Encoding::DELTA_LENGTH_BYTE_ARRAY,
62 props->encoding(ColumnPath::FromDotString("delta-length")));
63}
64
65} // namespace test
66} // namespace parquet
67