Skip to content

Resolves #159: Join indexes - #160

Closed
MMcM wants to merge 4 commits into
FoundationDB:masterfrom
MMcM:simple-join-indexes
Closed

MMcM wants to merge 4 commits into
FoundationDB:masterfrom
MMcM:simple-join-indexes

Conversation

@MMcM

@MMcM MMcM commented Nov 20, 2018 •

Copy link
Copy Markdown
Collaborator

No description provided.

@MMcM
MMcM force-pushed the simple-join-indexes branch from b8feff1 to fa397d3 Compare November 20, 2018 05:52

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 0
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 20

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)

See all issues in SonarCloud

@MMcM
MMcM force-pushed the simple-join-indexes branch from fa397d3 to b339545 Compare November 20, 2018 06:36

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 0
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 6

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)

See all issues in SonarCloud

// TODO: need some state to avoid generating the same synthetic record via more than one self-join path for non-idempotent indexes.
final SyntheticRecordPlanner syntheticPlanner = new SyntheticRecordPlanner(store.getRecordMetaData(), store.getRecordStoreState().withWriteOnlyIndexes(Collections.singletonList(index.getName())));
syntheticPlan = syntheticPlanner.forIndex(index);
syntheticMaintainer = (IndexMaintainer<Message>)maintainer;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I created #165 for the bigger issue (I think) here.

@MMcM
MMcM force-pushed the simple-join-indexes branch from b339545 to b44a8f6 Compare November 22, 2018 21:36
@FoundationDB FoundationDB deleted a comment from MMcM Nov 22, 2018
@FoundationDB FoundationDB deleted a comment from MMcM Nov 22, 2018

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 0
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 8

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  2. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  3. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)

See all issues in SonarCloud

import java.util.List;
import java.util.Map;

// TODO: This could be just FDBRecord<Message> if we were willing to change the signature of the IndexMaintainer methods.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe FDBIndexableRecord in the middle.

if (syntheticIndex) {
// Need to do this each transaction because other index enabled state might have changed. Could cache based on that.
// Copying the state also guards against changes made by other online building from check version.
// TODO: need some state to avoid generating the same synthetic record via more than one self-join path for non-idempotent indexes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe some overall approach to duplicate detection / elimination here and in regular queries.

@MMcM
MMcM force-pushed the simple-join-indexes branch from b44a8f6 to 2cfc18f Compare November 28, 2018 01:09

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 0
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 8

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  2. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)
  3. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)

See all issues in SonarCloud

@MMcM
MMcM force-pushed the simple-join-indexes branch from 2cfc18f to 10fa7b1 Compare December 3, 2018 16:50

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 0
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 9

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  2. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)
  3. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)

See all issues in SonarCloud

@MMcM
MMcM force-pushed the simple-join-indexes branch from 10fa7b1 to 4453ad8 Compare December 3, 2018 16:57

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 0
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 8

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  2. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)
  3. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)

See all issues in SonarCloud

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 1
Vulnerability Vulnerabilities: 2
Code Smell Code Smells: 30

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)
  2. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)
  3. Code Smell Code Smell: Define a constant instead of duplicating this literal "Index " 3 times. (more)
  4. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  5. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)
  6. Code Smell Code Smell: Rename "recordType" which hides the field declared at line 1888. (more)
  7. Bug Bug: A "NullPointerException" could be thrown; "evaluated" is nullable here. (more)
  8. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  9. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  10. Code Smell Code Smell: Rename "evaluated" which hides the field declared at line 1898. (more)
  11. Code Smell Code Smell: Remove usage of generic wildcard type. (more)
  12. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  13. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  14. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  15. Vulnerability Vulnerability: Make this member "protected". (more)
  16. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  17. Code Smell Code Smell: Remove this use of "getRecordCountKey"; it is deprecated. (more)
  18. Vulnerability Vulnerability: Make this member "protected". (more)
  19. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  20. Code Smell Code Smell: Reduce the total number of break and continue statements in this loop to use at most one. (more)
  21. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  22. Code Smell Code Smell: Remove the declaration of thrown exception 'com.apple.foundationdb.record.metadata.expressions.KeyExpression$SerializationException' which is a runtime exception. (more)
  23. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  24. Code Smell Code Smell: Remove this use of "hasIndexed"; it is deprecated. (more)
  25. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  26. Code Smell Code Smell: Remove this use of "hasRecordCountKey"; it is deprecated. (more)

