forked from groonga/groonga
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
defrag: defrag both patricia key and variable size columns
GitHub: groongaGH-2168 Ensure defragmentation covers both keys and variable-size columns in Patricia trees Previously, the defragmentation process for Patricia trees only targeted the keys, leaving variable-size columns untouched. This change handles both the keys and the variable-size columns.
- Loading branch information
Showing
3 changed files
with
124 additions
and
1 deletion.
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
101 changes: 101 additions & 0 deletions
101
test/command/suite/defrag/combined/pat_and_var_size_column.expected
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
table_create --name Users --flags TABLE_PAT_KEY --key_type ShortText | ||
[[0,0.0,0.0],true] | ||
column_create Users secret COLUMN_SCALAR ShortText | ||
[[0,0.0,0.0],true] | ||
delete Users --filter '_id == 2' | ||
[[0,0.0,0.0],true] | ||
object_inspect Users | ||
[ | ||
[ | ||
0, | ||
0.0, | ||
0.0 | ||
], | ||
{ | ||
"id": 256, | ||
"name": "Users", | ||
"type": { | ||
"id": 49, | ||
"name": "table:pat_key" | ||
}, | ||
"key": { | ||
"type": { | ||
"id": 14, | ||
"name": "ShortText", | ||
"type": { | ||
"id": 32, | ||
"name": "type" | ||
}, | ||
"size": 4096 | ||
}, | ||
"total_size": 36, | ||
"max_total_size": 4294967294 | ||
}, | ||
"value": { | ||
"type": null | ||
}, | ||
"n_records": 3, | ||
"disk_usage": 0 | ||
} | ||
] | ||
defrag Users | ||
[[0,0.0,0.0],true] | ||
#|w| segment_infos[1] = 2097160 after defrag | ||
object_inspect Users | ||
[ | ||
[ | ||
0, | ||
0.0, | ||
0.0 | ||
], | ||
{ | ||
"id": 256, | ||
"name": "Users", | ||
"type": { | ||
"id": 49, | ||
"name": "table:pat_key" | ||
}, | ||
"key": { | ||
"type": { | ||
"id": 14, | ||
"name": "ShortText", | ||
"type": { | ||
"id": 32, | ||
"name": "type" | ||
}, | ||
"size": 4096 | ||
}, | ||
"total_size": 27, | ||
"max_total_size": 4294967294 | ||
}, | ||
"value": { | ||
"type": null | ||
}, | ||
"n_records": 3, | ||
"disk_usage": 0 | ||
} | ||
] | ||
check Users | ||
[ | ||
[ | ||
0, | ||
0.0, | ||
0.0 | ||
], | ||
[ | ||
{ | ||
"flags": "0000C001", | ||
"key size": 4096, | ||
"value_size": 0, | ||
"tokenizer": 0, | ||
"normalizer": 0, | ||
"n_entries": 3, | ||
"curr_rec": 4, | ||
"curr_key": 27, | ||
"curr_del": 1, | ||
"curr_del2": 0, | ||
"curr_del3": 0, | ||
"n_garbages": 1 | ||
} | ||
] | ||
] |
22 changes: 22 additions & 0 deletions
22
test/command/suite/defrag/combined/pat_and_var_size_column.test
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# This is too slow with HTTP chunked. | ||
#@require-interface stdio | ||
|
||
table_create --name Users --flags TABLE_PAT_KEY --key_type ShortText | ||
column_create Users secret COLUMN_SCALAR ShortText | ||
|
||
# The 'secret' column stores large strings over 65536B, whicha are `SEQUENTIAL` | ||
# elements and stored in `SEQUENTIAL` segments. These segments will be | ||
# defragmentation targets. | ||
#@disable-logging | ||
#@generate-series 1 4 Users '{"_key" => "user-no-#{i}", "secret" => "#{"x" * (2 ** 20)}"}' | ||
#@enable-logging | ||
|
||
delete Users --filter '_id == 2' | ||
|
||
# After defragmentation, the total size of the PAT keys should decrease. | ||
# Additionally, defragmentation logs for the variable-size column should be | ||
# displayed. | ||
object_inspect Users | ||
defrag Users | ||
object_inspect Users | ||
check Users |