Skip to content

Commit 111d0f3

Browse files
authored
chore: Expose puffin blob constructor (#1320)
## Which issue does this PR close? This PR expose public construction function for puffin blob, as discussed in the linked issue. The main motivation is: puffin blob is supposed to hold any type, so should be public-ly accessible by developers. - Closes #1311 ## Are these changes tested? This PR is a no-op change, I verified compilation passes through on my end.
1 parent 2070a4f commit 111d0f3

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

crates/iceberg/src/puffin/blob.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717

1818
use std::collections::HashMap;
1919

20+
use typed_builder::TypedBuilder;
21+
2022
/// A serialized form of a "compact" Theta sketch produced by the Apache DataSketches library.
2123
pub const APACHE_DATASKETCHES_THETA_V1: &str = "apache-datasketches-theta-v1";
2224
/// A serialized form of a deletion vector.
2325
pub const DELETION_VECTOR_V1: &str = "deletion-vector-v1";
2426

2527
/// The blob
26-
#[derive(Debug, PartialEq, Clone)]
28+
#[derive(Debug, PartialEq, Clone, TypedBuilder)]
2729
pub struct Blob {
2830
pub(crate) r#type: String,
2931
pub(crate) fields: Vec<i32>,

crates/iceberg/src/puffin/test_utils.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ pub(crate) fn uncompressed_metric_blob_0_metadata() -> BlobMetadata {
9898
}
9999

100100
pub(crate) fn blob_0() -> Blob {
101-
Blob {
102-
r#type: METRIC_BLOB_0_TYPE.to_string(),
103-
fields: METRIC_BLOB_0_INPUT_FIELDS.to_vec(),
104-
snapshot_id: METRIC_BLOB_0_SNAPSHOT_ID,
105-
sequence_number: METRIC_BLOB_0_SEQUENCE_NUMBER,
106-
data: METRIC_BLOB_0_DATA.as_bytes().to_vec(),
107-
properties: HashMap::new(),
108-
}
101+
Blob::builder()
102+
.r#type(METRIC_BLOB_0_TYPE.to_string())
103+
.fields(METRIC_BLOB_0_INPUT_FIELDS.to_vec())
104+
.snapshot_id(METRIC_BLOB_0_SNAPSHOT_ID)
105+
.sequence_number(METRIC_BLOB_0_SEQUENCE_NUMBER)
106+
.data(METRIC_BLOB_0_DATA.as_bytes().to_vec())
107+
.properties(HashMap::new())
108+
.build()
109109
}
110110

111111
pub(crate) const METRIC_BLOB_1_TYPE: &str = "some-other-blob";
@@ -142,14 +142,14 @@ pub(crate) fn zstd_compressed_metric_blob_1_metadata() -> BlobMetadata {
142142
}
143143

144144
pub(crate) fn blob_1() -> Blob {
145-
Blob {
146-
r#type: METRIC_BLOB_1_TYPE.to_string(),
147-
fields: METRIC_BLOB_1_INPUT_FIELDS.to_vec(),
148-
snapshot_id: METRIC_BLOB_1_SNAPSHOT_ID,
149-
sequence_number: METRIC_BLOB_1_SEQUENCE_NUMBER,
150-
data: METRIC_BLOB_1_DATA.as_bytes().to_vec(),
151-
properties: HashMap::new(),
152-
}
145+
Blob::builder()
146+
.r#type(METRIC_BLOB_1_TYPE.to_string())
147+
.fields(METRIC_BLOB_1_INPUT_FIELDS.to_vec())
148+
.snapshot_id(METRIC_BLOB_1_SNAPSHOT_ID)
149+
.sequence_number(METRIC_BLOB_1_SEQUENCE_NUMBER)
150+
.data(METRIC_BLOB_1_DATA.as_bytes().to_vec())
151+
.properties(HashMap::new())
152+
.build()
153153
}
154154

155155
pub(crate) const CREATED_BY_PROPERTY_VALUE: &str = "Test 1234";

0 commit comments

Comments
 (0)