Skip to content
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

Issue 1415 - DynamoDB store for table names & IDs #1418

Merged
merged 31 commits into from
Oct 12, 2023

Conversation

kr565370
Copy link
Collaborator

@kr565370 kr565370 commented Oct 10, 2023

Make sure you have checked all steps below.

Issue

Tests

  • My PR adds the following tests OR does not need testing for this extremely good reason:
    • InMemoryTableIndexTest
    • DynamoDBTableIndexIT
    • TableIdGeneratorTest

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it, or I have linked to a
    separate issue for that below.
  • If I have added, removed, or updated any external dependencies used in the project, I have updated the
    NOTICES file to reflect this.

@kr565370 kr565370 marked this pull request as ready for review October 10, 2023 11:30
# Conflicts:
#	java/configuration/src/main/java/sleeper/configuration/properties/instance/CommonProperty.java
#	java/configuration/src/test/java/sleeper/configuration/properties/InstancePropertiesTestHelper.java
@patchwork01 patchwork01 removed their assignment Oct 11, 2023

import java.util.Objects;

public class TableId {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the right name for this class, given it contains a field called tableId? It means that TableIndex has the method Optional<TableId> getTableById(String tableId); which looks wrong. Could call this class TableIdAndName? Alternatively rename the field tableId to tableUniqueId and then the method on TableIndex would be Optional<TableId> getTableByUniqueId(String tableUniqueId);?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've renamed the field, thanks.

@Test
void shouldGenerate32BitHexId() {
assertThat(TableIdGenerator.fromRandomSeed(0).generateString())
.isEqualTo("60b420bb");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth testing that a second call to the same TableIdGenerator gives a different string to the first one? There's nothing to stop someone reusing the same TableIdGenerator many times.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.withExpressionAttributeNames(Map.of("#tablename", TABLE_NAME_FIELD))),
new TransactWriteItem().withPut(new Put()
.withTableName(idIndexDynamoTableName)
.withItem(DynamoDBTableIdFormat.getItem(id))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As DynamoDBTableIdFormat.getItem(id) is used twice, I think it would be better to calculate it once and re-use it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


@Override
public Stream<TableId> streamAllTables() {
return streamPagedItems(dynamoDB, new ScanRequest().withTableName(nameIndexDynamoTableName))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use strongly consistent reads.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@gaffer01 gaffer01 removed their assignment Oct 11, 2023
@patchwork01 patchwork01 merged commit 3208c24 into main Oct 12, 2023
15 checks passed
@patchwork01 patchwork01 deleted the 1415-table-name-store branch October 12, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DynamoDB store for table names & IDs
3 participants