See all issues in SonarCloud

@MMcM
MMcM force-pushed the simple-join-indexes branch from 3295dcf to 641937b Compare December 20, 2018 16:21

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 1
Vulnerability Vulnerabilities: 2
Code Smell Code Smells: 38

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  2. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  3. Code Smell Code Smell: Remove this use of "hasRecordCountKey"; it is deprecated. (more)
  4. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)
  5. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  6. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  7. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  8. Code Smell Code Smell: Remove this use of "hasIndexed"; it is deprecated. (more)
  9. Code Smell Code Smell: Define a constant instead of duplicating this literal "No records added yet" 5 times. (more)
  10. Vulnerability Vulnerability: Make this member "protected". (more)
  11. Code Smell Code Smell: Remove the declaration of thrown exception 'com.apple.foundationdb.record.metadata.expressions.KeyExpression$SerializationException' which is a runtime exception. (more)
  12. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  13. Code Smell Code Smell: Remove usage of generic wildcard type. (more)
  14. Code Smell Code Smell: Reduce the total number of break and continue statements in this loop to use at most one. (more)
  15. Vulnerability Vulnerability: Make this member "protected". (more)
  16. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  17. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  18. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  19. Code Smell Code Smell: Remove this use of "getRecordCountKey"; it is deprecated. (more)
  20. Code Smell Code Smell: Rename "recordType" which hides the field declared at line 1888. (more)
  21. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  22. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  23. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  24. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)
  25. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  26. Bug Bug: A "NullPointerException" could be thrown; "evaluated" is nullable here. (more)
  27. Code Smell Code Smell: Define a constant instead of duplicating this literal "Index " 3 times. (more)
  28. Code Smell Code Smell: Rename "evaluated" which hides the field declared at line 1898. (more)
  29. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  30. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 31 to the 30 allowed. (more)
  31. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  32. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)
  33. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  34. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)

See all issues in SonarCloud

@MMcM
MMcM force-pushed the simple-join-indexes branch 2 times, most recently from 6ae033a to 67a6cca Compare January 8, 2019 23:20
MMcM added 2 commits January 12, 2019 08:18
…are made from stored records.

In particular, joined record types, which synthesize by means of equi-joins.
@MMcM
MMcM force-pushed the simple-join-indexes branch from 67a6cca to b77b154 Compare January 12, 2019 20:06

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 1
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 44

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  2. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  3. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  4. Code Smell Code Smell: Remove this use of "hasIndexed"; it is deprecated. (more)
  5. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  6. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  7. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  8. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 31 to the 30 allowed. (more)
  9. Code Smell Code Smell: Remove the declaration of thrown exception 'com.apple.foundationdb.record.metadata.expressions.KeyExpression$SerializationException' which is a runtime exception. (more)
  10. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  11. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  12. Code Smell Code Smell: Define a constant instead of duplicating this literal "Union field " 3 times. (more)
  13. Code Smell Code Smell: Reduce the total number of break and continue statements in this loop to use at most one. (more)
  14. Code Smell Code Smell: Define a constant instead of duplicating this literal "Index " 3 times. (more)
  15. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  16. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)
  17. Code Smell Code Smell: Define a constant instead of duplicating this literal "No records added yet" 5 times. (more)
  18. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  19. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  20. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  21. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)
  22. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  23. Code Smell Code Smell: Rename "evaluated" which hides the field declared at line 1219. (more)
  24. Code Smell Code Smell: Remove this use of "hasRecordCountKey"; it is deprecated. (more)
  25. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  26. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  27. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  28. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  29. Bug Bug: A "NullPointerException" could be thrown; "evaluated" is nullable here. (more)
  30. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  31. Code Smell Code Smell: Remove this use of "getRecordCountKey"; it is deprecated. (more)
  32. Code Smell Code Smell: Rename "recordType" which hides the field declared at line 1209. (more)
  33. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  34. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)

See all issues in SonarCloud

@MMcM
MMcM force-pushed the simple-join-indexes branch from b77b154 to 6075586 Compare January 12, 2019 20:53

@fdb-build fdb-build left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SonarQube analysis found issues:
Bug Bugs: 1
Vulnerability Vulnerabilities: 0
Code Smell Code Smells: 39

