Skip to content

Commit ec65a69

Browse files
author
xiao.dong
committed
fix comments
1 parent 4a12ace commit ec65a69

File tree

6 files changed

+59
-71
lines changed

6 files changed

+59
-71
lines changed

src/iceberg/manifest_adapter.cc

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -237,81 +237,79 @@ Status ManifestEntryAdapter::AppendMap(
237237

238238
Status ManifestEntryAdapter::AppendDataFile(
239239
ArrowArray* arrow_array, const std::shared_ptr<StructType>& data_file_type,
240-
const std::shared_ptr<DataFile>& file) {
240+
const DataFile& file) {
241241
auto fields = data_file_type->fields();
242242
for (int32_t i = 0; i < fields.size(); i++) {
243243
const auto& field = fields[i];
244244
auto array = arrow_array->children[i];
245245

246246
switch (field.field_id()) {
247247
case 134: // content (optional int32)
248-
ICEBERG_RETURN_UNEXPECTED(
249-
AppendField(array, static_cast<int64_t>(file->content)));
248+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, static_cast<int64_t>(file.content)));
250249
break;
251250
case 100: // file_path (required string)
252-
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file->file_path));
251+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file.file_path));
253252
break;
254253
case 101: // file_format (required string)
255-
ICEBERG_RETURN_UNEXPECTED(AppendField(array, ToString(file->file_format)));
254+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, ToString(file.file_format)));
256255
break;
257256
case 102: // partition (required struct)
258257
{
259258
auto partition_type = internal::checked_pointer_cast<StructType>(field.type());
260-
ICEBERG_RETURN_UNEXPECTED(
261-
AppendPartition(array, partition_type, file->partition));
259+
ICEBERG_RETURN_UNEXPECTED(AppendPartition(array, partition_type, file.partition));
262260
} break;
263261
case 103: // record_count (required int64)
264-
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file->record_count));
262+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file.record_count));
265263
break;
266264
case 104: // file_size_in_bytes (required int64)
267-
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file->file_size_in_bytes));
265+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file.file_size_in_bytes));
268266
break;
269267
case 105: // block_size_in_bytes (compatible in v1)
270268
// always 64MB for v1
271269
ICEBERG_RETURN_UNEXPECTED(AppendField(array, kBlockSizeInBytesV1));
272270
break;
273271
case 108: // column_sizes (optional map)
274-
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file->column_sizes));
272+
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file.column_sizes));
275273
break;
276274
case 109: // value_counts (optional map)
277-
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file->value_counts));
275+
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file.value_counts));
278276
break;
279277
case 110: // null_value_counts (optional map)
280-
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file->null_value_counts));
278+
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file.null_value_counts));
281279
break;
282280
case 137: // nan_value_counts (optional map)
283-
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file->nan_value_counts));
281+
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file.nan_value_counts));
284282
break;
285283
case 125: // lower_bounds (optional map)
286-
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file->lower_bounds));
284+
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file.lower_bounds));
287285
break;
288286
case 128: // upper_bounds (optional map)
289-
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file->upper_bounds));
287+
ICEBERG_RETURN_UNEXPECTED(AppendMap(array, file.upper_bounds));
290288
break;
291289
case 131: // key_metadata (optional binary)
292-
if (!file->key_metadata.empty()) {
293-
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file->key_metadata));
290+
if (!file.key_metadata.empty()) {
291+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file.key_metadata));
294292
} else {
295293
ICEBERG_NANOARROW_RETURN_IF_NOT_OK(ArrowArrayAppendNull(array, 1));
296294
}
297295
break;
298296
case 132: // split_offsets (optional list)
299-
ICEBERG_RETURN_UNEXPECTED(AppendList(array, file->split_offsets));
297+
ICEBERG_RETURN_UNEXPECTED(AppendList(array, file.split_offsets));
300298
break;
301299
case 135: // equality_ids (optional list)
302-
ICEBERG_RETURN_UNEXPECTED(AppendList(array, file->equality_ids));
300+
ICEBERG_RETURN_UNEXPECTED(AppendList(array, file.equality_ids));
303301
break;
304302
case 140: // sort_order_id (optional int32)
305-
if (file->sort_order_id.has_value()) {
303+
if (file.sort_order_id.has_value()) {
306304
ICEBERG_RETURN_UNEXPECTED(
307-
AppendField(array, static_cast<int64_t>(file->sort_order_id.value())));
305+
AppendField(array, static_cast<int64_t>(file.sort_order_id.value())));
308306
} else {
309307
ICEBERG_NANOARROW_RETURN_IF_NOT_OK(ArrowArrayAppendNull(array, 1));
310308
}
311309
break;
312310
case 142: // first_row_id (optional int64)
313-
if (file->first_row_id.has_value()) {
314-
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file->first_row_id.value()));
311+
if (file.first_row_id.has_value()) {
312+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file.first_row_id.value()));
315313
} else {
316314
ICEBERG_NANOARROW_RETURN_IF_NOT_OK(ArrowArrayAppendNull(array, 1));
317315
}
@@ -327,16 +325,16 @@ Status ManifestEntryAdapter::AppendDataFile(
327325
break;
328326
}
329327
case 144: // content_offset (optional int64)
330-
if (file->content_offset.has_value()) {
331-
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file->content_offset.value()));
328+
if (file.content_offset.has_value()) {
329+
ICEBERG_RETURN_UNEXPECTED(AppendField(array, file.content_offset.value()));
332330
} else {
333331
ICEBERG_NANOARROW_RETURN_IF_NOT_OK(ArrowArrayAppendNull(array, 1));
334332
}
335333
break;
336334
case 145: // content_size_in_bytes (optional int64)
337-
if (file->content_size_in_bytes.has_value()) {
335+
if (file.content_size_in_bytes.has_value()) {
338336
ICEBERG_RETURN_UNEXPECTED(
339-
AppendField(array, file->content_size_in_bytes.value()));
337+
AppendField(array, file.content_size_in_bytes.value()));
340338
} else {
341339
ICEBERG_NANOARROW_RETURN_IF_NOT_OK(ArrowArrayAppendNull(array, 1));
342340
}
@@ -355,23 +353,22 @@ Result<std::optional<int64_t>> ManifestEntryAdapter::GetSequenceNumber(
355353
}
356354

