Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CNF operations #308

Open
Oppen opened this issue Jul 22, 2021 · 2 comments
Open

Implement CNF operations #308

Oppen opened this issue Jul 22, 2021 · 2 comments

Comments

@Oppen
Copy link
Collaborator

Oppen commented Jul 22, 2021

Conjunctive normal form (CNF) is a notation to represent some operations frequently used in a few niches. It can be seen as an extension of a feature we already support, which is union and intersection of many bitmaps at a time.

The idea is to come up with an API to pass a list (or, rather, array) of bitmaps for which to perform this efficiently and with minimal intermediate bitmap creation. A way to just compute cardinality in a memory efficient way sounds like a good idea as well.

If the proposal gains interest I may try to implement it, as it's useful for a project I work with.

An example of such an API would be:

typedef struct {
    size_t size;
    roaring_bitmap_t *bitmaps[];
} clause_t;

roaring_cnf(size_t n_conj, ...);

where n_conj tells us the number of intersections to perform, or the number of clauses we will be passing, and the varargs would be the clause_t typed clauses to intersect, each of which will have all of their contents unioned first.

@Oppen
Copy link
Collaborator Author

Oppen commented Jul 22, 2021

On a related issue: while I care most about the C version here, implementing in roaring first as an experiment may be a better idea, since it makes it easier to compare performance between several versions. Specially between only performing multiple unions at a time, having intermediate bitmaps for each clause, and multiple intersections of the results.

It could be an interesting convenience function either way.

@lemire
Copy link
Member

lemire commented Jul 22, 2021

Of some relevance...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants