forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperties_test.cc
More file actions
90 lines (74 loc) · 3.18 KB
/
Copy pathproperties_test.cc
File metadata and controls
90 lines (74 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include <gtest/gtest.h>
#include <string>
#include "arrow/buffer.h"
#include "arrow/io/memory.h"
#include "parquet/file_reader.h"
#include "parquet/properties.h"
namespace parquet {
using schema::ColumnPath;
namespace test {
TEST(TestReaderProperties, Basics) {
ReaderProperties props;
ASSERT_EQ(props.buffer_size(), kDefaultBufferSize);
ASSERT_FALSE(props.is_buffered_stream_enabled());
}
TEST(TestWriterProperties, Basics) {
std::shared_ptr<WriterProperties> props = WriterProperties::Builder().build();
ASSERT_EQ(kDefaultDataPageSize, props->data_pagesize());
ASSERT_EQ(DEFAULT_DICTIONARY_PAGE_SIZE_LIMIT, props->dictionary_pagesize_limit());
ASSERT_EQ(ParquetVersion::PARQUET_2_4, props->version());
ASSERT_EQ(ParquetDataPageVersion::V1, props->data_page_version());
}
TEST(TestWriterProperties, AdvancedHandling) {
WriterProperties::Builder builder;
builder.compression("gzip", Compression::GZIP);
builder.compression("zstd", Compression::ZSTD);
builder.compression(Compression::SNAPPY);
builder.encoding(Encoding::DELTA_BINARY_PACKED);
builder.encoding("delta-length", Encoding::DELTA_LENGTH_BYTE_ARRAY);
builder.data_page_version(ParquetDataPageVersion::V2);
std::shared_ptr<WriterProperties> props = builder.build();
ASSERT_EQ(Compression::GZIP, props->compression(ColumnPath::FromDotString("gzip")));
ASSERT_EQ(Compression::ZSTD, props->compression(ColumnPath::FromDotString("zstd")));
ASSERT_EQ(Compression::SNAPPY,
props->compression(ColumnPath::FromDotString("delta-length")));
ASSERT_EQ(Encoding::DELTA_BINARY_PACKED,
props->encoding(ColumnPath::FromDotString("gzip")));
ASSERT_EQ(Encoding::DELTA_LENGTH_BYTE_ARRAY,
props->encoding(ColumnPath::FromDotString("delta-length")));
ASSERT_EQ(ParquetDataPageVersion::V2, props->data_page_version());
}
TEST(TestReaderProperties, GetStreamInsufficientData) {
// ARROW-6058
std::string data = "shorter than expected";
auto buf = std::make_shared<Buffer>(data);
auto reader = std::make_shared<::arrow::io::BufferReader>(buf);
ReaderProperties props;
try {
ARROW_UNUSED(props.GetStream(reader, 12, 15));
FAIL() << "No exception raised";
} catch (const ParquetException& e) {
std::string ex_what =
("Tried reading 15 bytes starting at position 12"
" from file but only got 9");
ASSERT_EQ(ex_what, e.what());
}
}
} // namespace test
} // namespace parquet