forked from probsys/hierarchical-irm
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Merge GenDB and SchemaHelper; use GenDB in pclean binary #212
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8b796e5
Merge GenDB and SchemaHelper and use GenDB in pclean
ThomasColthurst a7cd141
Finish initial pass of pclean_lib rewrite
ThomasColthurst bd8ff32
Fix build errors
ThomasColthurst f1019e0
Merge with master
ThomasColthurst 842dda6
Fix bugs revealed by tests
ThomasColthurst 885d252
Add descriptions to compute_domain_cache and other methods
ThomasColthurst 427be6d
Generate pclean samples by row number, not from CRP samples
ThomasColthurst e3245e7
Fix make_pclean_sample to create the correct entities
ThomasColthurst 86d7d43
Remove debug printfs
ThomasColthurst 50e6c24
Comment out failing test for now
ThomasColthurst 31f857b
Debugging printfs
ThomasColthurst 1300c6a
Nothing
ThomasColthurst 57ef714
Resolve merge
ThomasColthurst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,15 +10,11 @@ | |
#include "hirm.hh" | ||
#include "observations.hh" | ||
#include "pclean/schema.hh" | ||
#include "pclean/schema_helper.hh" | ||
|
||
class GenDB { | ||
public: | ||
const PCleanSchema& schema; | ||
|
||
// TODO(emilyaf): Merge PCleanSchemaHelper and GenDB. | ||
PCleanSchemaHelper schema_helper; | ||
|
||
// This data structure contains entity sets and linkages. Semantics are | ||
// map<tuple<class_name, reference_field_name, class_primary_key> ref_val>>, | ||
// where primary_key and ref_val are (integer) entity IDs. | ||
|
@@ -101,6 +97,9 @@ class GenDB { | |
const std::string& class_name, const std::string& ref_field, | ||
const int class_item, const int new_ref_val); | ||
|
||
// Translate the PCleanSchema into an HIRM T_schema. | ||
T_schema make_hirm_schema(); | ||
|
||
// Incorporates the items and values from stored_values (generally an output | ||
// of update_reference_items). | ||
void incorporate_reference( | ||
|
@@ -125,4 +124,34 @@ class GenDB { | |
// Disable copying. | ||
GenDB& operator=(const GenDB&) = delete; | ||
GenDB(const GenDB&) = delete; | ||
}; | ||
|
||
// The rest of these methods are conceptually private, but actually | ||
// public for testing. | ||
|
||
ThomasColthurst marked this conversation as resolved.
Show resolved
Hide resolved
|
||
void compute_domains_cache(); | ||
|
||
void compute_domains_for(const std::string& name); | ||
|
||
void compute_reference_indices_cache(); | ||
|
||
void compute_reference_indices_for(const std::string& name); | ||
|
||
void make_relations_for_queryfield( | ||
const QueryField& f, const PCleanClass& c, T_schema* schema); | ||
|
||
bool only_final_emissions; | ||
bool record_class_is_clean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add a comment for "domains"? |
||
std::map<std::string, std::vector<std::string>> domains; | ||
|
||
// Map keys are relation name, item index of a class, and reference field | ||
// name. The values in the inner map are the item index of the reference | ||
// class. (See tests for more intuition.) | ||
std::map<std::string, std::map<int, std::map<std::string, int>>> | ||
relation_reference_indices; | ||
|
||
// Map keys are class name, item index of a class, and reference field | ||
// name. The values in the inner map are the item index of the reference | ||
// class. (See tests for more intuition.) | ||
std::map<std::string, std::map<int, std::map<std::string, int>>> | ||
class_reference_indices; | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have a CRP for the Record class. What is the problem, and is there another way to fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the specific problem was that I assumed that there would be a CRP for the record class, and I wrote a test under that assumption, and then I added these lines to make that test pass.
But I also use the record class's CRP in pclean_lib.cc::make_pclean_sample to create a class_item for each new row. I'm open to suggestions for better ways to implement that, but I believe that sampling from the record class's CRP is what the model spec says to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For make_pclean_sample, I think we should just use a counter for class_item, or have the function take a vector of unique row IDs. I don't think the spec says to sample from the record class's CRP -- there's a one-to-one correspondence between observations and record class entities, and sampling from a record class CRP would result in multiple observations of a single record entity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. When I was talking about the spec, I was talking about the generative model described on page 7 under "PClean entity model".