Skip to content

Commit fef68c7

Browse files
Switch serialization format
1 parent f6ba30c commit fef68c7

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

stack-graphs/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ edition = "2018"
1515
[features]
1616
copious-debugging = []
1717
serde = ["dep:serde", "lsp-positions/serde"]
18-
storage = ["rusqlite", "serde", "rmp-serde"]
18+
storage = ["postcard", "rusqlite", "serde"]
1919
visualization = ["serde", "serde_json"]
2020

2121
[lib]
@@ -31,7 +31,7 @@ fxhash = "0.2"
3131
itertools = "0.10"
3232
libc = "0.2"
3333
lsp-positions = { version = "0.3", path = "../lsp-positions" }
34-
rmp-serde = { version = "1.1", optional = true }
34+
postcard = { version = "1", optional = true, features = ["use-std"] }
3535
rusqlite = { version = "0.28", optional = true, features = ["bundled", "functions"] }
3636
serde = { version = "1.0", optional = true, features = ["derive"] }
3737
serde_json = { version = "1.0", optional = true }

stack-graphs/src/storage.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::stitching::ForwardPartialPathStitcher;
3030
use crate::CancellationError;
3131
use crate::CancellationFlag;
3232

33-
const VERSION: usize = 3;
33+
const VERSION: usize = 4;
3434

3535
const SCHEMA: &str = r#"
3636
CREATE TABLE metadata (
@@ -75,9 +75,7 @@ pub enum StorageError {
7575
#[error(transparent)]
7676
Serde(#[from] serde::Error),
7777
#[error(transparent)]
78-
RmpSerdeDecode(#[from] rmp_serde::decode::Error),
79-
#[error(transparent)]
80-
RmpSerdeEncode(#[from] rmp_serde::encode::Error),
78+
PostcardError(#[from] postcard::Error),
8179
}
8280

8381
pub type Result<T> = std::result::Result<T, StorageError>;
@@ -283,7 +281,7 @@ impl SQLiteWriter {
283281
&file.to_string_lossy(),
284282
tag,
285283
error,
286-
&rmp_serde::to_vec_named(&graph)?,
284+
&postcard::to_stdvec(&graph)?,
287285
))?;
288286
Ok(())
289287
}
@@ -323,7 +321,7 @@ impl SQLiteWriter {
323321
let mut stmt =
324322
conn.prepare_cached("INSERT INTO graphs (file, tag, value) VALUES (?, ?, ?)")?;
325323
let graph = serde::StackGraph::from_graph_filter(graph, &FileFilter(file));
326-
stmt.execute((file_str, tag, &rmp_serde::to_vec_named(&graph)?))?;
324+
stmt.execute((file_str, tag, &postcard::to_stdvec(&graph)?))?;
327325
Ok(())
328326
}
329327

@@ -364,7 +362,7 @@ impl SQLiteWriter {
364362
);
365363
let symbol_stack = path.symbol_stack_precondition.storage_key(graph, partials);
366364
let path = serde::PartialPath::from_partial_path(graph, partials, path);
367-
root_stmt.execute((file_str, symbol_stack, &rmp_serde::to_vec_named(&path)?))?;
365+
root_stmt.execute((file_str, symbol_stack, &postcard::to_stdvec(&path)?))?;
368366
root_path_count += 1;
369367
} else if start_node.is_in_file(file) {
370368
copious_debugging!(
@@ -375,7 +373,7 @@ impl SQLiteWriter {
375373
node_stmt.execute((
376374
file_str,
377375
path.start_node.local_id,
378-
&rmp_serde::to_vec_named(&path)?,
376+
&postcard::to_stdvec(&path)?,
379377
))?;
380378
node_path_count += 1;
381379
} else {
@@ -525,7 +523,7 @@ impl SQLiteReader {
525523
copious_debugging!(" * Load from database");
526524
let mut stmt = conn.prepare_cached("SELECT value FROM graphs WHERE file = ?")?;
527525
let value = stmt.query_row([file], |row| row.get::<_, Vec<u8>>(0))?;
528-
let file_graph = rmp_serde::from_slice::<serde::StackGraph>(&value)?;
526+
let file_graph = postcard::from_bytes::<serde::StackGraph>(&value)?;
529527
file_graph.load_into(graph)?;
530528
Ok(graph.get_file(file).expect("loaded file to exist"))
531529
}
@@ -581,7 +579,7 @@ impl SQLiteReader {
581579
&mut self.loaded_graphs,
582580
&self.conn,
583581
)?;
584-
let path = rmp_serde::from_slice::<serde::PartialPath>(&value)?;
582+
let path = postcard::from_bytes::<serde::PartialPath>(&value)?;
585583
let path = path.to_partial_path(&mut self.graph, &mut self.partials)?;
586584
copious_debugging!(
587585
" > Loaded {}",
@@ -635,7 +633,7 @@ impl SQLiteReader {
635633
&mut self.loaded_graphs,
636634
&self.conn,
637635
)?;
638-
let path = rmp_serde::from_slice::<serde::PartialPath>(&value)?;
636+
let path = postcard::from_bytes::<serde::PartialPath>(&value)?;
639637
let path = path.to_partial_path(&mut self.graph, &mut self.partials)?;
640638
copious_debugging!(
641639
" > Loaded {}",

0 commit comments

Comments
 (0)