Skip to content

Commit d9fd96f

Browse files
committed
Clarify data_for function
1 parent a11b72b commit d9fd96f

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

collector/src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ pub use self_profile::{QueryData, SelfProfile};
1616
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Deserialize)]
1717
pub struct DeltaTime(#[serde(with = "round_float")] pub f64);
1818

19-
/// The bound of a range changes in codebase
19+
/// The bound for finding an artifact
2020
///
21-
/// This can either be the upper or lower bound
21+
/// This can either be the upper or lower bound.
22+
/// In the case of commits or tags this is an exact bound, but for dates
23+
/// it's a best effort (i.e., if the bound is a date but there are no artifacts
24+
/// for that date, we'll find the artifact that most closely matches).
2225
#[derive(Debug, Clone, PartialEq, Eq)]
2326
pub enum Bound {
24-
/// An unverified git commit (in sha form)
27+
/// An unverified git commit (in sha form) or a tag of a commit (e.g., "1.53.0")
2528
Commit(String),
2629
/// A date in time
2730
Date(NaiveDate),
@@ -30,7 +33,7 @@ pub enum Bound {
3033
}
3134

3235
impl Bound {
33-
/// Tests whether self bounds the commit to the left
36+
/// Tests whether `self` matches commit when searching from the left
3437
pub fn left_match(&self, commit: &Commit) -> bool {
3538
match self {
3639
Bound::Commit(sha) => commit.sha == **sha,
@@ -42,7 +45,7 @@ impl Bound {
4245
}
4346
}
4447

45-
/// Tests whether self bounds the commit to the right
48+
/// Tests whether `self` matches commit when searching from the right
4649
pub fn right_match(&self, commit: &Commit) -> bool {
4750
match self {
4851
Bound::Commit(sha) => commit.sha == **sha,

database/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,11 @@ pub struct LabelId(pub u8, pub u32);
450450
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
451451
pub struct ArtifactIdNumber(pub u32);
452452

453-
/// Id lookups for various things
453+
/// Cached Id lookups for many database tables.
454454
///
455-
/// This is a quick way to find what the database id for something
455+
/// This is a quick way to find what the database id for something.
456+
/// Essentially duplicates of the various database tables (artifacts,
457+
/// error_series, pstat_series, etc.) so that we can avoid a network round-trip.
456458
#[derive(Debug, Clone, PartialEq, Eq, Default)]
457459
pub struct Index {
458460
/// Id look for a commit

site/src/comparison.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ pub async fn compare_given_commits(
230230
master_commits: &[collector::MasterCommit],
231231
) -> Result<Option<Comparison>, BoxedError> {
232232
let a = ctxt
233-
.data_for(true, start.clone())
233+
.artifact_id_for_bound(start.clone(), true)
234234
.ok_or(format!("could not find start commit for bound {:?}", start))?;
235-
let b = match ctxt.data_for(false, end.clone()) {
235+
let b = match ctxt.artifact_id_for_bound(end.clone(), false) {
236236
Some(b) => b,
237237
None => return Ok(None),
238238
};

site/src/load.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ impl SiteCtxt {
9595
]
9696
}
9797

98-
pub fn data_for(&self, is_left: bool, query: Bound) -> Option<ArtifactId> {
99-
crate::selector::data_for(&self.index.load(), is_left, query)
98+
pub fn artifact_id_for_bound(&self, query: Bound, is_left: bool) -> Option<ArtifactId> {
99+
crate::selector::artifact_id_for_bound(&self.index.load(), query, is_left)
100100
}
101101

102102
pub fn data_range(&self, range: RangeInclusive<Bound>) -> Vec<Commit> {

site/src/selector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::sync::Arc;
3939
///
4040
/// Searches the commits in the index either from the left or the right.
4141
/// If not found in those commits, searches through the artifacts in the index.
42-
pub fn data_for(data: &Index, is_left: bool, bound: Bound) -> Option<ArtifactId> {
42+
pub fn artifact_id_for_bound(data: &Index, bound: Bound, is_left: bool) -> Option<ArtifactId> {
4343
let commits = data.commits();
4444
let commit = if is_left {
4545
commits

0 commit comments

Comments
 (0)