-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Update only affected rows in KV storage #48435
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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
52 changes: 26 additions & 26 deletions
52
tests/queries/0_stateless/02577_keepermap_delete_update.reference
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
1 Some string 0 | ||
2 Some other string 0 | ||
3 random 0 | ||
4 random2 0 | ||
1 Some string 0 0 | ||
2 Some other string 0 0 | ||
3 random 0 0 | ||
4 random2 0 0 | ||
----------- | ||
3 random 0 | ||
4 random2 0 | ||
3 random 0 0 | ||
4 random2 0 0 | ||
----------- | ||
3 random 0 | ||
3 random 0 0 | ||
----------- | ||
0 | ||
----------- | ||
1 String 10 | ||
2 String 20 | ||
3 String 30 | ||
4 String 40 | ||
----------- | ||
1 String 10 | ||
2 String 20 | ||
3 Another 30 | ||
4 Another 40 | ||
----------- | ||
1 String 10 | ||
2 String 20 | ||
3 Another 30 | ||
4 Another 40 | ||
----------- | ||
1 String 102 | ||
2 String 202 | ||
3 Another 302 | ||
4 Another 402 | ||
1 String 10 0 | ||
2 String 20 0 | ||
3 String 30 0 | ||
4 String 40 0 | ||
----------- | ||
1 String 10 0 | ||
2 String 20 0 | ||
3 Another 30 1 | ||
4 Another 40 1 | ||
----------- | ||
1 String 10 0 | ||
2 String 20 0 | ||
3 Another 30 1 | ||
4 Another 40 1 | ||
----------- | ||
1 String 102 1 | ||
2 String 202 1 | ||
3 Another 302 2 | ||
4 Another 402 2 | ||
----------- |
40 changes: 20 additions & 20 deletions
40
tests/queries/0_stateless/02577_keepermap_delete_update.sql
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 |
---|---|---|
@@ -1,44 +1,44 @@ | ||
-- Tags: no-ordinary-database, no-fasttest | ||
|
||
DROP TABLE IF EXISTS 02661_keepermap_delete_update; | ||
DROP TABLE IF EXISTS 02577_keepermap_delete_update; | ||
|
||
CREATE TABLE 02661_keepermap_delete_update (key UInt64, value String, value2 UInt64) ENGINE=KeeperMap('/' || currentDatabase() || '/test02661_keepermap_delete_update') PRIMARY KEY(key); | ||
CREATE TABLE 02577_keepermap_delete_update (key UInt64, value String, value2 UInt64) ENGINE=KeeperMap('/' || currentDatabase() || '/test02577_keepermap_delete_update') PRIMARY KEY(key); | ||
|
||
INSERT INTO 02661_keepermap_delete_update VALUES (1, 'Some string', 0), (2, 'Some other string', 0), (3, 'random', 0), (4, 'random2', 0); | ||
INSERT INTO 02577_keepermap_delete_update VALUES (1, 'Some string', 0), (2, 'Some other string', 0), (3, 'random', 0), (4, 'random2', 0); | ||
|
||
SELECT * FROM 02661_keepermap_delete_update ORDER BY key; | ||
SELECT *, _version FROM 02577_keepermap_delete_update ORDER BY key; | ||
SELECT '-----------'; | ||
|
||
DELETE FROM 02661_keepermap_delete_update WHERE value LIKE 'Some%string'; | ||
DELETE FROM 02577_keepermap_delete_update WHERE value LIKE 'Some%string'; | ||
|
||
SELECT * FROM 02661_keepermap_delete_update ORDER BY key; | ||
SELECT *, _version FROM 02577_keepermap_delete_update ORDER BY key; | ||
SELECT '-----------'; | ||
|
||
ALTER TABLE 02661_keepermap_delete_update DELETE WHERE key >= 4; | ||
ALTER TABLE 02577_keepermap_delete_update DELETE WHERE key >= 4; | ||
|
||
SELECT * FROM 02661_keepermap_delete_update ORDER BY key; | ||
SELECT *, _version FROM 02577_keepermap_delete_update ORDER BY key; | ||
SELECT '-----------'; | ||
|
||
DELETE FROM 02661_keepermap_delete_update WHERE 1 = 1; | ||
SELECT count() FROM 02661_keepermap_delete_update; | ||
DELETE FROM 02577_keepermap_delete_update WHERE 1 = 1; | ||
SELECT count() FROM 02577_keepermap_delete_update; | ||
SELECT '-----------'; | ||
|
||
INSERT INTO 02661_keepermap_delete_update VALUES (1, 'String', 10), (2, 'String', 20), (3, 'String', 30), (4, 'String', 40); | ||
SELECT * FROM 02661_keepermap_delete_update ORDER BY key; | ||
INSERT INTO 02577_keepermap_delete_update VALUES (1, 'String', 10), (2, 'String', 20), (3, 'String', 30), (4, 'String', 40); | ||
SELECT *, _version FROM 02577_keepermap_delete_update ORDER BY key; | ||
SELECT '-----------'; | ||
|
||
ALTER TABLE 02661_keepermap_delete_update UPDATE value = 'Another' WHERE key > 2; | ||
SELECT * FROM 02661_keepermap_delete_update ORDER BY key; | ||
ALTER TABLE 02577_keepermap_delete_update UPDATE value = 'Another' WHERE key > 2; | ||
SELECT *, _version FROM 02577_keepermap_delete_update ORDER BY key; | ||
SELECT '-----------'; | ||
|
||
ALTER TABLE 02661_keepermap_delete_update UPDATE key = key * 10 WHERE 1 = 1; -- { serverError BAD_ARGUMENTS } | ||
SELECT * FROM 02661_keepermap_delete_update ORDER BY key; | ||
ALTER TABLE 02577_keepermap_delete_update UPDATE key = key * 10 WHERE 1 = 1; -- { serverError BAD_ARGUMENTS } | ||
SELECT *, _version FROM 02577_keepermap_delete_update ORDER BY key; | ||
SELECT '-----------'; | ||
|
||
ALTER TABLE 02661_keepermap_delete_update UPDATE value2 = value2 * 10 + 2 WHERE value2 < 100; | ||
SELECT * FROM 02661_keepermap_delete_update ORDER BY key; | ||
ALTER TABLE 02577_keepermap_delete_update UPDATE value2 = value2 * 10 + 2 WHERE value2 < 100; | ||
SELECT *, _version FROM 02577_keepermap_delete_update ORDER BY key; | ||
SELECT '-----------'; | ||
|
||
ALTER TABLE 02661_keepermap_delete_update ON CLUSTER test_shard_localhost UPDATE value2 = value2 * 10 + 2 WHERE value2 < 100; -- { serverError BAD_ARGUMENTS } | ||
ALTER TABLE 02577_keepermap_delete_update ON CLUSTER test_shard_localhost UPDATE value2 = value2 * 10 + 2 WHERE value2 < 100; -- { serverError BAD_ARGUMENTS } | ||
|
||
DROP TABLE IF EXISTS 02661_keepermap_delete_update; | ||
DROP TABLE IF EXISTS 02577_keepermap_delete_update; |
52 changes: 26 additions & 26 deletions
52
tests/queries/0_stateless/02707_keeper_map_delete_update_strict.reference
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
1 Some string 0 | ||
2 Some other string 0 | ||
3 random 0 | ||
4 random2 0 | ||
1 Some string 0 0 0 | ||
2 Some other string 0 0 0 | ||
3 random 0 0 0 | ||
4 random2 0 0 0 | ||
----------- | ||
3 random 0 | ||
4 random2 0 | ||
3 random 0 0 | ||
4 random2 0 0 | ||
----------- | ||
3 random 0 | ||
3 random 0 0 | ||
----------- | ||
0 | ||
----------- | ||
1 String 10 | ||
2 String 20 | ||
3 String 30 | ||
4 String 40 | ||
----------- | ||
1 String 10 | ||
2 String 20 | ||
3 Another 30 | ||
4 Another 40 | ||
----------- | ||
1 String 10 | ||
2 String 20 | ||
3 Another 30 | ||
4 Another 40 | ||
----------- | ||
1 String 102 | ||
2 String 202 | ||
3 Another 302 | ||
4 Another 402 | ||
1 String 10 0 | ||
2 String 20 0 | ||
3 String 30 0 | ||
4 String 40 0 | ||
----------- | ||
1 String 10 0 | ||
2 String 20 0 | ||
3 Another 30 1 | ||
4 Another 40 1 | ||
----------- | ||
1 String 10 0 | ||
2 String 20 0 | ||
3 Another 30 1 | ||
4 Another 40 1 | ||
----------- | ||
1 String 102 1 | ||
2 String 202 1 | ||
3 Another 302 2 | ||
4 Another 402 2 | ||
----------- |
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
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.
How
ALTER UPDATE WHERE
worked before if we didn't apply filters?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.
It correctly mutates the rows it needs by creating
SELECT if(condition, mutate, old_value)...
. The problem for KV store is that MutationIntepreter returns all the rows (changed and unchanged) causing an update on ALL keys while we only need a subset we would like to override.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.
Thanks. So, for rocksdb we will not rewrite values with the same
old_value
. And for keepermap we will also not update_version
.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.
exactly 😄