-
Notifications
You must be signed in to change notification settings - Fork 870
Create separate operation-specific configs for the object-mapper Scan and Query operations #3383
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
Merged
ashovlin
merged 3 commits into
feature/v4-ddb-separate-config
from
shovlia/v4-ddb-separate-queryscan
Jul 30, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
104 changes: 104 additions & 0 deletions
104
sdk/src/Services/DynamoDBv2/Custom/DataModel/QueryConfig.cs
This file contains hidden or 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,104 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using Amazon.DynamoDBv2.DocumentModel; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.DynamoDBv2.DataModel | ||
{ | ||
/// <summary> | ||
/// Input for the Query operation in the object-persistence programming model | ||
/// </summary> | ||
#if NET8_0_OR_GREATER | ||
// The DataModel namespace doesn't support trimming yet, so annotate public classes/methods as incompatible | ||
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode(Custom.Internal.InternalConstants.RequiresUnreferencedCodeMessage)] | ||
#endif | ||
public class QueryConfig : BaseOperationConfig | ||
{ | ||
/// <summary> | ||
/// Indicates whether a query should traverse the index backwards in descending order by range key value. | ||
/// If the property is false (or not set), traversal shall be in ascending order. | ||
/// </summary> | ||
public bool? BackwardQuery { get; set; } | ||
|
||
/// <summary> | ||
/// Indicates the name of the index to query against. | ||
/// This value is optional if the index name can be inferred from the call. | ||
/// </summary> | ||
public string IndexName { get; set; } | ||
|
||
/// <summary> | ||
/// The logical operator to apply to the filter conditions. | ||
/// </summary> | ||
/// <remarks> | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term><see cref="ConditionalOperatorValues.And" /></term> | ||
/// <definition>If all of the conditions evaluate to true, then the entire filter evaluates to true.</definition> | ||
/// </item> | ||
/// <item> | ||
/// <term><see cref="ConditionalOperatorValues.Or" /></term> | ||
/// <definition>If at least one of the conditions evaluate to true, then the entire filter evaluates to true.</definition> | ||
/// </item> | ||
/// </list> | ||
/// The default value is <see cref="ConditionalOperatorValues.And" />. | ||
/// </remarks> | ||
public ConditionalOperatorValues ConditionalOperator { get; set; } | ||
|
||
/// <summary> | ||
/// Query filter for the Query operation. Evaluates the query results and returns only | ||
/// the matching values. If you specify more than one condition, then by default all of the | ||
/// conditions must evaluate to true. To match only some conditions, set <see cref="ConditionalOperator"/> to <see cref="ConditionalOperatorValues.Or" />. | ||
/// </summary> | ||
/// <remarks> | ||
/// Note: Conditions must be against non-key properties. | ||
/// </remarks> | ||
public List<ScanCondition> QueryFilter { get; set; } | ||
|
||
/// <summary> | ||
/// Property that directs <see cref="DynamoDBContext" /> to use consistent reads. | ||
/// If property is not set, behavior defaults to non-consistent reads. | ||
/// </summary> | ||
/// <remarks> | ||
/// Refer to the <see href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html"> | ||
/// Read Consistency</see> topic in the DynamoDB Developer Guide for more information. | ||
/// </remarks> | ||
public bool? ConsistentRead { get; set; } | ||
|
||
/// <summary> | ||
/// If true, all <see cref="DateTime"/> properties are retrieved in UTC timezone while reading data from DynamoDB. Else, the local timezone is used. | ||
/// </summary> | ||
/// <remarks> | ||
/// This setting is only applicable to the high-level library. Service calls made via | ||
/// <see cref="AmazonDynamoDBClient"/> will always return <see cref="DateTime"/> attributes in UTC. | ||
/// </remarks> | ||
public bool? RetrieveDateTimeInUtc { get; set; } | ||
|
||
/// <inheritdoc/> | ||
internal override DynamoDBOperationConfig ToDynamoDBOperationConfig() | ||
{ | ||
var config = base.ToDynamoDBOperationConfig(); | ||
config.BackwardQuery = BackwardQuery; | ||
config.IndexName = IndexName; | ||
config.ConditionalOperator = ConditionalOperator; | ||
config.QueryFilter = QueryFilter; | ||
config.ConsistentRead = ConsistentRead; | ||
config.RetrieveDateTimeInUtc = RetrieveDateTimeInUtc; | ||
|
||
return config; | ||
} | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
sdk/src/Services/DynamoDBv2/Custom/DataModel/ScanConfig.cs
This file contains hidden or 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,97 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
using Amazon.DynamoDBv2.DocumentModel; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.DynamoDBv2.DataModel | ||
{ | ||
/// <summary> | ||
/// Input for the Scan operation in the object-persistence programming model | ||
/// </summary> | ||
#if NET8_0_OR_GREATER | ||
// The DataModel namespace doesn't support trimming yet, so annotate public classes/methods as incompatible | ||
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode(Custom.Internal.InternalConstants.RequiresUnreferencedCodeMessage)] | ||
#endif | ||
public class ScanConfig : BaseOperationConfig | ||
{ | ||
/// <summary> | ||
/// Indicates the name of the index to scan against. | ||
/// This value is optional if the index name can be inferred from the call. | ||
/// </summary> | ||
public string IndexName { get; set; } | ||
|
||
/// <summary> | ||
/// The logical operator to apply to the filter conditions. | ||
/// </summary> | ||
/// <remarks> | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term><see cref="ConditionalOperatorValues.And" /></term> | ||
/// <definition>If all of the conditions evaluate to true, then the entire filter evaluates to true.</definition> | ||
/// </item> | ||
/// <item> | ||
/// <term><see cref="ConditionalOperatorValues.Or" /></term> | ||
/// <definition>If at least one of the conditions evaluate to true, then the entire filter evaluates to true.</definition> | ||
/// </item> | ||
/// </list> | ||
/// The default value is <see cref="ConditionalOperatorValues.And" />. | ||
/// </remarks> | ||
public ConditionalOperatorValues ConditionalOperator { get; set; } | ||
|
||
/// <summary> | ||
/// Filter for the Scan operation. Evaluates the query results and returns only | ||
/// the matching values. If you specify more than one condition, then by default all of the | ||
/// conditions must evaluate to true. To match only some conditions, set <see cref="ConditionalOperator"/> to <see cref="ConditionalOperatorValues.Or" />. | ||
/// </summary> | ||
/// <remarks> | ||
/// Note: Conditions must be against non-key properties. | ||
/// </remarks> | ||
public List<ScanCondition> QueryFilter { get; set; } | ||
|
||
/// <summary> | ||
/// Property that directs <see cref="DynamoDBContext" /> to use consistent reads. | ||
/// If property is not set, behavior defaults to non-consistent reads. | ||
/// </summary> | ||
/// <remarks> | ||
/// Refer to the <see href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html"> | ||
/// Read Consistency</see> topic in the DynamoDB Developer Guide for more information. | ||
/// </remarks> | ||
public bool? ConsistentRead { get; set; } | ||
96malhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// <summary> | ||
/// If true, all <see cref="DateTime"/> properties are retrieved in UTC timezone while reading data from DynamoDB. Else, the local timezone is used. | ||
/// </summary> | ||
/// <remarks> | ||
/// This setting is only applicable to the high-level library. Service calls made via | ||
/// <see cref="AmazonDynamoDBClient"/> will always return <see cref="DateTime"/> attributes in UTC. | ||
/// </remarks> | ||
public bool? RetrieveDateTimeInUtc { get; set; } | ||
|
||
/// <inheritdoc/> | ||
internal override DynamoDBOperationConfig ToDynamoDBOperationConfig() | ||
{ | ||
var config = base.ToDynamoDBOperationConfig(); | ||
config.IndexName = IndexName; | ||
config.ConditionalOperator = ConditionalOperator; | ||
config.QueryFilter = QueryFilter; | ||
config.ConsistentRead = ConsistentRead; | ||
config.RetrieveDateTimeInUtc = RetrieveDateTimeInUtc; | ||
|
||
return config; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.