-
Notifications
You must be signed in to change notification settings - Fork 38
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
Allow to create before_
prefixed columns in Consensus Commit
#844
Allow to create before_
prefixed columns in Consensus Commit
#844
Conversation
return !metadata.getPrimaryKeyColumnNames().contains(columnName) | ||
&& metadata.getAfterImageColumnNames().contains(columnName); |
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.
When the column is not primary key column and is an after image column, update the before column of the column.
With this change, users can create before_
prefixed columns as normal columns. If the column name is before_x
, the before column name is before_before_x
.
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.
Why don't you use just com.scalar.db.transaction.consensuscommit.TransactionTableMetadata#getBeforeImageColumnNames()
?
(added)^ Sorry, I meant return !metadata.getBeforeImageColumnNames().contains(columnName)
.
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.
But return !metadata.getBeforeImageColumnNames().contains(columnName)
contains the primary key columns? Or we can use return !metadata.getPrimaryKeyColumnNames().contains(columnName) && !metadata.getBeforeImageColumnNames().contains(columnName)
, but it looks like the current one is more straightforward. What do you think?
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.
Oops, got it. I had a wrong idea, and cluster key has before
column while partition key doesn't have. Please ignore the previous comment.
return !metadata.getPrimaryKeyColumnNames().contains(columnName) | ||
&& metadata.getAfterImageColumnNames().contains(columnName); |
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.
Why don't you use just com.scalar.db.transaction.consensuscommit.TransactionTableMetadata#getBeforeImageColumnNames()
?
(added)^ Sorry, I meant return !metadata.getBeforeImageColumnNames().contains(columnName)
.
@@ -70,6 +78,10 @@ public Set<String> getSecondaryIndexNames() { | |||
return tableMetadata.getSecondaryIndexNames(); | |||
} | |||
|
|||
public LinkedHashSet<String> getPrimaryKeyColumnNames() { |
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.
This is a very off-topic question and just out of curiosity, but why LinkedHashSet
is used not just more abstract Set
? I've not looked over all the usages. But it doesn't seem to need to be the concrete class type (sorry if I'm missing something)
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.
LinkedHashSet
contains the context of the fixed iteration order (the insertion order). But Set
doesn't have any context of the iteration order. We wanted to add the context of the iteration order to the return type.
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 see. So, List
would be a simpler? It has contains()
and ImmutableLinkedHashSet's contains()
seems O(n) as well as List's one
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.
Yeah, using List
is another possible idea. But the difference is that Set
doesn't allow to have the same element, but List
does. But, if I re-design this class, I would use List
. Thanks.
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.
Ah, that makes sense 😉
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.
LGTM! Thank you!
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.
LGTM! Thank you for your quick fix. I also confirmed the issue did not happen in my local environment.
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.
LGTM, thank you!
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.
LGTM! Thank you!
Currently, when we create a non-primary key column with a name that starts with
before_
, the column is not handled correctly. Specifically, the before column is not updated correctly in the prepare phase, as explained in the following comment:#841 (comment)
This PR fixes the issue. Please take a look!