mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-26 01:20:38 +00:00
This introduces two new abstraction layers for I/O: - Block I/O, and - Blob I/O. The BlockReader trait abstracts a file or something else that can be read in 8kB pages. It is implemented by EphemeralFiles, and by a new FileBlockReader struct that allows reading arbitrary VirtualFiles in that manner, utilizing the page cache. There is also a new BlockCursor struct that works as a cursor over a BlockReader. When you create a BlockCursor and read the first page using it, it keeps the reference to the page. If you access the same page again, it avoids going to page cache and quickly returns the same page again. That can save a lot of lookups in the page cache if you perform multiple reads. The Blob-oriented API allows reading and writing "blobs" of arbitrary length. It is a layer on top of the block-oriented API. When you write a blob with the write_blob() function, it writes a length field followed by the actual data to the underlying block storage, and returns the offset where the blob was stored. The blob can be retrieved later using the offset. Finally, this replaces the I/O code in image-, delta-, and in-memory layers to use the new abstractions. These replace the 'bookfile' crate. This is a backwards-incompatible change to the storage format.
34 lines
943 B
Rust
34 lines
943 B
Rust
//! Main entry point for the dump_layerfile executable
|
|
//!
|
|
//! A handy tool for debugging, that's all.
|
|
use anyhow::Result;
|
|
use clap::{App, Arg};
|
|
use pageserver::layered_repository::dump_layerfile_from_path;
|
|
use pageserver::page_cache;
|
|
use pageserver::virtual_file;
|
|
use std::path::PathBuf;
|
|
use zenith_utils::GIT_VERSION;
|
|
|
|
fn main() -> Result<()> {
|
|
let arg_matches = App::new("Zenith dump_layerfile utility")
|
|
.about("Dump contents of one layer file, for debugging")
|
|
.version(GIT_VERSION)
|
|
.arg(
|
|
Arg::new("path")
|
|
.help("Path to file to dump")
|
|
.required(true)
|
|
.index(1),
|
|
)
|
|
.get_matches();
|
|
|
|
let path = PathBuf::from(arg_matches.value_of("path").unwrap());
|
|
|
|
// Basic initialization of things that don't change after startup
|
|
virtual_file::init(10);
|
|
page_cache::init(100);
|
|
|
|
dump_layerfile_from_path(&path, true)?;
|
|
|
|
Ok(())
|
|
}
|