Share scanned source storage across native publications

This commit is contained in:
gloamxun committed 2026-11-28 23:25:29 +08:00
1 parent c09d545da6
commit d6ab5a025f
6 files changed
+46 -10

No files matched your search

@@ -472,7 +472,7 @@ impl Executor {
executor.fresh_job = false;
executor.job_name = execution.job_name;
executor.interaction_mode = execution.interaction_mode;
executor.sources = execution.sources.into_iter().map(Arc::new).collect();
executor.sources = execution.sources;
executor.stream_sources = execution.stream_sources;
executor.generated_inputs = execution.generated_inputs;
executor.split_discards = execution.split_discards;
@@ -3306,7 +3306,7 @@ impl Executor {
} else {
ParagraphMode::Vertical
},
sources: self.sources.into_iter().map(Arc::unwrap_or_clone).collect(),
sources: self.sources,
stream_sources: self.stream_sources,
generated_inputs: self.generated_inputs,
reads: self.reads,
@@ -3740,7 +3740,7 @@ impl Executor {
})
.collect();
let evidence = ExecutionEvidence {
sources: self.sources.into_iter().map(Arc::unwrap_or_clone).collect(),
sources: self.sources,
source_versions,
stream_sources: self.stream_sources,
generated_inputs: self.generated_inputs,
@@ -3784,7 +3784,7 @@ impl Executor {
io: self.io,
input_position: self.input_position,
paragraph_mode: ParagraphMode::Vertical,
sources: self.sources.into_iter().map(Arc::unwrap_or_clone).collect(),
sources: self.sources,
stream_sources: self.stream_sources,
generated_inputs: self.generated_inputs,
reads: self.reads,
@@ -114,7 +114,7 @@ impl FormatImage {
schema: SCHEMA,
engine: ENGINE.into(),
state,
sources: execution.sources.into_iter().map(Arc::new).collect(),
sources: execution.sources,
stream_sources: execution.stream_sources,
generated_inputs: execution.generated_inputs,
resources,
+3 -2
View File
@@ -654,7 +654,8 @@ pub struct Execution {
/// Physical scanner position, independent of macro definition/call spans.
pub input_position: Option<(usize, usize)>,
pub paragraph_mode: ParagraphMode,
pub sources: Vec<SourceFile>,
/// Physical and generated inputs in span-source order.
pub sources: Vec<std::sync::Arc<SourceFile>>,
/// Source IDs backed by the bytes delivered through an input stream.
#[serde(default)]
pub stream_sources: BTreeSet<usize>,
@@ -697,7 +698,7 @@ pub struct Error {
/// not a resumable executor checkpoint or a successful document.
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct ExecutionEvidence {
pub sources: Vec<SourceFile>,
pub sources: Vec<std::sync::Arc<SourceFile>>,
pub source_versions: Vec<SourceVersion>,
pub stream_sources: BTreeSet<usize>,
pub generated_inputs: std::collections::BTreeMap<usize, GeneratedInput>,
@@ -56,8 +56,8 @@ impl RevisionExecution {
.iter()
.enumerate()
.map(|(id, source)| {
// The previous result was built by this session. Match the
// scanned bytes, including generated and stream input.
// A shared source keeps its exact bytes across revisions.
// Independently loaded sources can also have identical content.
previous
.and_then(|old| {
old.execution
@@ -65,7 +65,7 @@ impl RevisionExecution {
.get(id)
.zip(old.source_versions.get(id))
})
.filter(|(old_source, _)| *old_source == source)
.filter(|(old_source, _)| Arc::ptr_eq(old_source, source) || old_source.as_ref() == source.as_ref())
.map_or_else(
|| SourceVersion {
sha256: format!("{:x}", Sha256::digest(&source.data)),