Skip to content

Commit 0c1094b

Browse files
author
xiao.dong
committed
fix comments
1 parent 643b115 commit 0c1094b

File tree

3 files changed

+36
-54
lines changed

3 files changed

+36
-54
lines changed

src/iceberg/util/gzip_internal.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ class ZlibImpl {
3939

4040
Status Init() {
4141
// Maximum window size
42-
static int WINDOW_BITS = 15;
42+
static int kWindowBits = 15;
4343
// Determine if this is libz or gzip from header.
44-
static int DETECT_CODEC = 32;
45-
46-
int ret = inflateInit2(&stream_, WINDOW_BITS | DETECT_CODEC);
44+
static int kDetectCodec = 32;
45+
int ret = inflateInit2(&stream_, kWindowBits | kDetectCodec);
4746
if (ret != Z_OK) {
4847
return DecompressError("inflateInit2 failed, result:{}", ret);
4948
}
@@ -82,7 +81,7 @@ class ZlibImpl {
8281
z_stream stream_;
8382
};
8483

85-
GZipDecompressor::GZipDecompressor() : zlib_impl_(std::make_shared<ZlibImpl>()) {}
84+
GZipDecompressor::GZipDecompressor() : zlib_impl_(std::make_unique<ZlibImpl>()) {}
8685

8786
GZipDecompressor::~GZipDecompressor() = default;
8887

src/iceberg/util/gzip_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GZipDecompressor {
3939
Result<std::string> Decompress(const std::string& compressed_data);
4040

4141
private:
42-
std::shared_ptr<ZlibImpl> zlib_impl_;
42+
std::unique_ptr<ZlibImpl> zlib_impl_;
4343
};
4444

4545
} // namespace iceberg

test/metadata_io_test.cc

Lines changed: 31 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -44,35 +44,41 @@ class MetadataIOTest : public TempFileTestBase {
4444
temp_filepath_ = CreateNewTempFilePathWithSuffix(".metadata.json");
4545
}
4646

47+
TableMetadata PrepareMetadata() {
48+
std::vector<SchemaField> schema_fields;
49+
schema_fields.emplace_back(/*field_id=*/1, "x", std::make_shared<LongType>(),
50+
/*optional=*/false);
51+
auto schema = std::make_shared<Schema>(std::move(schema_fields), /*schema_id=*/1);
52+
53+
TableMetadata metadata{
54+
.format_version = 1,
55+
.table_uuid = "1234567890",
56+
.location = "s3://bucket/path",
57+
.last_sequence_number = 0,
58+
.schemas = {schema},
59+
.current_schema_id = 1,
60+
.default_spec_id = 0,
61+
.last_partition_id = 0,
62+
.properties = {{"key", "value"}},
63+
.current_snapshot_id = 3051729675574597004,
64+
.snapshots = {std::make_shared<Snapshot>(Snapshot{
65+
.snapshot_id = 3051729675574597004,
66+
.sequence_number = 0,
67+
.timestamp_ms = TimePointMsFromUnixMs(1515100955770).value(),
68+
.manifest_list = "s3://a/b/1.avro",
69+
.summary = {{"operation", "append"}},
70+
})},
71+
.default_sort_order_id = 0,
72+
.next_row_id = 0};
73+
return metadata;
74+
}
75+
4776
std::shared_ptr<iceberg::FileIO> io_;
4877
std::string temp_filepath_;
4978
};
5079

5180
TEST_F(MetadataIOTest, ReadWriteMetadata) {
52-
std::vector<SchemaField> schema_fields;
53-
schema_fields.emplace_back(/*field_id=*/1, "x", std::make_shared<LongType>(),
54-
/*optional=*/false);
55-
auto schema = std::make_shared<Schema>(std::move(schema_fields), /*schema_id=*/1);
56-
57-
TableMetadata metadata{.format_version = 1,
58-
.table_uuid = "1234567890",
59-
.location = "s3://bucket/path",
60-
.last_sequence_number = 0,
61-
.schemas = {schema},
62-
.current_schema_id = 1,
63-
.default_spec_id = 0,
64-
.last_partition_id = 0,
65-
.properties = {{"key", "value"}},
66-
.current_snapshot_id = 3051729675574597004,
67-
.snapshots = {std::make_shared<Snapshot>(Snapshot{
68-
.snapshot_id = 3051729675574597004,
69-
.sequence_number = 0,
70-
.timestamp_ms = TimePointMsFromUnixMs(1515100955770).value(),
71-
.manifest_list = "s3://a/b/1.avro",
72-
.summary = {{"operation", "append"}},
73-
})},
74-
.default_sort_order_id = 0,
75-
.next_row_id = 0};
81+
TableMetadata metadata = PrepareMetadata();
7682

7783
EXPECT_THAT(TableMetadataUtil::Write(*io_, temp_filepath_, metadata), IsOk());
7884

@@ -84,30 +90,7 @@ TEST_F(MetadataIOTest, ReadWriteMetadata) {
8490
}
8591

8692
TEST_F(MetadataIOTest, ReadWriteCompressedMetadata) {
87-
std::vector<SchemaField> schema_fields;
88-
schema_fields.emplace_back(/*field_id=*/1, "x", std::make_shared<LongType>(),
89-
/*optional=*/false);
90-
auto schema = std::make_shared<Schema>(std::move(schema_fields), /*schema_id=*/1);
91-
92-
TableMetadata metadata{.format_version = 1,
93-
.table_uuid = "1234567890",
94-
.location = "s3://bucket/path",
95-
.last_sequence_number = 0,
96-
.schemas = {schema},
97-
.current_schema_id = 1,
98-
.default_spec_id = 0,
99-
.last_partition_id = 0,
100-
.properties = {{"key", "value"}},
101-
.current_snapshot_id = 3051729675574597004,
102-
.snapshots = {std::make_shared<Snapshot>(Snapshot{
103-
.snapshot_id = 3051729675574597004,
104-
.sequence_number = 0,
105-
.timestamp_ms = TimePointMsFromUnixMs(1515100955770).value(),
106-
.manifest_list = "s3://a/b/1.avro",
107-
.summary = {{"operation", "append"}},
108-
})},
109-
.default_sort_order_id = 0,
110-
.next_row_id = 0};
93+
TableMetadata metadata = PrepareMetadata();
11194

11295
auto json = ToJson(metadata);
11396
auto ret = ToJsonString(json);

0 commit comments

Comments
 (0)