rename EphmeralFile::size to EphemeralFile::len (#5076)

## Problem
close https://github.com/neondatabase/neon/issues/5034

## Summary of changes
Based on the
[comment](https://github.com/neondatabase/neon/pull/4994#discussion_r1297277922).
Just rename the `EphmeralFile::size` to `EphemeralFile::len`.
This commit is contained in:
Chengpeng Yan
2023-08-24 22:41:57 +08:00
committed by GitHub
parent f70871dfd0
commit fa74d5649e
2 changed files with 13 additions and 13 deletions

View File

@@ -22,7 +22,7 @@ pub struct EphemeralFile {
_tenant_id: TenantId,
_timeline_id: TimelineId,
file: VirtualFile,
size: u64,
len: u64,
/// An ephemeral file is append-only.
/// We keep the last page, which can still be modified, in [`Self::mutable_tail`].
/// The other pages, which can no longer be modified, are accessed through the page cache.
@@ -53,13 +53,13 @@ impl EphemeralFile {
_tenant_id: tenant_id,
_timeline_id: timeline_id,
file,
size: 0,
len: 0,
mutable_tail: [0u8; PAGE_SZ],
})
}
pub(crate) fn size(&self) -> u64 {
self.size
pub(crate) fn len(&self) -> u64 {
self.len
}
}
@@ -84,8 +84,8 @@ impl BlobWriter for EphemeralFile {
impl<'a> Writer<'a> {
fn new(ephemeral_file: &'a mut EphemeralFile) -> io::Result<Writer<'a>> {
Ok(Writer {
blknum: (ephemeral_file.size / PAGE_SZ as u64) as u32,
off: (ephemeral_file.size % PAGE_SZ as u64) as usize,
blknum: (ephemeral_file.len / PAGE_SZ as u64) as u32,
off: (ephemeral_file.len % PAGE_SZ as u64) as usize,
ephemeral_file,
})
}
@@ -154,7 +154,7 @@ impl BlobWriter for EphemeralFile {
}
}
let pos = self.size;
let pos = self.len;
let mut writer = Writer::new(self)?;
// Write the length field
@@ -172,11 +172,11 @@ impl BlobWriter for EphemeralFile {
writer.push_bytes(srcbuf)?;
if srcbuf.len() < 0x80 {
self.size += 1;
self.len += 1;
} else {
self.size += 4;
self.len += 4;
}
self.size += srcbuf.len() as u64;
self.len += srcbuf.len() as u64;
Ok(pos)
}
@@ -208,7 +208,7 @@ impl Drop for EphemeralFile {
impl BlockReader for EphemeralFile {
fn read_blk(&self, blknum: u32) -> Result<BlockLease, io::Error> {
let flushed_blknums = 0..self.size / PAGE_SZ as u64;
let flushed_blknums = 0..self.len / PAGE_SZ as u64;
if flushed_blknums.contains(&(blknum as u64)) {
let cache = page_cache::get();
loop {
@@ -242,7 +242,7 @@ impl BlockReader for EphemeralFile {
};
}
} else {
debug_assert_eq!(blknum as u64, self.size / PAGE_SZ as u64);
debug_assert_eq!(blknum as u64, self.len / PAGE_SZ as u64);
Ok(BlockLease::EphemeralFileMutableTail(&self.mutable_tail))
}
}

View File

@@ -238,7 +238,7 @@ impl InMemoryLayer {
///
pub async fn size(&self) -> Result<u64> {
let inner = self.inner.read().await;
Ok(inner.file.size())
Ok(inner.file.len())
}
///