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

fix: ExpresseionValues -> ExpressionValues typo #796

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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
10 changes: 5 additions & 5 deletions common/aws/dynamodb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var (

type Item = map[string]types.AttributeValue
type Key = map[string]types.AttributeValue
type ExpresseionValues = map[string]types.AttributeValue
type ExpressionValues = map[string]types.AttributeValue

type QueryResult struct {
Items []Item
Expand Down Expand Up @@ -177,7 +177,7 @@ func (c *Client) GetItems(ctx context.Context, tableName string, keys []Key) ([]
}

// QueryIndex returns all items in the index that match the given key
func (c *Client) QueryIndex(ctx context.Context, tableName string, indexName string, keyCondition string, expAttributeValues ExpresseionValues) ([]Item, error) {
func (c *Client) QueryIndex(ctx context.Context, tableName string, indexName string, keyCondition string, expAttributeValues ExpressionValues) ([]Item, error) {
response, err := c.dynamoClient.Query(ctx, &dynamodb.QueryInput{
TableName: aws.String(tableName),
IndexName: aws.String(indexName),
Expand All @@ -192,7 +192,7 @@ func (c *Client) QueryIndex(ctx context.Context, tableName string, indexName str
}

// Query returns all items in the primary index that match the given expression
func (c *Client) Query(ctx context.Context, tableName string, keyCondition string, expAttributeValues ExpresseionValues) ([]Item, error) {
func (c *Client) Query(ctx context.Context, tableName string, keyCondition string, expAttributeValues ExpressionValues) ([]Item, error) {
response, err := c.dynamoClient.Query(ctx, &dynamodb.QueryInput{
TableName: aws.String(tableName),
KeyConditionExpression: aws.String(keyCondition),
Expand All @@ -206,7 +206,7 @@ func (c *Client) Query(ctx context.Context, tableName string, keyCondition strin
}

// QueryIndexCount returns the count of the items in the index that match the given key
func (c *Client) QueryIndexCount(ctx context.Context, tableName string, indexName string, keyCondition string, expAttributeValues ExpresseionValues) (int32, error) {
func (c *Client) QueryIndexCount(ctx context.Context, tableName string, indexName string, keyCondition string, expAttributeValues ExpressionValues) (int32, error) {
response, err := c.dynamoClient.Query(ctx, &dynamodb.QueryInput{
TableName: aws.String(tableName),
IndexName: aws.String(indexName),
Expand All @@ -224,7 +224,7 @@ func (c *Client) QueryIndexCount(ctx context.Context, tableName string, indexNam
// QueryIndexWithPagination returns all items in the index that match the given key
// Results are limited to the given limit and the pagination token is returned
// When limit is 0, all items are returned
func (c *Client) QueryIndexWithPagination(ctx context.Context, tableName string, indexName string, keyCondition string, expAttributeValues ExpresseionValues, limit int32, exclusiveStartKey map[string]types.AttributeValue) (QueryResult, error) {
func (c *Client) QueryIndexWithPagination(ctx context.Context, tableName string, indexName string, keyCondition string, expAttributeValues ExpressionValues, limit int32, exclusiveStartKey map[string]types.AttributeValue) (QueryResult, error) {
var queryInput *dynamodb.QueryInput

// Fetch all items if limit is 0
Expand Down
32 changes: 16 additions & 16 deletions common/aws/dynamodb/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func TestQueryIndex(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, unprocessed, 0)

queryResult, err := dynamoClient.QueryIndex(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err := dynamoClient.QueryIndex(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}})
Expand Down Expand Up @@ -356,14 +356,14 @@ func TestQueryIndexCount(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, unprocessed, 0)

count, err := dynamoClient.QueryIndexCount(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
count, err := dynamoClient.QueryIndexCount(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}})
assert.NoError(t, err)
assert.Equal(t, int(count), 10)

count, err = dynamoClient.QueryIndexCount(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
count, err = dynamoClient.QueryIndexCount(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "1",
}})
Expand All @@ -388,7 +388,7 @@ func TestQueryIndexPaginationSingleItem(t *testing.T) {
err := dynamoClient.PutItem(ctx, tableName, item)
assert.NoError(t, err)

queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 1, nil)
Expand All @@ -403,7 +403,7 @@ func TestQueryIndexPaginationSingleItem(t *testing.T) {
lastEvaluatedKey := queryResult.LastEvaluatedKey

// Get the next item using LastEvaluatedKey expect to be nil
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 1, lastEvaluatedKey)
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestQueryIndexPaginationItemNoLimit(t *testing.T) {
assert.NoError(t, err)
}

queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 0, nil)
Expand All @@ -447,7 +447,7 @@ func TestQueryIndexPaginationItemNoLimit(t *testing.T) {
lastEvaluatedKey := queryResult.LastEvaluatedKey

// Get the next item using LastEvaluatedKey expect to be nil
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 2, lastEvaluatedKey)
Expand All @@ -463,7 +463,7 @@ func TestQueryIndexPaginationNoStoredItems(t *testing.T) {
indexName := "StatusIndex"

ctx := context.Background()
queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 1, nil)
Expand Down Expand Up @@ -503,7 +503,7 @@ func TestQueryIndexPagination(t *testing.T) {
assert.NoError(t, err)
}

queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, nil)
Expand All @@ -515,7 +515,7 @@ func TestQueryIndexPagination(t *testing.T) {
assert.Equal(t, "0", queryResult.LastEvaluatedKey["BlobStatus"].(*types.AttributeValueMemberN).Value)

// Get the next 10 items
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, queryResult.LastEvaluatedKey)
Expand All @@ -524,7 +524,7 @@ func TestQueryIndexPagination(t *testing.T) {
assert.Equal(t, "key10", queryResult.LastEvaluatedKey["MetadataKey"].(*types.AttributeValueMemberS).Value)

// Get the last 10 items
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, queryResult.LastEvaluatedKey)
Expand All @@ -533,7 +533,7 @@ func TestQueryIndexPagination(t *testing.T) {
assert.Equal(t, "key0", queryResult.LastEvaluatedKey["MetadataKey"].(*types.AttributeValueMemberS).Value)

// Empty result Since all items are processed
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, queryResult.LastEvaluatedKey)
Expand Down Expand Up @@ -564,31 +564,31 @@ func TestQueryIndexWithPaginationForBatch(t *testing.T) {
assert.Len(t, unprocessed, 0)

// Get First 10 items
queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err := dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, nil)
assert.NoError(t, err)
assert.Len(t, queryResult.Items, 10)

// Get the next 10 items
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, queryResult.LastEvaluatedKey)
assert.NoError(t, err)
assert.Len(t, queryResult.Items, 10)

// Get the last 10 items
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, queryResult.LastEvaluatedKey)
assert.NoError(t, err)
assert.Len(t, queryResult.Items, 10)

// Empty result Since all items are processed
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpresseionValues{
queryResult, err = dynamoClient.QueryIndexWithPagination(ctx, tableName, indexName, "BlobStatus = :status", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: "0",
}}, 10, queryResult.LastEvaluatedKey)
Expand Down
12 changes: 6 additions & 6 deletions disperser/common/blobstore/blob_metadata_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (s *BlobMetadataStore) GetBulkBlobMetadata(ctx context.Context, blobKeys []
// 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) GetBlobMetadataByStatus(ctx context.Context, status disperser.BlobStatus) ([]*disperser.BlobMetadata, error) {
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, expiryIndexName, "BlobStatus = :status AND Expiry > :expiry", commondynamodb.ExpresseionValues{
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, expiryIndexName, "BlobStatus = :status AND Expiry > :expiry", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: strconv.Itoa(int(status)),
},
Expand All @@ -148,7 +148,7 @@ func (s *BlobMetadataStore) GetBlobMetadataByStatus(ctx context.Context, 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) GetBlobMetadataCountByStatus(ctx context.Context, status disperser.BlobStatus) (int32, error) {
count, err := s.dynamoDBClient.QueryIndexCount(ctx, s.tableName, expiryIndexName, "BlobStatus = :status AND Expiry > :expiry", commondynamodb.ExpresseionValues{
count, err := s.dynamoDBClient.QueryIndexCount(ctx, s.tableName, expiryIndexName, "BlobStatus = :status AND Expiry > :expiry", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: strconv.Itoa(int(status)),
},
Expand Down Expand Up @@ -181,7 +181,7 @@ func (s *BlobMetadataStore) GetBlobMetadataByStatusWithPagination(ctx context.Co
}
}

queryResult, err := s.dynamoDBClient.QueryIndexWithPagination(ctx, s.tableName, expiryIndexName, "BlobStatus = :status AND Expiry > :expiry", commondynamodb.ExpresseionValues{
queryResult, err := s.dynamoDBClient.QueryIndexWithPagination(ctx, s.tableName, expiryIndexName, "BlobStatus = :status AND Expiry > :expiry", commondynamodb.ExpressionValues{
":status": &types.AttributeValueMemberN{
Value: strconv.Itoa(int(status)),
},
Expand Down Expand Up @@ -221,7 +221,7 @@ func (s *BlobMetadataStore) GetBlobMetadataByStatusWithPagination(ctx context.Co
}

func (s *BlobMetadataStore) GetAllBlobMetadataByBatch(ctx context.Context, batchHeaderHash [32]byte) ([]*disperser.BlobMetadata, error) {
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, batchIndexName, "BatchHeaderHash = :batch_header_hash", commondynamodb.ExpresseionValues{
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, batchIndexName, "BatchHeaderHash = :batch_header_hash", commondynamodb.ExpressionValues{
":batch_header_hash": &types.AttributeValueMemberB{
Value: batchHeaderHash[:],
},
Expand Down Expand Up @@ -272,7 +272,7 @@ func (s *BlobMetadataStore) GetAllBlobMetadataByBatchWithPagination(
s.tableName,
batchIndexName,
"BatchHeaderHash = :batch_header_hash",
commondynamodb.ExpresseionValues{
commondynamodb.ExpressionValues{
":batch_header_hash": &types.AttributeValueMemberB{
Value: batchHeaderHash[:],
},
Expand Down Expand Up @@ -312,7 +312,7 @@ func (s *BlobMetadataStore) GetAllBlobMetadataByBatchWithPagination(
}

func (s *BlobMetadataStore) GetBlobMetadataInBatch(ctx context.Context, batchHeaderHash [32]byte, blobIndex uint32) (*disperser.BlobMetadata, error) {
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, batchIndexName, "BatchHeaderHash = :batch_header_hash AND BlobIndex = :blob_index", commondynamodb.ExpresseionValues{
items, err := s.dynamoDBClient.QueryIndex(ctx, s.tableName, batchIndexName, "BatchHeaderHash = :batch_header_hash AND BlobIndex = :blob_index", commondynamodb.ExpressionValues{
":batch_header_hash": &types.AttributeValueMemberB{
Value: batchHeaderHash[:],
},
Expand Down
Loading