Skip to content

Commit 512539f

Browse files
committed
Add getter methods
1 parent 1038a5b commit 512539f

File tree

2 files changed

+106
-22
lines changed

2 files changed

+106
-22
lines changed

crates/iceberg/src/puffin/blob.rs

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,48 @@ pub const APACHE_DATASKETCHES_THETA_V1: &str = "apache-datasketches-theta-v1";
2323
/// The blob
2424
#[derive(Debug, PartialEq, Clone)]
2525
pub struct Blob {
26+
pub(crate) r#type: String,
27+
pub(crate) fields: Vec<i32>,
28+
pub(crate) snapshot_id: i64,
29+
pub(crate) sequence_number: i64,
30+
pub(crate) data: Vec<u8>,
31+
pub(crate) properties: HashMap<String, String>,
32+
}
33+
34+
impl Blob {
35+
#[inline]
2636
/// See blob types: https://iceberg.apache.org/puffin-spec/#blob-types
27-
pub r#type: String,
37+
pub fn blob_type(&self) -> &String {
38+
&self.r#type
39+
}
40+
41+
#[inline]
2842
/// List of field IDs the blob was computed for; the order of items is used to compute sketches stored in the blob.
29-
pub fields: Vec<i32>,
43+
pub fn fields(&self) -> &Vec<i32> {
44+
&self.fields
45+
}
46+
47+
#[inline]
3048
/// ID of the Iceberg table's snapshot the blob was computed from
31-
pub snapshot_id: i64,
49+
pub fn snapshot_id(&self) -> &i64 {
50+
&self.snapshot_id
51+
}
52+
53+
#[inline]
3254
/// Sequence number of the Iceberg table's snapshot the blob was computed from
33-
pub sequence_number: i64,
55+
pub fn sequence_number(&self) -> &i64 {
56+
&self.r#sequence_number
57+
}
58+
59+
#[inline]
3460
/// The uncompressed blob data
35-
pub data: Vec<u8>,
61+
pub fn data(&self) -> &Vec<u8> {
62+
&self.data
63+
}
64+
65+
#[inline]
3666
/// Arbitrary meta-information about the blob
37-
pub properties: HashMap<String, String>,
67+
pub fn properties(&self) -> &HashMap<String, String> {
68+
&self.properties
69+
}
3870
}

crates/iceberg/src/puffin/metadata.rs

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,68 @@ pub const CREATED_BY_PROPERTY: &str = "created-by";
3333
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
3434
#[serde(rename_all = "kebab-case")]
3535
pub struct BlobMetadata {
36+
pub(crate) r#type: String,
37+
pub(crate) fields: Vec<i32>,
38+
pub(crate) snapshot_id: i64,
39+
pub(crate) sequence_number: i64,
40+
pub(crate) offset: u64,
41+
pub(crate) length: u64,
42+
#[serde(skip_serializing_if = "CompressionCodec::is_none")]
43+
#[serde(default)]
44+
pub(crate) compression_codec: CompressionCodec,
45+
#[serde(skip_serializing_if = "HashMap::is_empty")]
46+
#[serde(default)]
47+
pub(crate) properties: HashMap<String, String>,
48+
}
49+
50+
impl BlobMetadata {
51+
#[inline]
3652
/// See blob types: https://iceberg.apache.org/puffin-spec/#blob-types
37-
pub r#type: String,
53+
pub fn blob_type(&self) -> &String {
54+
&self.r#type
55+
}
56+
57+
#[inline]
3858
/// List of field IDs the blob was computed for; the order of items is used to compute sketches stored in the blob.
39-
pub fields: Vec<i32>,
59+
pub fn fields(&self) -> &Vec<i32> {
60+
&self.fields
61+
}
62+
63+
#[inline]
4064
/// ID of the Iceberg table's snapshot the blob was computed from
41-
pub snapshot_id: i64,
65+
pub fn snapshot_id(&self) -> &i64 {
66+
&self.snapshot_id
67+
}
68+
69+
#[inline]
4270
/// Sequence number of the Iceberg table's snapshot the blob was computed from
43-
pub sequence_number: i64,
71+
pub fn sequence_number(&self) -> &i64 {
72+
&self.r#sequence_number
73+
}
74+
75+
#[inline]
4476
/// The offset in the file where the blob contents start
45-
pub offset: u64,
77+
pub fn offset(&self) -> &u64 {
78+
&self.offset
79+
}
80+
81+
#[inline]
4682
/// The length of the blob stored in the file (after compression, if compressed)
47-
pub length: u64,
83+
pub fn length(&self) -> &u64 {
84+
&self.length
85+
}
86+
87+
#[inline]
4888
/// The compression codec used to compress the data
49-
#[serde(skip_serializing_if = "CompressionCodec::is_none")]
50-
#[serde(default)]
51-
pub compression_codec: CompressionCodec,
89+
pub fn compression_codec(&self) -> &CompressionCodec {
90+
&self.compression_codec
91+
}
92+
93+
#[inline]
5294
/// Arbitrary meta-information about the blob
53-
#[serde(skip_serializing_if = "HashMap::is_empty")]
54-
#[serde(default)]
55-
pub properties: HashMap<String, String>,
95+
pub fn properties(&self) -> &HashMap<String, String> {
96+
&self.properties
97+
}
5698
}
5799

58100
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
@@ -92,12 +134,10 @@ impl Flag {
92134
/// For more information, see: https://iceberg.apache.org/puffin-spec/#filemetadata
93135
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)]
94136
pub struct FileMetadata {
95-
/// Metadata about blobs in file
96-
pub blobs: Vec<BlobMetadata>,
97-
/// Arbitrary meta-information, like writer identification/version.
137+
pub(crate) blobs: Vec<BlobMetadata>,
98138
#[serde(skip_serializing_if = "HashMap::is_empty")]
99139
#[serde(default)]
100-
pub properties: HashMap<String, String>,
140+
pub(crate) properties: HashMap<String, String>,
101141
}
102142

103143
impl FileMetadata {
@@ -247,6 +287,18 @@ impl FileMetadata {
247287
FileMetadata::extract_footer_payload_as_str(&footer_bytes, footer_payload_length)?;
248288
FileMetadata::from_json_str(&footer_payload_str)
249289
}
290+
291+
#[inline]
292+
/// Metadata about blobs in file
293+
pub fn blobs(&self) -> &Vec<BlobMetadata> {
294+
&self.blobs
295+
}
296+
297+
#[inline]
298+
/// Arbitrary meta-information, like writer identification/version.
299+
pub fn properties(&self) -> &HashMap<String, String> {
300+
&self.properties
301+
}
250302
}
251303

252304
#[cfg(test)]

0 commit comments

Comments
 (0)