Unverified Commit ad898de7 authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

chore(turbo-tasks-backend): Fix build with `--features turbo-tasks-backend/lmdb` (#79530)

This had bit-rotted. Sounds like we do want to keep it around for sanity checking things from time-to-time.

Tested with:

```
cargo check --features turbo-tasks-backend/lmdb
```
parent 3d398a8f
...@@ -137,6 +137,10 @@ impl<'a, B: SerialWriteBatch<'a>> SerialWriteBatch<'a> for FreshDbOptimizationWr ...@@ -137,6 +137,10 @@ impl<'a, B: SerialWriteBatch<'a>> SerialWriteBatch<'a> for FreshDbOptimizationWr
fn delete(&mut self, key_space: KeySpace, key: WriteBuffer<'_>) -> Result<()> { fn delete(&mut self, key_space: KeySpace, key: WriteBuffer<'_>) -> Result<()> {
self.write_batch.delete(key_space, key) self.write_batch.delete(key_space, key)
} }
fn flush(&mut self, key_space: KeySpace) -> Result<()> {
self.write_batch.flush(key_space)
}
} }
impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a> impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a>
...@@ -149,4 +153,8 @@ impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a> ...@@ -149,4 +153,8 @@ impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a>
fn delete(&self, key_space: KeySpace, key: WriteBuffer<'_>) -> Result<()> { fn delete(&self, key_space: KeySpace, key: WriteBuffer<'_>) -> Result<()> {
self.write_batch.delete(key_space, key) self.write_batch.delete(key_space, key)
} }
unsafe fn flush(&self, key_space: KeySpace) -> Result<()> {
unsafe { self.write_batch.flush(key_space) }
}
} }
...@@ -189,4 +189,9 @@ impl<'a> SerialWriteBatch<'a> for LmbdWriteBatch<'a> { ...@@ -189,4 +189,9 @@ impl<'a> SerialWriteBatch<'a> for LmbdWriteBatch<'a> {
)?; )?;
Ok(()) Ok(())
} }
fn flush(&mut self, _key_space: KeySpace) -> Result<()> {
// this is an unimplemented optimization, this LMDB implemenation is only used in testing
Ok(())
}
} }
...@@ -6,7 +6,7 @@ use smallvec::SmallVec; ...@@ -6,7 +6,7 @@ use smallvec::SmallVec;
use thread_local::ThreadLocal; use thread_local::ThreadLocal;
use crate::database::{ use crate::database::{
key_value_database::KeyValueDatabase, key_value_database::{KeySpace, KeyValueDatabase},
write_batch::{ write_batch::{
BaseWriteBatch, ConcurrentWriteBatch, SerialWriteBatch, WriteBatch, WriteBuffer, BaseWriteBatch, ConcurrentWriteBatch, SerialWriteBatch, WriteBatch, WriteBuffer,
}, },
...@@ -88,7 +88,7 @@ impl<T: KeyValueDatabase + 'static> KeyValueDatabase for ReadTransactionCache<T> ...@@ -88,7 +88,7 @@ impl<T: KeyValueDatabase + 'static> KeyValueDatabase for ReadTransactionCache<T>
fn get<'l, 'db: 'l>( fn get<'l, 'db: 'l>(
&'l self, &'l self,
transaction: &'l Self::ReadTransaction<'db>, transaction: &'l Self::ReadTransaction<'db>,
key_space: super::key_value_database::KeySpace, key_space: KeySpace,
key: &[u8], key: &[u8],
) -> anyhow::Result<Option<Self::ValueBuffer<'l>>> { ) -> anyhow::Result<Option<Self::ValueBuffer<'l>>> {
self.database self.database
...@@ -168,11 +168,7 @@ impl<'a, T: KeyValueDatabase + 'static, B: BaseWriteBatch<'a>> BaseWriteBatch<'a ...@@ -168,11 +168,7 @@ impl<'a, T: KeyValueDatabase + 'static, B: BaseWriteBatch<'a>> BaseWriteBatch<'a
Self: 'l, Self: 'l,
'a: 'l; 'a: 'l;
fn get<'l>( fn get<'l>(&'l self, key_space: KeySpace, key: &[u8]) -> Result<Option<Self::ValueBuffer<'l>>>
&'l self,
key_space: super::key_value_database::KeySpace,
key: &[u8],
) -> Result<Option<Self::ValueBuffer<'l>>>
where where
'a: 'l, 'a: 'l,
{ {
...@@ -185,37 +181,32 @@ impl<'a, T: KeyValueDatabase, B: SerialWriteBatch<'a>> SerialWriteBatch<'a> ...@@ -185,37 +181,32 @@ impl<'a, T: KeyValueDatabase, B: SerialWriteBatch<'a>> SerialWriteBatch<'a>
{ {
fn put( fn put(
&mut self, &mut self,
key_space: super::key_value_database::KeySpace, key_space: KeySpace,
key: WriteBuffer<'_>, key: WriteBuffer<'_>,
value: WriteBuffer<'_>, value: WriteBuffer<'_>,
) -> Result<()> { ) -> Result<()> {
self.write_batch.put(key_space, key, value) self.write_batch.put(key_space, key, value)
} }
fn delete( fn delete(&mut self, key_space: KeySpace, key: WriteBuffer<'_>) -> Result<()> {
&mut self,
key_space: super::key_value_database::KeySpace,
key: WriteBuffer<'_>,
) -> Result<()> {
self.write_batch.delete(key_space, key) self.write_batch.delete(key_space, key)
} }
fn flush(&mut self, key_space: KeySpace) -> Result<()> {
self.write_batch.flush(key_space)
}
} }
impl<'a, T: KeyValueDatabase, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a> impl<'a, T: KeyValueDatabase, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a>
for ReadTransactionCacheWriteBatch<'a, T, B> for ReadTransactionCacheWriteBatch<'a, T, B>
{ {
fn put( fn put(&self, key_space: KeySpace, key: WriteBuffer<'_>, value: WriteBuffer<'_>) -> Result<()> {
&self,
key_space: super::key_value_database::KeySpace,
key: WriteBuffer<'_>,
value: WriteBuffer<'_>,
) -> Result<()> {
self.write_batch.put(key_space, key, value) self.write_batch.put(key_space, key, value)
} }
fn delete( fn delete(&self, key_space: KeySpace, key: WriteBuffer<'_>) -> Result<()> {
&self,
key_space: super::key_value_database::KeySpace,
key: WriteBuffer<'_>,
) -> Result<()> {
self.write_batch.delete(key_space, key) self.write_batch.delete(key_space, key)
} }
unsafe fn flush(&self, key_space: KeySpace) -> Result<()> {
unsafe { self.write_batch.flush(key_space) }
}
} }
use std::{ use std::{
borrow::Borrow, borrow::Borrow,
fs::{self, File}, fs::{self, File},
hash::BuildHasherDefault,
io::{BufWriter, Read, Write}, io::{BufWriter, Read, Write},
mem::transmute, mem::transmute,
path::PathBuf, path::PathBuf,
...@@ -10,7 +9,7 @@ use std::{ ...@@ -10,7 +9,7 @@ use std::{
use anyhow::{Ok, Result}; use anyhow::{Ok, Result};
use byteorder::WriteBytesExt; use byteorder::WriteBytesExt;
use rustc_hash::{FxHashMap, FxHasher}; use rustc_hash::FxHashMap;
use turbo_tasks::FxDashMap; use turbo_tasks::FxDashMap;
use crate::database::{ use crate::database::{
...@@ -290,6 +289,10 @@ impl<'a, B: SerialWriteBatch<'a>> SerialWriteBatch<'a> for StartupCacheWriteBatc ...@@ -290,6 +289,10 @@ impl<'a, B: SerialWriteBatch<'a>> SerialWriteBatch<'a> for StartupCacheWriteBatc
} }
self.batch.delete(key_space, key) self.batch.delete(key_space, key)
} }
fn flush(&mut self, key_space: KeySpace) -> Result<()> {
self.batch.flush(key_space)
}
} }
impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a> for StartupCacheWriteBatch<'a, B> { impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a> for StartupCacheWriteBatch<'a, B> {
...@@ -308,6 +311,10 @@ impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a> for StartupCacheW ...@@ -308,6 +311,10 @@ impl<'a, B: ConcurrentWriteBatch<'a>> ConcurrentWriteBatch<'a> for StartupCacheW
} }
self.batch.delete(key_space, key) self.batch.delete(key_space, key)
} }
unsafe fn flush(&self, key_space: KeySpace) -> Result<()> {
unsafe { self.batch.flush(key_space) }
}
} }
fn write_key_value_pair( fn write_key_value_pair(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment