Add support for reading bloom filter chunks by AHSauge · Pull Request #7279 · libgit2/libgit2 · GitHub
Skip to content

Add support for reading bloom filter chunks#7279

Open
AHSauge wants to merge 1 commit into
libgit2:mainfrom
AHSauge:feature/read-bloom-filter
Open

Add support for reading bloom filter chunks#7279
AHSauge wants to merge 1 commit into
libgit2:mainfrom
AHSauge:feature/read-bloom-filter

Conversation

@AHSauge

@AHSauge AHSauge commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

The filter settings are split out as a separate struct to make it easier to
avoid circular dependencies later down the line.

Related to #5758

@AHSauge AHSauge force-pushed the feature/read-bloom-filter branch from a38d825 to 64da1ec Compare June 4, 2026 07:55

@ethomson ethomson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this! A few stylistic comments - the only really relevant one is pulling the structure definition into commit_graph.c

Comment thread src/libgit2/commit_graph.c Outdated
Comment on lines +329 to +344

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At this point, I'd just pull these all together...

Suggested change
return error;
if ((error = commit_graph_parse_oid_fanout(file, data, &chunk_oid_fanout)) < 0 ||
(error = commit_graph_parse_oid_lookup(file, data, &chunk_oid_lookup)) < 0 ||
(error = commit_graph_parse_commit_data(file, data, &chunk_commit_data)) < 0 ||
(error = commit_graph_parse_extra_edge_list(file, data, &chunk_extra_edge_list)) < 0 ||
(error = commit_graph_parse_bloom_filter(file, data,
&chunk_bloom_filter_index, &chunk_bloom_filter_data)) < 0)
return error;

Comment thread src/libgit2/commit_graph.h Outdated
@@ -59,6 +60,9 @@ typedef struct git_commit_graph_file {
/* The number of entries in the Extra Edge List table. Each entry is 4 bytes wide. */
size_t num_extra_edge_list;

/* Bloom filter data*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/* Bloom filter data*/
/* Bloom filter data */

Comment thread src/libgit2/commit_graph.c Outdated
Comment on lines +213 to +214
if (bloom_filter_index->length == 0
|| bloom_filter_data->length < 12)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (bloom_filter_index->length == 0
|| bloom_filter_data->length < 12)
if (bloom_filter_index->length == 0 ||
bloom_filter_data->length < 12)

Comment on lines +216 to +217
if (bloom_filter_index->length != file->num_commits * sizeof(uint32_t))
return commit_graph_error("malformed Bloom Filter Index chunk");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (bloom_filter_index->length != file->num_commits * sizeof(uint32_t))
return commit_graph_error("malformed Bloom Filter Index chunk");
if (bloom_filter_index->length != file->num_commits * sizeof(uint32_t))
return commit_graph_error("malformed Bloom Filter Index chunk");

Comment thread src/libgit2/commit_graph.c Outdated
Comment on lines +219 to +221
/*
* Current valid hash version is 1 or 2
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/*
* Current valid hash version is 1 or 2
*/

* Current valid hash version is 1 or 2
*/
hash_version = ntohl(data_header[0]);
if (hash_version < 1 || hash_version > 2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (hash_version < 1 || hash_version > 2)
if (hash_version < 1 || hash_version > 2)

Comment thread src/libgit2/bloom_filter.h Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't a general-purpose bloom filter structure - I think that we should pull this into commit_graph.c with the rest of the commit graph structures.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure. The rationale behind the split was just to allow for code isolation down the line, but we can address that if necessary when we get there. I've merged the structure into git_commit_graph_file since that seems more sensible, and I believe I've address the other comments you had as well.

Please let me know if you want further adjustments

@AHSauge AHSauge force-pushed the feature/read-bloom-filter branch from 64da1ec to 0d1218c Compare June 6, 2026 14:19
@AHSauge AHSauge force-pushed the feature/read-bloom-filter branch from 0d1218c to dc6ffe0 Compare June 6, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants