-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Activate interning write side [DPP-710] (#11614)
After this PR is merged write side of string-interning is activated: * String interning table is being populated as part of usual indexing * Data migration will populate the table from already existent data Effect of populating string interning is not visible yet. List of changes * Add schema and data migrations where applicable * Patch up sandbox-classic and parallel indexer to populate string_interning persistence, and initialize write side string interning view * Add ledger_end_stringinterning_id to track the need for update at the view (+ aligning code) * remove lookupLedgerEndOffsetAndSequentialId * fix/extend unit-tests changelog_begin changelog_end
- Loading branch information
1 parent
93c07f4
commit f8f8807
Showing
44 changed files
with
498 additions
and
195 deletions.
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
2 changes: 1 addition & 1 deletion
2
...n-api/src/main/resources/db/migration/h2database-appendonly/V1__Append_only_schema.sha256
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 +1 @@ | ||
e28b88accecead16dcd67becabf7ad230654b65f93c277e785ba77203c3db8b5 | ||
bd9ddd16ae4ecc09923215635442c83b7894e95d23203baccde6df27cb0ce2cf |
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
1 change: 1 addition & 0 deletions
1
...ration/oracle-appendonly/V4__add_ledger_end_string_interning_columnt_to_parameters.sha256
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 @@ | ||
2131cf0ed208e236ebf0ae68c8153cb8080d3b133114902185393c2b34f0b45d |
5 changes: 5 additions & 0 deletions
5
...migration/oracle-appendonly/V4__add_ledger_end_string_interning_columnt_to_parameters.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
ALTER TABLE parameters | ||
ADD ledger_end_string_interning_id NUMBER; |
1 change: 1 addition & 0 deletions
1
.../src/main/resources/db/migration/postgres-appendonly/V113__enable_string_interning.sha256
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 @@ | ||
cc55310126bde9627d59698cee292506e4d80c8303f090ba8649c4f4c6e19fbc |
69 changes: 69 additions & 0 deletions
69
...api/src/main/resources/db/migration/postgres-appendonly/V113__enable_string_interning.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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
-- add string_interning ledger-end tracking column to parameters | ||
ALTER TABLE parameters | ||
ADD COLUMN ledger_end_string_interning_id INTEGER; | ||
|
||
-- create temporary sequence to populate the string_interning table as migrating data | ||
CREATE SEQUENCE string_interning_seq_temp; | ||
-- add temporary index to aid string lookups as migrating data | ||
CREATE UNIQUE INDEX string_interning_external_string_temp_idx ON string_interning USING btree (external_string); | ||
|
||
-- add temporary migration function | ||
CREATE FUNCTION insert_to_string_interning(prefix TEXT, table_name TEXT, selector_expr TEXT) | ||
RETURNS void | ||
LANGUAGE plpgsql | ||
AS | ||
$$ | ||
BEGIN | ||
EXECUTE | ||
'INSERT INTO string_interning(internal_id, external_string) ' || | ||
'SELECT nextval(''string_interning_seq_temp''), id ' || | ||
'FROM (SELECT DISTINCT ''' || prefix || ''' || ' || selector_expr || ' id FROM ' || table_name || ') distinct_ids ' || | ||
'WHERE NOT EXISTS (SELECT 1 FROM string_interning WHERE external_string = distinct_ids.id)' || | ||
'AND id IS NOT NULL'; | ||
END | ||
$$; | ||
|
||
-- data migrations | ||
|
||
-- template_id | ||
SELECT insert_to_string_interning('t|', 'participant_events_create', 'template_id'); | ||
SELECT insert_to_string_interning('t|', 'participant_events_divulgence', 'template_id'); | ||
SELECT insert_to_string_interning('t|', 'participant_events_consuming_exercise', 'template_id'); | ||
SELECT insert_to_string_interning('t|', 'participant_events_non_consuming_exercise', 'template_id'); | ||
|
||
-- party | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(flat_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(submitters)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(create_observers)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_create', 'unnest(create_signatories)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_events_divulgence', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_divulgence', 'unnest(submitters)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(flat_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(submitters)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_consuming_exercise', 'unnest(exercise_actors)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(tree_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(flat_event_witnesses)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(submitters)'); | ||
SELECT insert_to_string_interning('p|', 'participant_events_non_consuming_exercise', 'unnest(exercise_actors)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'participant_command_completions', 'unnest(submitters)'); | ||
|
||
SELECT insert_to_string_interning('p|', 'party_entries', 'party'); | ||
|
||
-- fill ledger-end | ||
UPDATE parameters | ||
SET ledger_end_string_interning_id = (SELECT max(internal_id) FROM string_interning); | ||
|
||
-- remove temporary SQL objects | ||
DROP SEQUENCE string_interning_seq_temp; | ||
DROP INDEX string_interning_external_string_temp_idx; | ||
DROP FUNCTION insert_to_string_interning(TEXT, TEXT, TEXT); | ||
|
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
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.