Revert "address the "This is silly" comment"

This reverts commit c736f9d6ef.
This commit is contained in:
Christian Schwarz
2024-09-15 12:18:26 +01:00
parent 4b2b0a24da
commit 4c7599e8df
4 changed files with 16 additions and 40 deletions

View File

@@ -312,7 +312,8 @@ impl ValuesReconstructState {
&mut self,
key: &Key,
lsn: Lsn,
future_value: FutureValue,
completes: bool,
value: sync::oneshot::Receiver<Result<Bytes, std::io::Error>>,
) -> ValueReconstructSituation {
let state = self
.keys
@@ -320,22 +321,14 @@ impl ValuesReconstructState {
.or_insert(Ok(VectoredValueReconstructState::default()));
if let Ok(state) = state {
let key_done = match state.situation {
match state.situation {
ValueReconstructSituation::Complete => unreachable!(),
ValueReconstructSituation::Continue => match future_value {
FutureValue::Img { rx } => {
assert!(state.img.is_none());
state.img = Some((lsn, rx));
true
}
FutureValue::WalRecord { will_init, rx } => {
state.records.push((lsn, rx));
will_init
}
},
};
ValueReconstructSituation::Continue => {
state.records.push((lsn, value));
}
}
if key_done && state.situation == ValueReconstructSituation::Continue {
if completes && state.situation == ValueReconstructSituation::Continue {
state.situation = ValueReconstructSituation::Complete;
self.keys_done.add_key(*key);
}
@@ -366,16 +359,6 @@ impl ValuesReconstructState {
}
}
enum FutureValue {
WalRecord {
will_init: bool,
rx: sync::oneshot::Receiver<Result<Bytes, std::io::Error>>,
},
Img {
rx: sync::oneshot::Receiver<Result<Bytes, std::io::Error>>,
},
}
impl Default for ValuesReconstructState {
fn default() -> Self {
Self::new()

View File

@@ -1002,10 +1002,8 @@ impl DeltaLayerInner {
reconstruct_state.update_key(
&blob_meta.key,
blob_meta.lsn,
super::FutureValue::WalRecord {
will_init: blob_meta.will_init,
rx,
},
blob_meta.will_init,
rx,
);
}

View File

@@ -588,11 +588,8 @@ impl ImageLayerInner {
for (_, blob_meta) in read.blobs_at.as_slice() {
let (tx, rx) = oneshot::channel();
senders.insert((blob_meta.key, blob_meta.lsn), tx);
reconstruct_state.update_key(
&blob_meta.key,
blob_meta.lsn,
super::FutureValue::Img { rx },
);
reconstruct_state.update_key(&blob_meta.key, blob_meta.lsn, true, rx);
}
let buf_size = read.size();
@@ -627,7 +624,9 @@ impl ImageLayerInner {
let sender = senders
.remove(&(meta.meta.key, meta.meta.lsn))
.expect("sender must exist");
let bytes = Bytes::copy_from_slice(buf);
// TODO: this is silly - sort it out
let bytes = Value::ser(&Value::Image(Bytes::copy_from_slice(buf)))
.expect("stupid but correct");
let _ = sender.send(Ok(bytes.into()));
}

View File

@@ -467,11 +467,7 @@ impl InMemoryLayer {
let (tx, rx) = tokio::sync::oneshot::channel();
senders.insert((key, *entry_lsn), tx);
reconstruct_state.update_key(
&key,
*entry_lsn,
crate::tenant::storage_layer::FutureValue::WalRecord { will_init, rx },
);
reconstruct_state.update_key(&key, *entry_lsn, will_init, rx);
if will_init {
break;