Including the following issue(s) which could not be reported in line:

  1. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  2. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  3. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  4. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  5. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)
  6. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 33 to the 30 allowed. (more)
  7. Code Smell Code Smell: Remove the declaration of thrown exception 'com.apple.foundationdb.record.metadata.expressions.KeyExpression$SerializationException' which is a runtime exception. (more)
  8. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  9. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  10. Code Smell Code Smell: Remove this expression which always evaluates to "true" (more)
  11. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  12. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  13. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  14. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  15. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  16. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  17. Code Smell Code Smell: Reduce the total number of break and continue statements in this loop to use at most one. (more)
  18. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  19. Code Smell Code Smell: Define a constant instead of duplicating this literal "No records added yet" 5 times. (more)
  20. Code Smell Code Smell: Remove this use of "getRecordCountKey"; it is deprecated. (more)
  21. Code Smell Code Smell: Remove this use of "getIndexed"; it is deprecated. (more)
  22. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  23. Code Smell Code Smell: Complete the task associated to this TODO comment. (more)
  24. Code Smell Code Smell: Rename "evaluated" which hides the field declared at line 1219. (more)
  25. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  26. Bug Bug: A "NullPointerException" could be thrown; "evaluated" is nullable here. (more)
  27. Code Smell Code Smell: Rename "recordType" which hides the field declared at line 1209. (more)
  28. Code Smell Code Smell: Define a constant instead of duplicating this literal "Union field " 3 times. (more)
  29. Code Smell Code Smell: Refactor this method to reduce its Cognitive Complexity from 31 to the 30 allowed. (more)
  30. Code Smell Code Smell: Define a constant instead of duplicating this literal "Index " 3 times. (more)
  31. Code Smell Code Smell: 2 duplicated blocks of code must be removed. (more)
  32. Code Smell Code Smell: Do not forget to remove this deprecated code someday. (more)
  33. Code Smell Code Smell: Remove this use of "hasRecordCountKey"; it is deprecated. (more)
  34. Code Smell Code Smell: Remove this use of "hasIndexed"; it is deprecated. (more)

See all issues in SonarCloud

if (!conditions.isEmpty()) {
builder.setFilter(conditions.size() > 1 ? Query.and(conditions) : conditions.get(0));
}
// TODO: Would it be better to do this more centrally?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Smell Code Smell: Complete the task associated to this TODO comment. (squid:S1135)

See it in SonarCloud

for (Constituent constituent : constituents) {
keys.add(constituent.getRecordType().getPrimaryKey());
}
// TODO: Would a non-flattened version of concat be easier to deal with?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Smell Code Smell: Complete the task associated to this TODO comment. (squid:S1135)

See it in SonarCloud

public void addMultiTypeIndex(@Nullable List<RecordTypeBuilder> recordTypes, @Nonnull Index index) {
public void addMultiTypeIndex(@Nullable List<? extends RecordTypeIndexesBuilder> recordTypes, @Nonnull Index index) {
addIndexCommon(index);
if (recordTypes == null || recordTypes.size() == 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Smell Code Smell: Use isEmpty() to check whether the collection is empty or not. (squid:S1155)

See it in SonarCloud

final SyntheticRecordFromStoredRecordPlan fromRecord = forType(syntheticRecordType);
// Query to get all records of the needed type(s).
RecordQueryPlan query = queryPlanner.plan(RecordQuery.newBuilder().setRecordTypes(fromRecord.getStoredRecordTypes()).build());
return new SyntheticRecordScanPlan(query, fromRecord, true); // TODO: better needDistinct calculation

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Smell Code Smell: Complete the task associated to this TODO comment. (squid:S1135)

See it in SonarCloud

@@ -395,6 +457,12 @@ public RecordMetaDataProto.MetaData toProto(@Nullable Descriptors.FileDescriptor
builder.setRecordCountKey(recordCountKey.toKeyExpression());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Smell Code Smell: Remove this use of "setRecordCountKey"; it is deprecated. (squid:CallToDeprecatedMethod)

See it in SonarCloud

if (syntheticIndex) {
// Need to do this each transaction because other index enabled state might have changed. Could cache based on that.
// Copying the state also guards against changes made by other online building from check version.
// TODO: need some state to avoid generating the same synthetic record via more than one self-join path for non-idempotent indexes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Smell Code Smell: Complete the task associated to this TODO comment. (squid:S1135)

See it in SonarCloud

@MMcM

MMcM commented Jan 15, 2019

Copy link
Copy Markdown
Collaborator Author

Reopening after repo switchover.

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