-
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.
Add string-interning data access [DPP-707] (#11484)
* Add new table, and party_id to party_entries * Add write side basics (DbDto, Schema) * Add read side basic (StorageBackendStringInterning) * Add StorageBackend unit test * Support for all DB backends changelog_begin changelog_end
- Loading branch information
1 parent
6c94164
commit 541d07c
Showing
21 changed files
with
174 additions
and
4 deletions.
There are no files selected for viewing
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 @@ | ||
86ded6839752d76bb3e3e6cde7f4ec103dea6cee6382b6695de95e84dd74d2da | ||
e28b88accecead16dcd67becabf7ad230654b65f93c277e785ba77203c3db8b5 |
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
...ion-api/src/main/resources/db/migration/oracle-appendonly/V3__Add_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 @@ | ||
f87eb3e6709109d9fa34a9757cf53e3f8b84584a079442eea6e8da4f4224dc2e |
7 changes: 7 additions & 0 deletions
7
...ration-api/src/main/resources/db/migration/oracle-appendonly/V3__Add_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,7 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
CREATE TABLE string_interning ( | ||
internal_id NUMBER PRIMARY KEY NOT NULL, | ||
external_string VARCHAR2(4000) | ||
); |
1 change: 1 addition & 0 deletions
1
...api/src/main/resources/db/migration/postgres-appendonly/V112__add_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 @@ | ||
d807d5d30cc3c3a55ad6a7319f21cc8a77f78c0a76fbdc94cd3c6a895e432fb7 |
7 changes: 7 additions & 0 deletions
7
...on-api/src/main/resources/db/migration/postgres-appendonly/V112__add_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,7 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
CREATE TABLE string_interning ( | ||
internal_id INTEGER PRIMARY KEY NOT NULL, | ||
external_string 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
30 changes: 30 additions & 0 deletions
30
.../src/main/scala/platform/store/backend/common/StringInterningStorageBackendTemplate.scala
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,30 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.platform.store.backend.common | ||
|
||
import java.sql.Connection | ||
|
||
import anorm.SqlParser.{int, str} | ||
import anorm.{RowParser, SqlStringInterpolation, ~} | ||
import com.daml.platform.store.backend.StringInterningStorageBackend | ||
import com.daml.platform.store.SimpleSqlAsVectorOf.SimpleSqlAsVectorOf | ||
|
||
object StringInterningStorageBackendTemplate extends StringInterningStorageBackend { | ||
|
||
private val StringInterningEntriesParser: RowParser[(Int, String)] = | ||
int("internal_id") ~ str("external_string") map { case internalId ~ externalString => | ||
(internalId, externalString) | ||
} | ||
|
||
override def loadStringInterningEntries(fromIdExclusive: Int, untilIdInclusive: Int)( | ||
connection: Connection | ||
): Iterable[(Int, String)] = | ||
SQL""" | ||
SELECT internal_id, external_string | ||
FROM string_interning | ||
WHERE | ||
internal_id > $fromIdExclusive | ||
AND internal_id <= $untilIdInclusive | ||
""".asVectorOf(StringInterningEntriesParser)(connection) | ||
} |
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
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.