-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Indexer] Create
objects_version
table.
## Description This table maps an object's ID and version to a checkpoint sequence number, in a table partitioned by the first byte of the object ID. This speeds up look ups into `objects_history` by offering a path for a first look-up to the correct partition in that table for a given object's ID and version. This PR introduces the table, and the logic to populate it in the indexer. ## Test plan ``` sui$ cargo nextest run -p sui-indexer sui$ cargo nextest run -p sui-graphql-rpc sui$ cargo nextest run -p sui-graphql-e2e-tests --features pg_integration ```
- Loading branch information
Showing
8 changed files
with
841 additions
and
3 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
crates/sui-indexer/migrations/mysql/2024-05-05-155158_obj_indices/down.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,2 @@ | ||
-- This file should undo anything in `up.sql` | ||
-- TODO: objects_version |
1 change: 1 addition & 0 deletions
1
crates/sui-indexer/migrations/mysql/2024-05-05-155158_obj_indices/up.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 @@ | ||
-- TODO: objects_version |
1 change: 1 addition & 0 deletions
1
crates/sui-indexer/migrations/pg/2024-05-05-155158_obj_indices/down.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 @@ | ||
DROP TABLE IF EXISTS objects_version; |
778 changes: 778 additions & 0 deletions
778
crates/sui-indexer/migrations/pg/2024-05-05-155158_obj_indices/up.sql
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use diesel::prelude::*; | ||
|
||
use crate::schema::objects_version; | ||
|
||
use super::objects::StoredDeletedObject; | ||
use super::objects::StoredObject; | ||
|
||
#[derive(Queryable, Insertable, Debug, Identifiable, Clone, QueryableByName)] | ||
#[diesel(table_name = objects_version, primary_key(object_id, object_version))] | ||
pub struct StoredObjectVersion { | ||
pub object_id: Vec<u8>, | ||
pub object_version: i64, | ||
pub cp_sequence_number: i64, | ||
} | ||
|
||
impl From<&StoredObject> for StoredObjectVersion { | ||
fn from(o: &StoredObject) -> Self { | ||
Self { | ||
object_id: o.object_id.clone(), | ||
object_version: o.object_version, | ||
cp_sequence_number: o.checkpoint_sequence_number, | ||
} | ||
} | ||
} | ||
|
||
impl From<&StoredDeletedObject> for StoredObjectVersion { | ||
fn from(o: &StoredDeletedObject) -> Self { | ||
Self { | ||
object_id: o.object_id.clone(), | ||
object_version: o.object_version, | ||
cp_sequence_number: o.checkpoint_sequence_number, | ||
} | ||
} | ||
} |
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