Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "massmap"
version = "0.1.4"
version = "0.1.5"
edition = "2024"
authors = ["SF-Zhou <sfzhou.scut@gmail.com>"]
homepage = "https://github.com/SF-Zhou/massmap"
Expand Down
23 changes: 12 additions & 11 deletions src/massmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ pub struct MassMapInner<R: MassMapReader, H: MassMapHashLoader = MassMapDefaultH
/// Metadata describing the layout and hashing strategy of the backing file.
pub meta: MassMapMeta,
/// Metadata for each hash bucket in the map.
pub(crate) bucket_metas: Vec<MassMapBucketMeta>,
pub bucket_metas: Vec<MassMapBucketMeta>,
/// Hash state initialized with the stored seed.
build_hasher: H::BuildHasher,
/// Reader used to access the backing storage.
pub(crate) reader: R,
pub reader: R,
}

/// Typed view over a [`MassMapInner`].
Expand Down Expand Up @@ -142,24 +142,24 @@ where
}

/// Exposes a reference to the underlying immutable metadata.
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meta() method is now public but lacks documentation explaining what metadata is exposed and how it can be used. Consider adding documentation similar to the newly documented methods below it, explaining the purpose and typical use cases of accessing the metadata.

Suggested change
/// Exposes a reference to the underlying immutable metadata.
/// Returns a reference to the underlying massmap metadata.
///
/// The metadata describes the layout, hashing strategy, and configuration
/// details of the massmap file. This can be useful for diagnostics,
/// testing, or when you need to inspect how the map was constructed.

Copilot uses AI. Check for mistakes.
///
/// This is primarily intended for internal crate use (e.g. merging maps).
pub(crate) fn meta(&self) -> &MassMapMeta {
pub fn meta(&self) -> &MassMapMeta {
&self.inner.meta
}

/// Exposes a reference to the underlying bucket metadata array.
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bucket_metas() method is now public but lacks documentation. Consider adding documentation that explains:

  • What bucket metadata contains (offset, length, count for each bucket)
  • The typical use cases for accessing this information
  • The relationship between the returned slice and the bucket count
Suggested change
/// Exposes a reference to the underlying bucket metadata array.
/// Returns a reference to the array of metadata for each hash bucket in the map.
///
/// Each [`MassMapBucketMeta`] describes a single bucket's layout in the backing file,
/// including its offset, length, and entry count. This information is useful for
/// diagnostics, advanced iteration, or direct inspection of the bucket structure.
///
/// The returned slice has length equal to the number of buckets in the map
/// (see [`bucket_count()`]), with each element corresponding to a bucket in order.

Copilot uses AI. Check for mistakes.
pub(crate) fn bucket_metas(&self) -> &[MassMapBucketMeta] {
pub fn bucket_metas(&self) -> &[MassMapBucketMeta] {
&self.inner.bucket_metas
}

/// Exposes the underlying header for internal crate use.
pub(crate) fn header(&self) -> &MassMapHeader {
/// Returns a reference to the underlying massmap header.
///
/// This can be used to inspect metadata about the massmap file, such as version or configuration.
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation is misleading. According to the MassMapHeader struct definition (meta.rs:11-16), the header only contains meta_offset and meta_length, not version or configuration information. Those are stored in MassMapMeta.

Consider updating the documentation to accurately reflect what's in the header:

/// Returns a reference to the underlying massmap header.
///
/// This provides access to the metadata location information (offset and length) in the massmap file.
Suggested change
/// This can be used to inspect metadata about the massmap file, such as version or configuration.
/// This provides access to the metadata location information (offset and length) in the massmap file.

Copilot uses AI. Check for mistakes.
pub fn header(&self) -> &MassMapHeader {
&self.inner.header
}

/// Exposes a reference to the underlying reader for internal crate use.
pub(crate) fn reader(&self) -> &R {
/// Returns a reference to the underlying reader used to access the backing storage.
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The documentation for reader() should specify what operations can be performed with the reader. For example, mention that it provides read-only access and implements the MassMapReader trait, or link to relevant documentation about how to use it.

Suggested change
/// Returns a reference to the underlying reader used to access the backing storage.
/// Returns a reference to the underlying reader used to access the backing storage.
///
/// The returned reader provides read-only access to the massmap data and implements
/// the [`MassMapReader`](crate::MassMapReader) trait. You can use it to perform
/// low-level read operations as defined by the trait. See the [`MassMapReader`]
/// documentation for details on available methods and usage.

Copilot uses AI. Check for mistakes.
pub fn reader(&self) -> &R {
&self.inner.reader
}

Expand Down Expand Up @@ -295,7 +295,8 @@ where
})
}

fn bucket_index<Q>(&self, k: &Q) -> usize
/// Computes the bucket index for the given key.
Copy link

Copilot AI Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly public bucket_index() method lacks documentation explaining what the bucket index is used for and what valid range of values it can return. Consider adding documentation that explains:

  • What a bucket index represents in the context of the massmap
  • The valid range (0 to bucket_count - 1)
  • A typical use case for accessing this method
Suggested change
/// Computes the bucket index for the given key.
/// Computes the bucket index for the given key.
///
/// # What is a bucket index?
/// The bucket index represents the position of the hash bucket in the massmap
/// where the given key would be stored. Each bucket contains zero or more key-value pairs.
///
/// # Valid range
/// Returns a value in the range `0..bucket_count`, where `bucket_count` is the number of buckets
/// in the map (i.e., `self.inner.bucket_metas.len()`). The valid range is `0` to `bucket_count - 1`.
///
/// # Typical use case
/// This method is useful for debugging, testing, or advanced inspection of the map's internal
/// structure, such as determining which bucket a key would be assigned to.

Copilot uses AI. Check for mistakes.
pub fn bucket_index<Q>(&self, k: &Q) -> usize
where
K: Borrow<Q>,
Q: Eq + Hash + ?Sized,
Expand Down
Loading