357355
Result<std::optional<std::string>> ManifestEntryAdapter::GetReferenceDataFile(
358-
const std::shared_ptr<DataFile>& file) {
359-
return file->referenced_data_file;
356+
const DataFile& file) {
357+
return file.referenced_data_file;
360358
}
361359

362-
Result<std::optional<int64_t>> ManifestEntryAdapter::GetFirstRowId(
363-
const std::shared_ptr<DataFile>& file) {
364-
return file->first_row_id;
360+
Result<std::optional<int64_t>> ManifestEntryAdapter::GetFirstRowId(const DataFile& file) {
361+
return file.first_row_id;
365362
}
366363

367364
Result<std::optional<int64_t>> ManifestEntryAdapter::GetContentOffset(
368-
const std::shared_ptr<DataFile>& file) {
369-
return file->content_offset;
365+
const DataFile& file) {
366+
return file.content_offset;
370367
}
371368

372369
Result<std::optional<int64_t>> ManifestEntryAdapter::GetContentSizeInBytes(
373-
const std::shared_ptr<DataFile>& file) {
374-
return file->content_size_in_bytes;
370+
const DataFile& file) {
371+
return file.content_size_in_bytes;
375372
}
376373

377374
Status ManifestEntryAdapter::AppendInternal(const ManifestEntry& entry) {
@@ -397,7 +394,7 @@ Status ManifestEntryAdapter::AppendInternal(const ManifestEntry& entry) {
397394
// Get the data file type from the field
398395
auto data_file_type = internal::checked_pointer_cast<StructType>(field.type());
399396
ICEBERG_RETURN_UNEXPECTED(
400-
AppendDataFile(array, data_file_type, entry.data_file));
397+
AppendDataFile(array, data_file_type, *entry.data_file));
401398
} else {
402399
return InvalidManifest("Missing required data file field.");
403400
}

src/iceberg/manifest_adapter.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class ICEBERG_EXPORT ManifestEntryAdapter : public ManifestAdapter {
8484
Status AppendInternal(const ManifestEntry& entry);
8585
Status AppendDataFile(ArrowArray* arrow_array,
8686
const std::shared_ptr<StructType>& data_file_type,
87-
const std::shared_ptr<DataFile>& file);
87+
const DataFile& file);
8888
static Status AppendPartition(ArrowArray* arrow_array,
8989
const std::shared_ptr<StructType>& partition_type,
9090
const std::vector<Literal>& partitions);
@@ -98,14 +98,10 @@ class ICEBERG_EXPORT ManifestEntryAdapter : public ManifestAdapter {
9898
const std::map<int32_t, std::vector<uint8_t>>& map_value);
9999

100100
virtual Result<std::optional<int64_t>> GetSequenceNumber(const ManifestEntry& entry);
101-
virtual Result<std::optional<std::string>> GetReferenceDataFile(
102-
const std::shared_ptr<DataFile>& file);
103-
virtual Result<std::optional<int64_t>> GetFirstRowId(
104-
const std::shared_ptr<DataFile>& file);
105-
virtual Result<std::optional<int64_t>> GetContentOffset(
106-
const std::shared_ptr<DataFile>& file);
107-
virtual Result<std::optional<int64_t>> GetContentSizeInBytes(
108-
const std::shared_ptr<DataFile>& file);
101+
virtual Result<std::optional<std::string>> GetReferenceDataFile(const DataFile& file);
102+
virtual Result<std::optional<int64_t>> GetFirstRowId(const DataFile& file);
103+
virtual Result<std::optional<int64_t>> GetContentOffset(const DataFile& file);
104+
virtual Result<std::optional<int64_t>> GetContentSizeInBytes(const DataFile& file);
109105

110106
protected:
111107
std::shared_ptr<PartitionSpec> partition_spec_;

src/iceberg/v2_metadata.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ Result<std::optional<int64_t>> ManifestEntryAdapterV2::GetSequenceNumber(
9191
}
9292

9393
Result<std::optional<std::string>> ManifestEntryAdapterV2::GetReferenceDataFile(
94-
const std::shared_ptr<DataFile>& file) {
95-
if (file->content == DataFile::Content::kPositionDeletes) {
96-
return file->referenced_data_file;
94+
const DataFile& file) {
95+
if (file.content == DataFile::Content::kPositionDeletes) {
96+
return file.referenced_data_file;
9797
}
9898
return std::nullopt;
9999
}

src/iceberg/v2_metadata.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class ManifestEntryAdapterV2 : public ManifestEntryAdapter {
3636

3737
protected:
3838
Result<std::optional<int64_t>> GetSequenceNumber(const ManifestEntry& entry) override;
39-
Result<std::optional<std::string>> GetReferenceDataFile(
40-
const std::shared_ptr<DataFile>& file) override;
39+
Result<std::optional<std::string>> GetReferenceDataFile(const DataFile& file) override;
4140

4241
private:
4342
std::optional<int64_t> snapshot_id_;

src/iceberg/v3_metadata.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,33 +95,33 @@ Result<std::optional<int64_t>> ManifestEntryAdapterV3::GetSequenceNumber(
9595
}
9696

9797
Result<std::optional<std::string>> ManifestEntryAdapterV3::GetReferenceDataFile(
98-
const std::shared_ptr<DataFile>& file) {
99-
if (file->content == DataFile::Content::kPositionDeletes) {
100-
return file->referenced_data_file;
98+
const DataFile& file) {
99+
if (file.content == DataFile::Content::kPositionDeletes) {
100+
return file.referenced_data_file;
101101
}
102102
return std::nullopt;
103103
}
104104

105105
Result<std::optional<int64_t>> ManifestEntryAdapterV3::GetFirstRowId(
106-
const std::shared_ptr<DataFile>& file) {
107-
if (file->content == DataFile::Content::kData) {
108-
return file->first_row_id;
106+
const DataFile& file) {
107+
if (file.content == DataFile::Content::kData) {
108+
return file.first_row_id;
109109
}
110110
return std::nullopt;
111111
}
112112

113113
Result<std::optional<int64_t>> ManifestEntryAdapterV3::GetContentOffset(
114-
const std::shared_ptr<DataFile>& file) {
115-
if (file->content == DataFile::Content::kPositionDeletes) {
116-
return file->content_offset;
114+
const DataFile& file) {
115+
if (file.content == DataFile::Content::kPositionDeletes) {
116+
return file.content_offset;
117117
}
118118
return std::nullopt;
119119
}
120120

121121
Result<std::optional<int64_t>> ManifestEntryAdapterV3::GetContentSizeInBytes(
122-
const std::shared_ptr<DataFile>& file) {
123-
if (file->content == DataFile::Content::kPositionDeletes) {
124-
return file->content_size_in_bytes;
122+
const DataFile& file) {
123+
if (file.content == DataFile::Content::kPositionDeletes) {
124+
return file.content_size_in_bytes;
125125
}
126126
return std::nullopt;
127127
}

src/iceberg/v3_metadata.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,10 @@ class ManifestEntryAdapterV3 : public ManifestEntryAdapter {
3939

4040
protected:
4141
Result<std::optional<int64_t>> GetSequenceNumber(const ManifestEntry& entry) override;
42-
Result<std::optional<std::string>> GetReferenceDataFile(
43-
const std::shared_ptr<DataFile>& file) override;
44-
Result<std::optional<int64_t>> GetFirstRowId(
45-
const std::shared_ptr<DataFile>& file) override;
46-
Result<std::optional<int64_t>> GetContentOffset(
47-
const std::shared_ptr<DataFile>& file) override;
48-
Result<std::optional<int64_t>> GetContentSizeInBytes(
49-
const std::shared_ptr<DataFile>& file) override;
42+
Result<std::optional<std::string>> GetReferenceDataFile(const DataFile& file) override;
43+
Result<std::optional<int64_t>> GetFirstRowId(const DataFile& file) override;
44+
Result<std::optional<int64_t>> GetContentOffset(const DataFile& file) override;
45+
Result<std::optional<int64_t>> GetContentSizeInBytes(const DataFile& file) override;
5046

5147
private:
5248
std::optional<int64_t> snapshot_id_;

0 commit comments

Comments
 (0)