Skip to content

Commit d9f0496

Browse files
committed
marker info flag
1 parent 54b5762 commit d9f0496

File tree

3 files changed

+43
-24
lines changed

3 files changed

+43
-24
lines changed

provider/blob/src/blob_schema.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,16 @@ impl<'data, LocaleVecFormat: VarZeroVecFormat> BlobSchemaV3<'data, LocaleVecForm
171171
.ok_or_else(|| DataError::custom("Invalid blob bytes").with_req(marker, req))?;
172172
Ok((
173173
buffer,
174-
ZeroTrieSimpleAscii::from_store(zerotrie)
175-
.get(CHECKSUM_KEY)
176-
.and_then(|cs| Some(u64::from_le_bytes(self.buffers.get(cs)?.try_into().ok()?))),
174+
marker
175+
.has_checksum
176+
.then(|| {
177+
ZeroTrieSimpleAscii::from_store(zerotrie)
178+
.get(CHECKSUM_KEY)
179+
.and_then(|cs| {
180+
Some(u64::from_le_bytes(self.buffers.get(cs)?.try_into().ok()?))
181+
})
182+
})
183+
.flatten(),
177184
))
178185
}
179186

provider/core/src/marker.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,16 @@ impl DataMarkerId {
468468
#[derive(Copy, Clone, PartialEq, Eq)]
469469
#[non_exhaustive]
470470
pub struct DataMarkerInfo {
471-
/// TODO
471+
/// The ID of this marker.
472472
pub id: DataMarkerId,
473-
/// TODO
473+
/// Whether this data marker only has a single payload, not keyed by a data identifier.
474474
pub is_singleton: bool,
475-
/// TODO
475+
/// Whether this data marker uses checksums for integrity purposes.
476+
pub has_checksum: bool,
477+
/// The fallback to use for this data marker.
476478
pub fallback_config: LocaleFallbackConfig,
477-
/// TODO
479+
/// The attributes domain for this data marker. This can be used for filtering marker
480+
/// attributes during provider export.
478481
#[cfg(feature = "export")]
479482
pub attributes_domain: &'static str,
480483
}
@@ -504,6 +507,7 @@ impl DataMarkerInfo {
504507
id,
505508
fallback_config: LocaleFallbackConfig::default(),
506509
is_singleton: false,
510+
has_checksum: false,
507511
#[cfg(feature = "export")]
508512
attributes_domain: "",
509513
}

provider/export/src/export_impl.rs

+25-17
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ impl ExportDriver {
140140

141141
let transform_duration = instant1.elapsed();
142142

143-
flush_metadata.checksum = response.metadata.checksum;
143+
if marker.has_checksum {
144+
flush_metadata.checksum = response.metadata.checksum;
145+
} else if response.metadata.checksum.is_some() {
146+
log::warn!("{marker:?} returns a checksum, but it's not configured to");
147+
}
144148

145149
sink.flush_singleton(marker, &response.payload, flush_metadata)
146150
.map_err(|e| e.with_req(marker, Default::default()))?;
@@ -179,23 +183,27 @@ impl ExportDriver {
179183
})
180184
.collect::<Result<HashMap<_, _>, _>>()?;
181185

182-
flush_metadata.checksum =
183-
responses
184-
.iter()
185-
.try_fold(None, |acc, (id, (response, _))| {
186-
match (acc, response.metadata.checksum) {
187-
(Some(a), Some(b)) if a != b => {
188-
Err(DataError::custom("Mismatched checksums").with_req(
189-
marker,
190-
DataRequest {
191-
id: id.as_borrowed(),
192-
..Default::default()
193-
},
194-
))
186+
if marker.has_checksum {
187+
flush_metadata.checksum =
188+
responses
189+
.iter()
190+
.try_fold(None, |acc, (id, (response, _))| {
191+
match (acc, response.metadata.checksum) {
192+
(Some(a), Some(b)) if a != b => {
193+
Err(DataError::custom("Mismatched checksums").with_req(
194+
marker,
195+
DataRequest {
196+
id: id.as_borrowed(),
197+
..Default::default()
198+
},
199+
))
200+
}
201+
(a, b) => Ok(a.or(b)),
195202
}
196-
(a, b) => Ok(a.or(b)),
197-
}
198-
})?;
203+
})?;
204+
} else if responses.iter().any(|r| r.1 .0.metadata.checksum.is_some()) {
205+
log::warn!("{marker:?} returns a checksum, but it's not configured to");
206+
}
199207

200208
let (slowest_duration, slowest_id) = match deduplication_strategy {
201209
DeduplicationStrategy::Maximal | DeduplicationStrategy::RetainBaseLanguages => {

0 commit comments

Comments
 (0)