Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 150 additions & 9 deletions delphi/create_dynamodb_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def create_job_queue_table(dynamodb, delete_existing=False):
{'AttributeName': 'conversation_id', 'AttributeType': 'S'},
{'AttributeName': 'job_type', 'AttributeType': 'S'},
{'AttributeName': 'priority', 'AttributeType': 'N'},
{'AttributeName': 'worker_id', 'AttributeType': 'S'}
{'AttributeName': 'worker_id', 'AttributeType': 'S'},
{'AttributeName': 'parent_job_id', 'AttributeType': 'S'},
{'AttributeName': 'root_job_id', 'AttributeType': 'S'},
{'AttributeName': 'job_stage', 'AttributeType': 'S'}
],
'BillingMode': 'PAY_PER_REQUEST',

Expand Down Expand Up @@ -201,6 +204,31 @@ def create_job_queue_table(dynamodb, delete_existing=False):
{'AttributeName': 'status', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
},
# Job tree-related indexes
{
'IndexName': 'ParentJobIndex',
'KeySchema': [
{'AttributeName': 'parent_job_id', 'KeyType': 'HASH'},
{'AttributeName': 'created_at', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
},
{
'IndexName': 'RootJobIndex',
'KeySchema': [
{'AttributeName': 'root_job_id', 'KeyType': 'HASH'},
{'AttributeName': 'job_stage', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
},
{
'IndexName': 'JobStageIndex',
'KeySchema': [
{'AttributeName': 'job_stage', 'KeyType': 'HASH'},
{'AttributeName': 'created_at', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
}
],
}
Expand Down Expand Up @@ -301,7 +329,29 @@ def create_evoc_tables(dynamodb, delete_existing=False):
],
'AttributeDefinitions': [
{'AttributeName': 'conversation_id', 'AttributeType': 'S'},
{'AttributeName': 'comment_id', 'AttributeType': 'N'}
{'AttributeName': 'comment_id', 'AttributeType': 'N'},
{'AttributeName': 'job_id', 'AttributeType': 'S'},
{'AttributeName': 'created_at', 'AttributeType': 'S'}
],
'GlobalSecondaryIndexes': [
{
'IndexName': 'JobIdIndex',
'KeySchema': [
{'AttributeName': 'job_id', 'KeyType': 'HASH'},
{'AttributeName': 'conversation_id', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
},
{
'IndexName': 'ConversationTimeIndex',
'KeySchema': [
{'AttributeName': 'conversation_id', 'KeyType': 'HASH'},
{'AttributeName': 'created_at', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
}
],
'ProvisionedThroughput': {
'ReadCapacityUnits': 5,
Expand All @@ -315,7 +365,29 @@ def create_evoc_tables(dynamodb, delete_existing=False):
],
'AttributeDefinitions': [
{'AttributeName': 'conversation_id', 'AttributeType': 'S'},
{'AttributeName': 'comment_id', 'AttributeType': 'N'}
{'AttributeName': 'comment_id', 'AttributeType': 'N'},
{'AttributeName': 'job_id', 'AttributeType': 'S'},
{'AttributeName': 'created_at', 'AttributeType': 'S'}
],
'GlobalSecondaryIndexes': [
{
'IndexName': 'JobIdIndex',
'KeySchema': [
{'AttributeName': 'job_id', 'KeyType': 'HASH'},
{'AttributeName': 'conversation_id', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
},
{
'IndexName': 'ConversationTimeIndex',
'KeySchema': [
{'AttributeName': 'conversation_id', 'KeyType': 'HASH'},
{'AttributeName': 'created_at', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
}
],
'ProvisionedThroughput': {
'ReadCapacityUnits': 5,
Expand All @@ -329,7 +401,29 @@ def create_evoc_tables(dynamodb, delete_existing=False):
],
'AttributeDefinitions': [
{'AttributeName': 'conversation_id', 'AttributeType': 'S'},
{'AttributeName': 'cluster_key', 'AttributeType': 'S'}
{'AttributeName': 'cluster_key', 'AttributeType': 'S'},
{'AttributeName': 'job_id', 'AttributeType': 'S'},
{'AttributeName': 'created_at', 'AttributeType': 'S'}
],
'GlobalSecondaryIndexes': [
{
'IndexName': 'JobIdIndex',
'KeySchema': [
{'AttributeName': 'job_id', 'KeyType': 'HASH'},
{'AttributeName': 'conversation_id', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
},
{
'IndexName': 'ConversationTimeIndex',
'KeySchema': [
{'AttributeName': 'conversation_id', 'KeyType': 'HASH'},
{'AttributeName': 'created_at', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
}
],
'ProvisionedThroughput': {
'ReadCapacityUnits': 5,
Expand All @@ -343,7 +437,19 @@ def create_evoc_tables(dynamodb, delete_existing=False):
],
'AttributeDefinitions': [
{'AttributeName': 'conversation_id', 'AttributeType': 'S'},
{'AttributeName': 'edge_id', 'AttributeType': 'S'}
{'AttributeName': 'edge_id', 'AttributeType': 'S'},
{'AttributeName': 'job_id', 'AttributeType': 'S'}
],
'GlobalSecondaryIndexes': [
{
'IndexName': 'JobIdIndex',
'KeySchema': [
{'AttributeName': 'job_id', 'KeyType': 'HASH'},
{'AttributeName': 'conversation_id', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
}
],
'ProvisionedThroughput': {
'ReadCapacityUnits': 5,
Expand All @@ -354,12 +460,25 @@ def create_evoc_tables(dynamodb, delete_existing=False):
# Extended tables
'Delphi_CommentClustersFeatures': {
'KeySchema': [
{'AttributeName': 'conversation_id', 'KeyType': 'HASH'},
{'AttributeName': 'cluster_key', 'KeyType': 'RANGE'}
{'AttributeName': 'job_id', 'KeyType': 'HASH'},
{'AttributeName': 'conversation_id_cluster_key', 'KeyType': 'RANGE'}
],
'AttributeDefinitions': [
{'AttributeName': 'job_id', 'AttributeType': 'S'},
{'AttributeName': 'conversation_id_cluster_key', 'AttributeType': 'S'},
{'AttributeName': 'conversation_id', 'AttributeType': 'S'},
{'AttributeName': 'cluster_key', 'AttributeType': 'S'}
{'AttributeName': 'created_at', 'AttributeType': 'S'}
],
'GlobalSecondaryIndexes': [
{
'IndexName': 'ConversationIndex',
'KeySchema': [
{'AttributeName': 'conversation_id', 'KeyType': 'HASH'},
{'AttributeName': 'created_at', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
}
],
'ProvisionedThroughput': {
'ReadCapacityUnits': 5,
Expand All @@ -373,7 +492,29 @@ def create_evoc_tables(dynamodb, delete_existing=False):
],
'AttributeDefinitions': [
{'AttributeName': 'conversation_id', 'AttributeType': 'S'},
{'AttributeName': 'topic_key', 'AttributeType': 'S'}
{'AttributeName': 'topic_key', 'AttributeType': 'S'},
{'AttributeName': 'job_id', 'AttributeType': 'S'},
{'AttributeName': 'created_at', 'AttributeType': 'S'}
],
'GlobalSecondaryIndexes': [
{
'IndexName': 'JobIdIndex',
'KeySchema': [
{'AttributeName': 'job_id', 'KeyType': 'HASH'},
{'AttributeName': 'conversation_id', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
},
{
'IndexName': 'ConversationTimeIndex',
'KeySchema': [
{'AttributeName': 'conversation_id', 'KeyType': 'HASH'},
{'AttributeName': 'created_at', 'KeyType': 'RANGE'}
],
'Projection': {'ProjectionType': 'ALL'},
'ProvisionedThroughput': {'ReadCapacityUnits': 5, 'WriteCapacityUnits': 5}
}
],
'ProvisionedThroughput': {
'ReadCapacityUnits': 5,
Expand Down
Loading
Loading