Skip to content

Commit f3929f5

Browse files
committed
address PR feedback: add/cleanup KDocs, remove unnecessary debug logging, add runtime check for acceptable partition key value types, remove unused function, re-add accidentally-removed trailing comma from codegen
1 parent 7a1d42d commit f3929f5

File tree

7 files changed

+34
-22
lines changed

7 files changed

+34
-22
lines changed

hll/dynamodb-mapper/dynamodb-mapper-ops-codegen/src/main/kotlin/aws/sdk/kotlin/hll/dynamodbmapper/codegen/operations/rendering/OperationRenderer.kt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ internal class OperationRenderer(
9696

9797
openBlock("private fun <T> #T.convert(", operation.request.type)
9898
requestMembers(MemberCodegenBehavior.Hoist) { write("#L: #T, ", name, type) }
99-
write("schema: #T", MapperTypes.Items.itemSchema("T"))
99+
write("schema: #T,", MapperTypes.Items.itemSchema("T"))
100100
closeAndOpenBlock(") = #L {", operation.request.lowLevelName)
101101
requestMembers(MemberCodegenBehavior.PassThrough) { write("#L = this@convert.#L", name, highLevel.name) }
102102
requestMembers(MemberCodegenBehavior.MapKeys) {
@@ -200,14 +200,5 @@ private inline operator fun Map<MemberCodegenBehavior, List<Member>>.invoke(
200200
}
201201
}
202202

203-
private inline operator fun Map<MemberCodegenBehavior, List<Member>>.invoke(
204-
predicate: (MemberCodegenBehavior) -> Boolean,
205-
block: Member.() -> Unit,
206-
) {
207-
entries.forEach { (behavior, members) ->
208-
if (predicate(behavior)) members.forEach(block)
209-
}
210-
}
211-
212203
private val Structure.lowLevelName: String
213204
get() = "LowLevel${type.shortName}"

hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Expressions.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ public sealed interface Expression {
2929
*/
3030
public sealed interface BooleanExpr : Expression
3131

32+
/**
33+
* A subtype of [Expression] that represents a key condition on a sort key, such as would be used for specifying a Query
34+
* key. This is a [marker interface](https://en.wikipedia.org/wiki/Marker_interface_pattern) which adds no additional
35+
* declarations.
36+
*/
3237
public sealed interface SortKeyExpr : Expression

hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/Filter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public interface Filter {
661661
public fun AttributePath.isBetween(min: Expression, max: Expression): BooleanExpr
662662

663663
/**
664-
* Creates a range expression for verifying the sort key is between two other expressions
664+
* Creates a range expression for verifying this expression is between two other expressions
665665
* @param min The lower bound value
666666
* @param max The upper bound value (inclusive)
667667
*/

hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/SortKeyFilter.kt

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface SortKey
2020
* { sortKey eq 42 }
2121
* ```
2222
*
23-
* This example creates an expression which checks whether an attribute named `foo` is equal to the value `42`.
23+
* This example creates an expression which checks whether the sort key is equal to the value `42`.
2424
*
2525
* ## (Non-)Relationship to schema
2626
*
@@ -34,12 +34,12 @@ public interface SortKey
3434
*
3535
* A very common filter condition is verifying whether the value of the sort key is equal (or unequal) to another a
3636
* literal value. These comparisons are available by using the following functions:
37-
* * [eq] — checks if two values are equal (equivalent to Kotlin's `==` operator)
38-
* * [neq] — checks if two values are _not_ equal (equivalent to Kotlin's `!=` operator)
39-
* * [lt] — checks if a value is less than another value (equivalent to Kotlin's `<` operator)
40-
* * [lte] — checks if a value is less than _or equal to_ another value (equivalent to Kotlin's `<=` operator)
41-
* * [gt] — checks if a value is greater than another value (equivalent to Kotlin's `>` operator)
42-
* * [gte] — checks if a value is greater than _or equal to_ another value (equivalent to Kotlin's `>=` operator)
37+
* * [eq] — checks if the sort key is equal to another value (equivalent to Kotlin's `==` operator)
38+
* * [neq] — checks if two the sort key is _not_ equal to another value (equivalent to Kotlin's `!=` operator)
39+
* * [lt] — checks if the sort key is less than another value (equivalent to Kotlin's `<` operator)
40+
* * [lte] — checks if the sort key is less than _or equal to_ another value (equivalent to Kotlin's `<=` operator)
41+
* * [gt] — checks if the sort key is greater than another value (equivalent to Kotlin's `>` operator)
42+
* * [gte] — checks if the sort key is greater than _or equal to_ another value (equivalent to Kotlin's `>=` operator)
4343
*
4444
* For example:
4545
*
@@ -56,11 +56,16 @@ public interface SortKey
5656
* ```kotlin
5757
* // Checks whether the value of the sort key is between 40 and 60 (inclusive)
5858
* sortKey isIn 40..60
59+
*
60+
* // Checks whether the value of the sort key is between two binary values (inclusive)
61+
* val minBinary: ByteArray = ...
62+
* val maxBinary: ByteArray = ...
63+
* sortKey.isBetween(minBinary, maxBinary)
5964
* ```
6065
*
6166
* # Prefixes
6267
*
63-
* The [startsWith] function enables expressing a prefix for the value of the sort key. For example:
68+
* The [startsWith] function checks for a prefix in the value of the sort key. For example:
6469
*
6570
* ```kotlin
6671
* sortKey startsWith "abc" // Checks whether the value of the sort key starts with `"abc"`

hll/dynamodb-mapper/dynamodb-mapper/common/src/aws/sdk/kotlin/hll/dynamodbmapper/expressions/internal/KeyFilterImpl.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ import aws.sdk.kotlin.hll.dynamodbmapper.items.ItemSchema
99
import aws.sdk.kotlin.hll.dynamodbmapper.util.dynamicAttr
1010
import aws.sdk.kotlin.hll.dynamodbmapper.util.requireNull
1111

12-
internal data class KeyFilterImpl(override val partitionKey: Any, override val sortKey: SortKeyExpr?) : KeyFilter
12+
internal data class KeyFilterImpl(override val partitionKey: Any, override val sortKey: SortKeyExpr?) : KeyFilter {
13+
init {
14+
require(
15+
partitionKey is ByteArray ||
16+
partitionKey is Number ||
17+
partitionKey is String ||
18+
partitionKey is UByte ||
19+
partitionKey is UInt ||
20+
partitionKey is ULong ||
21+
partitionKey is UShort,
22+
) { "Partition key values must be either a ByteArray, Number, String, or an unsigned number type" }
23+
}
24+
}
1325

1426
internal fun KeyFilter.toExpression(schema: ItemSchema<*>) = when (schema) {
1527
is ItemSchema.CompositeKey<*, *, *> -> {

hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/model/Member.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public data class Member(
4242
}
4343

4444
/**
45-
* Gets the low-level [Structure] equivalent for this high-level structure
45+
* Gets the low-level [Member] equivalent for this high-level member
4646
*/
4747
@InternalSdkApi
4848
public val Member.lowLevel: Member

hll/hll-codegen/src/main/kotlin/aws/sdk/kotlin/hll/codegen/rendering/BuilderRenderer.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ public class BuilderRenderer(
6868

6969
write("#Lvar #L: #T = null", ctx.attributes.visibility, member.name, member.type.nullable())
7070

71-
ctx.info("For member $builderName.${member.name} dslInfo = $dslInfo")
7271
if (dslInfo != null) {
7372
blankLine()
7473
withBlock(

0 commit comments

Comments
 (0)