-
Notifications
You must be signed in to change notification settings - Fork 205
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
[DataApi] Get BlobCount By AccountID #541
Changes from 8 commits
0562b5a
8e6c7d0
e655eb2
badbd96
6efc495
6f33481
99c05b0
bde7ab2
21440ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"time" | ||
|
||
commondynamodb "github.com/Layr-Labs/eigenda/common/aws/dynamodb" | ||
"github.com/Layr-Labs/eigenda/core" | ||
"github.com/Layr-Labs/eigenda/disperser" | ||
"github.com/Layr-Labs/eigensdk-go/logging" | ||
"github.com/aws/aws-sdk-go-v2/aws" | ||
|
@@ -16,8 +17,9 @@ import ( | |
) | ||
|
||
const ( | ||
statusIndexName = "StatusIndex" | ||
batchIndexName = "BatchIndex" | ||
statusIndexName = "StatusIndex" | ||
batchIndexName = "BatchIndex" | ||
accountIdIndexName = "AccountIdIndex" | ||
) | ||
|
||
// BlobMetadataStore is a blob metadata storage backed by DynamoDB | ||
|
@@ -218,6 +220,21 @@ func (s *BlobMetadataStore) GetBlobMetadataInBatch(ctx context.Context, batchHea | |
return metadata, nil | ||
} | ||
|
||
// GetBlobMetadataByAccount Count returns the count of all the metadata with the given status | ||
// Because this function scans the entire index, it should only be used for status with a limited number of items. | ||
// It should only be used to filter "Processing" status. To support other status, a streaming version should be implemented. | ||
func (s *BlobMetadataStore) GetBlobMetadataCountByAccountID(ctx context.Context, accountID core.AccountID) (int32, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably want the total amount of data rather than the total number of blobs. Or perhaps both. Let's do another sync on the exact use case for this work! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mooselumph i think if we want total amount of data everytime than better approach is to have a lambda invoke on DynamodB stream.....which only processes INSERT_EVENT and can be used to update:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for now temporarily i will just update Batcher to update amount of data after Blob is confirmed and increment count |
||
count, err := s.dynamoDBClient.QueryIndexCount(ctx, s.tableName, accountIdIndexName, "AccountID = :accountID", commondynamodb.ExpresseionValues{ | ||
":accountID": &types.AttributeValueMemberS{ | ||
Value: accountID, | ||
}}) | ||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
return count, nil | ||
} | ||
|
||
func (s *BlobMetadataStore) IncrementNumRetries(ctx context.Context, existingMetadata *disperser.BlobMetadata) error { | ||
_, err := s.dynamoDBClient.UpdateItem(ctx, s.tableName, map[string]types.AttributeValue{ | ||
"BlobHash": &types.AttributeValueMemberS{ | ||
|
@@ -297,6 +314,10 @@ func GenerateTableSchema(metadataTableName string, readCapacityUnits int64, writ | |
AttributeName: aws.String("BlobIndex"), | ||
AttributeType: types.ScalarAttributeTypeN, | ||
}, | ||
{ | ||
AttributeName: aws.String("AccountID"), | ||
AttributeType: types.ScalarAttributeTypeS, | ||
}, | ||
}, | ||
KeySchema: []types.KeySchemaElement{ | ||
{ | ||
|
@@ -350,6 +371,26 @@ func GenerateTableSchema(metadataTableName string, readCapacityUnits int64, writ | |
WriteCapacityUnits: aws.Int64(writeCapacityUnits), | ||
}, | ||
}, | ||
{ | ||
IndexName: aws.String(accountIdIndexName), | ||
KeySchema: []types.KeySchemaElement{ | ||
{ | ||
AttributeName: aws.String("AccountID"), | ||
KeyType: types.KeyTypeHash, | ||
}, | ||
{ | ||
AttributeName: aws.String("RequestedAt"), | ||
KeyType: types.KeyTypeRange, | ||
}, | ||
}, | ||
Projection: &types.Projection{ | ||
ProjectionType: types.ProjectionTypeAll, | ||
}, | ||
ProvisionedThroughput: &types.ProvisionedThroughput{ | ||
ReadCapacityUnits: aws.Int64(readCapacityUnits), | ||
WriteCapacityUnits: aws.Int64(writeCapacityUnits), | ||
}, | ||
}, | ||
}, | ||
ProvisionedThroughput: &types.ProvisionedThroughput{ | ||
ReadCapacityUnits: aws.Int64(readCapacityUnits), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might need to change depending on if the authenticated endpoint is being used right ?