Skip to content

Commit 9f70c0d

Browse files
Follow naming convention from Iceberg's Java and Python implementations (#204)
1 parent 86784ee commit 9f70c0d

File tree

2 files changed

+49
-49
lines changed

2 files changed

+49
-49
lines changed

crates/iceberg/src/spec/manifest.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use self::_const_schema::{manifest_schema_v1, manifest_schema_v2};
2020

2121
use super::{
22-
FieldSummary, FormatVersion, ManifestContentType, ManifestListEntry, PartitionSpec, Schema,
22+
FieldSummary, FormatVersion, ManifestContentType, ManifestFile, PartitionSpec, Schema,
2323
SchemaId, Struct, INITIAL_SEQUENCE_NUMBER,
2424
};
2525
use super::{Literal, UNASSIGNED_SEQUENCE_NUMBER};
@@ -196,7 +196,7 @@ impl ManifestWriter {
196196
}
197197

198198
/// Write a manifest entry.
199-
pub async fn write(mut self, manifest: Manifest) -> Result<ManifestListEntry> {
199+
pub async fn write(mut self, manifest: Manifest) -> Result<ManifestFile> {
200200
// Create the avro writer
201201
let partition_type = manifest
202202
.metadata
@@ -302,7 +302,7 @@ impl ManifestWriter {
302302
let partition_summary =
303303
self.get_field_summary_vec(&manifest.metadata.partition_spec.fields);
304304

305-
Ok(ManifestListEntry {
305+
Ok(ManifestFile {
306306
manifest_path: self.output.location().to_string(),
307307
manifest_length: length as i64,
308308
partition_spec_id: manifest.metadata.partition_spec.spec_id,
@@ -861,7 +861,7 @@ impl ManifestEntry {
861861
}
862862

863863
/// Inherit data from manifest list, such as snapshot id, sequence number.
864-
pub(crate) fn inherit_data(&mut self, snapshot_entry: &ManifestListEntry) {
864+
pub(crate) fn inherit_data(&mut self, snapshot_entry: &ManifestFile) {
865865
if self.snapshot_id.is_none() {
866866
self.snapshot_id = Some(snapshot_entry.added_snapshot_id);
867867
}
@@ -1981,7 +1981,7 @@ mod tests {
19811981
async fn test_manifest_read_write(
19821982
manifest: Manifest,
19831983
writer_builder: impl FnOnce(OutputFile) -> ManifestWriter,
1984-
) -> ManifestListEntry {
1984+
) -> ManifestFile {
19851985
let (bs, res) = write_manifest(&manifest, writer_builder).await;
19861986
let actual_manifest = Manifest::parse_avro(bs.as_slice()).unwrap();
19871987

@@ -1993,7 +1993,7 @@ mod tests {
19931993
async fn write_manifest(
19941994
manifest: &Manifest,
19951995
writer_builder: impl FnOnce(OutputFile) -> ManifestWriter,
1996-
) -> (Vec<u8>, ManifestListEntry) {
1996+
) -> (Vec<u8>, ManifestFile) {
19971997
let temp_dir = TempDir::new().unwrap();
19981998
let path = temp_dir.path().join("test_manifest.avro");
19991999
let io = FileIOBuilder::new_fs_io().build().unwrap();

crates/iceberg/src/spec/manifest_list.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use futures::{AsyncReadExt, AsyncWriteExt};
2626

2727
use self::{
2828
_const_schema::{MANIFEST_LIST_AVRO_SCHEMA_V1, MANIFEST_LIST_AVRO_SCHEMA_V2},
29-
_serde::{ManifestListEntryV1, ManifestListEntryV2},
29+
_serde::{ManifestFileV1, ManifestFileV2},
3030
};
3131

3232
use super::{FormatVersion, Manifest, StructType};
@@ -51,7 +51,7 @@ pub const UNASSIGNED_SEQUENCE_NUMBER: i64 = -1;
5151
#[derive(Debug, Clone, PartialEq)]
5252
pub struct ManifestList {
5353
/// Entries in a manifest list.
54-
entries: Vec<ManifestListEntry>,
54+
entries: Vec<ManifestFile>,
5555
}
5656

5757
impl ManifestList {
@@ -76,7 +76,7 @@ impl ManifestList {
7676
}
7777

7878
/// Get the entries in the manifest list.
79-
pub fn entries(&self) -> &[ManifestListEntry] {
79+
pub fn entries(&self) -> &[ManifestFile] {
8080
&self.entries
8181
}
8282
}
@@ -168,12 +168,12 @@ impl ManifestListWriter {
168168
/// Append manifest entries to be written.
169169
pub fn add_manifest_entries(
170170
&mut self,
171-
manifest_entries: impl Iterator<Item = ManifestListEntry>,
171+
manifest_entries: impl Iterator<Item = ManifestFile>,
172172
) -> Result<()> {
173173
match self.format_version {
174174
FormatVersion::V1 => {
175175
for manifest_entry in manifest_entries {
176-
let manifest_entry: ManifestListEntryV1 = manifest_entry.try_into()?;
176+
let manifest_entry: ManifestFileV1 = manifest_entry.try_into()?;
177177
self.avro_writer.append_ser(manifest_entry)?;
178178
}
179179
}
@@ -203,7 +203,7 @@ impl ManifestListWriter {
203203
}
204204
manifest_entry.min_sequence_number = self.sequence_number;
205205
}
206-
let manifest_entry: ManifestListEntryV2 = manifest_entry.try_into()?;
206+
let manifest_entry: ManifestFileV2 = manifest_entry.try_into()?;
207207
self.avro_writer.append_ser(manifest_entry)?;
208208
}
209209
}
@@ -503,7 +503,7 @@ mod _const_schema {
503503

504504
/// Entry in a manifest list.
505505
#[derive(Debug, PartialEq, Clone)]
506-
pub struct ManifestListEntry {
506+
pub struct ManifestFile {
507507
/// field: 500
508508
///
509509
/// Location of the manifest file
@@ -630,7 +630,7 @@ impl TryFrom<i32> for ManifestContentType {
630630
}
631631
}
632632

633-
impl ManifestListEntry {
633+
impl ManifestFile {
634634
/// Load [`Manifest`].
635635
///
636636
/// This method will also initialize inherited values of [`ManifestEntry`], such as `sequence_number`.
@@ -679,9 +679,9 @@ pub struct FieldSummary {
679679
}
680680

681681
/// This is a helper module that defines types to help with serialization/deserialization.
682-
/// For deserialization the input first gets read into either the [ManifestListEntryV1] or [ManifestListEntryV2] struct
683-
/// and then converted into the [ManifestListEntry] struct. Serialization works the other way around.
684-
/// [ManifestListEntryV1] and [ManifestListEntryV2] are internal struct that are only used for serialization and deserialization.
682+
/// For deserialization the input first gets read into either the [ManifestFileV1] or [ManifestFileV2] struct
683+
/// and then converted into the [ManifestFile] struct. Serialization works the other way around.
684+
/// [ManifestFileV1] and [ManifestFileV2] are internal struct that are only used for serialization and deserialization.
685685
pub(super) mod _serde {
686686
use crate::{
687687
spec::{Literal, StructType, Type},
@@ -690,19 +690,19 @@ pub(super) mod _serde {
690690
pub use serde_bytes::ByteBuf;
691691
use serde_derive::{Deserialize, Serialize};
692692

693-
use super::ManifestListEntry;
693+
use super::ManifestFile;
694694
use crate::error::Result;
695695

696696
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
697697
#[serde(transparent)]
698698
pub(crate) struct ManifestListV2 {
699-
entries: Vec<ManifestListEntryV2>,
699+
entries: Vec<ManifestFileV2>,
700700
}
701701

702702
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
703703
#[serde(transparent)]
704704
pub(crate) struct ManifestListV1 {
705-
entries: Vec<ManifestListEntryV1>,
705+
entries: Vec<ManifestFileV1>,
706706
}
707707

708708
impl ManifestListV2 {
@@ -790,7 +790,7 @@ pub(super) mod _serde {
790790
}
791791

792792
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
793-
pub(super) struct ManifestListEntryV1 {
793+
pub(super) struct ManifestFileV1 {
794794
pub manifest_path: String,
795795
pub manifest_length: i64,
796796
pub partition_spec_id: i32,
@@ -806,7 +806,7 @@ pub(super) mod _serde {
806806
}
807807

808808
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
809-
pub(super) struct ManifestListEntryV2 {
809+
pub(super) struct ManifestFileV2 {
810810
pub manifest_path: String,
811811
pub manifest_length: i64,
812812
pub partition_spec_id: i32,
@@ -885,12 +885,12 @@ pub(super) mod _serde {
885885
}
886886
}
887887

888-
impl ManifestListEntryV2 {
889-
/// Converts the [ManifestListEntryV2] into a [ManifestListEntry].
888+
impl ManifestFileV2 {
889+
/// Converts the [ManifestFileV2] into a [ManifestFile].
890890
/// The convert of [partitions] need the partition_type info so use this function instead of [std::TryFrom] trait.
891-
pub fn try_into(self, partition_type: Option<&StructType>) -> Result<ManifestListEntry> {
891+
pub fn try_into(self, partition_type: Option<&StructType>) -> Result<ManifestFile> {
892892
let partitions = try_convert_to_field_summary(self.partitions, partition_type)?;
893-
Ok(ManifestListEntry {
893+
Ok(ManifestFile {
894894
manifest_path: self.manifest_path,
895895
manifest_length: self.manifest_length,
896896
partition_spec_id: self.partition_spec_id,
@@ -910,12 +910,12 @@ pub(super) mod _serde {
910910
}
911911
}
912912

913-
impl ManifestListEntryV1 {
914-
/// Converts the [ManifestListEntryV1] into a [ManifestListEntry].
913+
impl ManifestFileV1 {
914+
/// Converts the [MManifestFileV1] into a [ManifestFile].
915915
/// The convert of [partitions] need the partition_type info so use this function instead of [std::TryFrom] trait.
916-
pub fn try_into(self, partition_type: Option<&StructType>) -> Result<ManifestListEntry> {
916+
pub fn try_into(self, partition_type: Option<&StructType>) -> Result<ManifestFile> {
917917
let partitions = try_convert_to_field_summary(self.partitions, partition_type)?;
918-
Ok(ManifestListEntry {
918+
Ok(ManifestFile {
919919
manifest_path: self.manifest_path,
920920
manifest_length: self.manifest_length,
921921
partition_spec_id: self.partition_spec_id,
@@ -977,10 +977,10 @@ pub(super) mod _serde {
977977
}
978978
}
979979

980-
impl TryFrom<ManifestListEntry> for ManifestListEntryV2 {
980+
impl TryFrom<ManifestFile> for ManifestFileV2 {
981981
type Error = Error;
982982

983-
fn try_from(value: ManifestListEntry) -> std::result::Result<Self, Self::Error> {
983+
fn try_from(value: ManifestFile) -> std::result::Result<Self, Self::Error> {
984984
let partitions = convert_to_serde_field_summary(value.partitions);
985985
let key_metadata = convert_to_serde_key_metadata(value.key_metadata);
986986
Ok(Self {
@@ -996,7 +996,7 @@ pub(super) mod _serde {
996996
.ok_or_else(|| {
997997
Error::new(
998998
crate::ErrorKind::DataInvalid,
999-
"added_data_files_count in ManifestListEntryV2 should be require",
999+
"added_data_files_count in ManifestFileV2 should be require",
10001000
)
10011001
})?
10021002
.try_into()?,
@@ -1005,7 +1005,7 @@ pub(super) mod _serde {
10051005
.ok_or_else(|| {
10061006
Error::new(
10071007
crate::ErrorKind::DataInvalid,
1008-
"existing_data_files_count in ManifestListEntryV2 should be require",
1008+
"existing_data_files_count in ManifestFileV2 should be require",
10091009
)
10101010
})?
10111011
.try_into()?,
@@ -1014,7 +1014,7 @@ pub(super) mod _serde {
10141014
.ok_or_else(|| {
10151015
Error::new(
10161016
crate::ErrorKind::DataInvalid,
1017-
"deleted_data_files_count in ManifestListEntryV2 should be require",
1017+
"deleted_data_files_count in ManifestFileV2 should be require",
10181018
)
10191019
})?
10201020
.try_into()?,
@@ -1023,7 +1023,7 @@ pub(super) mod _serde {
10231023
.ok_or_else(|| {
10241024
Error::new(
10251025
crate::ErrorKind::DataInvalid,
1026-
"added_rows_count in ManifestListEntryV2 should be require",
1026+
"added_rows_count in ManifestFileV2 should be require",
10271027
)
10281028
})?
10291029
.try_into()?,
@@ -1032,7 +1032,7 @@ pub(super) mod _serde {
10321032
.ok_or_else(|| {
10331033
Error::new(
10341034
crate::ErrorKind::DataInvalid,
1035-
"existing_rows_count in ManifestListEntryV2 should be require",
1035+
"existing_rows_count in ManifestFileV2 should be require",
10361036
)
10371037
})?
10381038
.try_into()?,
@@ -1041,7 +1041,7 @@ pub(super) mod _serde {
10411041
.ok_or_else(|| {
10421042
Error::new(
10431043
crate::ErrorKind::DataInvalid,
1044-
"deleted_rows_count in ManifestListEntryV2 should be require",
1044+
"deleted_rows_count in ManifestFileV2 should be require",
10451045
)
10461046
})?
10471047
.try_into()?,
@@ -1051,10 +1051,10 @@ pub(super) mod _serde {
10511051
}
10521052
}
10531053

1054-
impl TryFrom<ManifestListEntry> for ManifestListEntryV1 {
1054+
impl TryFrom<ManifestFile> for ManifestFileV1 {
10551055
type Error = Error;
10561056

1057-
fn try_from(value: ManifestListEntry) -> std::result::Result<Self, Self::Error> {
1057+
fn try_from(value: ManifestFile) -> std::result::Result<Self, Self::Error> {
10581058
let partitions = convert_to_serde_field_summary(value.partitions);
10591059
let key_metadata = convert_to_serde_key_metadata(value.key_metadata);
10601060
Ok(Self {
@@ -1100,7 +1100,7 @@ mod test {
11001100
io::FileIOBuilder,
11011101
spec::{
11021102
manifest_list::{_serde::ManifestListV1, UNASSIGNED_SEQUENCE_NUMBER},
1103-
FieldSummary, Literal, ManifestContentType, ManifestList, ManifestListEntry,
1103+
FieldSummary, Literal, ManifestContentType, ManifestFile, ManifestList,
11041104
ManifestListWriter, NestedField, PrimitiveType, StructType, Type,
11051105
},
11061106
};
@@ -1111,7 +1111,7 @@ mod test {
11111111
async fn test_parse_manifest_list_v1() {
11121112
let manifest_list = ManifestList {
11131113
entries: vec![
1114-
ManifestListEntry {
1114+
ManifestFile {
11151115
manifest_path: "/opt/bitnami/spark/warehouse/db/table/metadata/10d28031-9739-484c-92db-cdf2975cead4-m0.avro".to_string(),
11161116
manifest_length: 5806,
11171117
partition_spec_id: 0,
@@ -1161,7 +1161,7 @@ mod test {
11611161
async fn test_parse_manifest_list_v2() {
11621162
let manifest_list = ManifestList {
11631163
entries: vec![
1164-
ManifestListEntry {
1164+
ManifestFile {
11651165
manifest_path: "s3a://icebergdata/demo/s1/t1/metadata/05ffe08b-810f-49b3-a8f4-e88fc99b254a-m0.avro".to_string(),
11661166
manifest_length: 6926,
11671167
partition_spec_id: 1,
@@ -1178,7 +1178,7 @@ mod test {
11781178
partitions: vec![FieldSummary { contains_null: false, contains_nan: Some(false), lower_bound: Some(Literal::long(1)), upper_bound: Some(Literal::long(1))}],
11791179
key_metadata: vec![],
11801180
},
1181-
ManifestListEntry {
1181+
ManifestFile {
11821182
manifest_path: "s3a://icebergdata/demo/s1/t1/metadata/05ffe08b-810f-49b3-a8f4-e88fc99b254a-m1.avro".to_string(),
11831183
manifest_length: 6926,
11841184
partition_spec_id: 2,
@@ -1249,7 +1249,7 @@ mod test {
12491249
#[test]
12501250
fn test_serialize_manifest_list_v1() {
12511251
let manifest_list:ManifestListV1 = ManifestList {
1252-
entries: vec![ManifestListEntry {
1252+
entries: vec![ManifestFile {
12531253
manifest_path: "/opt/bitnami/spark/warehouse/db/table/metadata/10d28031-9739-484c-92db-cdf2975cead4-m0.avro".to_string(),
12541254
manifest_length: 5806,
12551255
partition_spec_id: 0,
@@ -1277,7 +1277,7 @@ mod test {
12771277
#[test]
12781278
fn test_serialize_manifest_list_v2() {
12791279
let manifest_list:ManifestListV2 = ManifestList {
1280-
entries: vec![ManifestListEntry {
1280+
entries: vec![ManifestFile {
12811281
manifest_path: "s3a://icebergdata/demo/s1/t1/metadata/05ffe08b-810f-49b3-a8f4-e88fc99b254a-m0.avro".to_string(),
12821282
manifest_length: 6926,
12831283
partition_spec_id: 1,
@@ -1305,7 +1305,7 @@ mod test {
13051305
#[tokio::test]
13061306
async fn test_manifest_list_writer_v1() {
13071307
let expected_manifest_list = ManifestList {
1308-
entries: vec![ManifestListEntry {
1308+
entries: vec![ManifestFile {
13091309
manifest_path: "/opt/bitnami/spark/warehouse/db/table/metadata/10d28031-9739-484c-92db-cdf2975cead4-m0.avro".to_string(),
13101310
manifest_length: 5806,
13111311
partition_spec_id: 1,
@@ -1361,7 +1361,7 @@ mod test {
13611361
let snapshot_id = 377075049360453639;
13621362
let seq_num = 1;
13631363
let mut expected_manifest_list = ManifestList {
1364-
entries: vec![ManifestListEntry {
1364+
entries: vec![ManifestFile {
13651365
manifest_path: "s3a://icebergdata/demo/s1/t1/metadata/05ffe08b-810f-49b3-a8f4-e88fc99b254a-m0.avro".to_string(),
13661366
manifest_length: 6926,
13671367
partition_spec_id: 1,
@@ -1415,7 +1415,7 @@ mod test {
14151415
#[tokio::test]
14161416
async fn test_manifest_list_writer_v1_as_v2() {
14171417
let expected_manifest_list = ManifestList {
1418-
entries: vec![ManifestListEntry {
1418+
entries: vec![ManifestFile {
14191419
manifest_path: "/opt/bitnami/spark/warehouse/db/table/metadata/10d28031-9739-484c-92db-cdf2975cead4-m0.avro".to_string(),
14201420
manifest_length: 5806,
14211421
partition_spec_id: 1,

0 commit comments

Comments
 (0)