@@ -80,109 +80,66 @@ values used are also completely arbitrary.
80
80
81
81
### Common primitive operations
82
82
These all strongly map to the primitive DynamoDB operations they are
83
- named after. The examples below are the most simple variants of each
84
- operation possible, using the the two styles available for constructing
85
- requests with either builder or consumers. These commands can be
86
- customized by using the builders provided for each command and offer
87
- most of the features available in the low- level DynamoDB SDK client.
83
+ named after. These examples are the most simple variants of each
84
+ operation possible. These commands can be customized by using the
85
+ builders provided for each command and offer most of the features
86
+ available in the low- level DynamoDB SDK client.
88
87
89
88
```java
90
89
// CreateTable
91
- customerTable. createTable();
92
- customerTable. createTable(CreateTableEnhancedRequest . builder(). build());
90
+ customerTable. createTable(CreateTableEnhancedRequest . create());
93
91
94
92
// GetItem
95
- Customer customer = customerTable. getItem(r - > r. key(Key . create(stringValue(" a123" ))));
96
- Customer customer = customerTable. getItem(GetItemEnhancedRequest . builder()
97
- .key(Key . create(stringValue(" a123" )))
98
- .build());
93
+ Customer customer = customerTable. getItem(GetItemEnhancedRequest . create(Key . create(stringValue(" a123" ))));
94
+
99
95
// UpdateItem
100
- Customer updatedCustomer = customerTable. updateItem(Customer . class, r - > r. item(customer));
101
- Customer updatedCustomer = customerTable. updateItem(UpdateItemEnhancedRequest . builder(Customer . class)
102
- .item(customer)
103
- .build());
96
+ Customer updatedCustomer = customerTable. updateItem(UpdateItemEnhancedRequest . create(customer));
104
97
105
98
// PutItem
106
- customerTable. putItem(Customer . class, r - > r. item(customer));
107
- customerTable. putItem(PutItemEnhancedRequest . builder(Customer . class)
108
- .item(customer)
109
- .build());
99
+ customerTable. putItem(PutItemEnhancedRequest . create(customer));
110
100
111
101
// DeleteItem
112
- Customer deletedCustomer = customerTable. deleteItem(r - > r. key(Key . create(stringValue(" a123" ), numberValue(456 ))));
113
- Customer deletedCustomer = customerTable. deleteItem(DeleteItemEnhancedRequest . builder()
114
- .key(Key . create(stringValue(" a123" ), numberValue(456 )))
115
- .build());
102
+ Customer deletedCustomer = customerTable. deleteItem(DeleteItemEnhancedRequest . create(Key . create(stringValue(" a123" ), numberValue(456 ))));
116
103
117
104
// Query
118
- Iterable<Page<Customer > > customers = customerTable. query(r - > r. queryConditional(equalTo(Key . create(stringValue(" a123" )))));
119
- Iterable<Page<Customer > > customers = customerTable. query(QueryEnhancedRequest . builder()
120
- .queryConditional(equalTo(Key . create(stringValue(" a123" ))))
121
- .build());
105
+ Iterable<Page<Customer > > customers = customerTable. query(QueryEnhancedRequest . create(equalTo(Key . create(stringValue(" a123" )))));
106
+
122
107
// Scan
123
- Iterable<Page<Customer > > customers = customerTable. scan();
124
- Iterable<Page<Customer > > customers = customerTable. scan(ScanEnhancedRequest . builder(). build());
108
+ Iterable<Page<Customer > > customers = customerTable. scan(ScanEnhancedRequest . create());
125
109
126
110
// BatchGetItem
127
- batchResults = enhancedClient. batchGetItem(r - > r. addReadBatch(ReadBatch . builder(Customer . class)
128
- .mappedTableResource(customerTable)
129
- .addGetItem(i - > i. key(key1))
130
- .addGetItem(i - > i. key(key2))
131
- .addGetItem(i - > i. key(key3))
132
- .build()));
133
111
batchResults = enhancedClient. batchGetItem(
134
- BatchGetItemEnhancedRequest . builder()
135
- .readBatches(ReadBatch . builder(Customer . class)
136
- .mappedTableResource(customerTable)
137
- .addGetItem(GetItemEnhancedRequest . builder(). key(key1). build())
138
- .addGetItem(GetItemEnhancedRequest . builder(). key(key2). build())
139
- .addGetItem(GetItemEnhancedRequest . builder(). key(key3). build())
140
- .build())
112
+ BatchGetItemEnhancedRequest . builder(). addReadBatch(ReadBatch . builder(Customer . class)
113
+ .mappedTableResource(customerTable)
114
+ .addGetItem(GetItemEnhancedRequest . create(key1))
115
+ .addGetItem(GetItemEnhancedRequest . create(key2))
116
+ .addGetItem(GetItemEnhancedRequest . create(key3))
117
+ .build())
141
118
.build());
142
119
143
120
// BatchWriteItem
144
- batchResults = enhancedClient. batchWriteItem(r - > r. addWriteBatch(WriteBatch . builder(Customer . class)
145
- .mappedTableResource(customerTable)
146
- .addPutItem(i - > i. item(customer))
147
- .addDeleteItem(i - > i. key(key1))
148
- .addDeleteItem(i - > i. key(key1))
149
- .build()));
150
121
batchResults = enhancedClient. batchWriteItem(
151
- BatchWriteItemEnhancedRequest . builder()
152
- .addWriteBatch(WriteBatch . builder(Customer . class)
153
- .mappedTableResource(customerTable)
154
- .addPutItem(PutItemEnhancedRequest . builder(Customer . class). item(customer). build())
155
- .addDeleteItem(DeleteItemEnhancedRequest . builder(). key(key1). build())
156
- .addDeleteItem(DeleteItemEnhancedRequest . builder(). key(key2). build())
157
- .build())
122
+ BatchWriteItemEnhancedRequest . builder(). addWriteBatch(WriteBatch . builder(Customer . class)
123
+ .mappedTableResource(customerTable)
124
+ .putItem(PutItemEnhancedRequest . create(item))
125
+ .deleteItem(DeleteItemEnhancedRequest . create(key1))
126
+ .deleteItem(DeleteItemEnhancedRequest . create(key2))
127
+ .build())
158
128
.build());
159
129
160
130
// TransactGetItems
161
- transactResults = enhancedClient. transactGetItems(r - > r. addGetItem(customerTable, r - > r. key(Key . create(key1)))
162
- .addGetItem(customerTable, r - > r. key(Key . create(key2))));
163
131
transactResults = enhancedClient. transactGetItems(
164
132
TransactGetItemsEnhancedRequest . builder()
165
- .addGetItem(customerTable, GetItemEnhancedRequest . builder() . key( Key . create(key1)) . build( ))
166
- .addGetItem(customerTable, GetItemEnhancedRequest . builder() . key( Key . create(key2)) . build( ))
133
+ .addGetItem(customerTable, GetItemEnhancedRequest . create( Key . create(key1)))
134
+ .addGetItem(customerTable, GetItemEnhancedRequest . create( Key . create(key2)))
167
135
.build());
168
136
169
137
// TransactWriteItems
170
- enhancedClient. transactWriteItems(r - > r. addConditionCheck(customerTable, i - > i. key(orderKey). conditionExpression(conditionExpression))
171
- .addUpdateItem(customerTable, Customer . class, i - > i. item(customer))
172
- .addDeleteItem(customerTable, i - > i. key(key)));
173
-
174
138
enhancedClient. transactWriteItems(
175
139
TransactWriteItemsEnhancedRequest . builder()
176
- .addConditionCheck(customerTable, ConditionCheck . builder()
177
- .key(orderKey)
178
- .conditionExpression(conditionExpression)
179
- .build())
180
- .addUpdateItem(customerTable, UpdateItemEnhancedRequest . builder(Customer . class)
181
- .item(customer)
182
- .build())
183
- .addDeleteItem(customerTable, DeleteItemEnhancedRequest . builder()
184
- .key(key)
185
- .build())
140
+ .addConditionCheck(customerTable, ConditionCheck . create(orderKey, conditionExpression))
141
+ .addUpdateItem(customerTable, UpdateItemEnhancedRequest . create(customer))
142
+ .addDeleteItem(customerTable, DeleteItemEnhancedRequest . create(key))
186
143
.build());
187
144
```
188
145
@@ -192,7 +149,7 @@ index. Here's an example of how to do this:
192
149
```
193
150
DynamoDbIndex<Customer> customersByName = customerTable.index("customers_by_name");
194
151
195
- Iterable<Page<Customer>> customersWithName = customersByName.query(r -> r.queryConditional (equalTo(Key.create(stringValue("Smith")))));
152
+ Iterable<Page<Customer>> customersWithName = customersByName.query(QueryEnhancedRequest.create (equalTo(Key.create(stringValue("Smith")))));
196
153
```
197
154
198
155
### Non-blocking asynchronous operations
@@ -215,7 +172,7 @@ key differences:
215
172
application can then do other work without having to block on the
216
173
result:
217
174
```java
218
- CompletableFuture<Customer > result = mappedTable. getItem(r - > r . key (customerKey));
175
+ CompletableFuture<Customer > result = mappedTable. getItem(GetItemEnhancedRequest . create (customerKey));
219
176
// Perform other work here
220
177
return result. join(); // now block and wait for the result
221
178
```
@@ -225,7 +182,7 @@ key differences:
225
182
application can then subscribe a handler to that publisher and deal
226
183
with the results asynchronously without having to block:
227
184
```java
228
- SdkPublisher<Customer > results = mappedTable. query(r - > r . queryConditional (equalTo(Key . create(stringValue(" a123" )))));
185
+ SdkPublisher<Customer > results = mappedTable. query(QueryEnhancedRequest . create (equalTo(Key . create(stringValue(" a123" )))));
229
186
results. subscribe(myCustomerResultsProcessor);
230
187
// Perform other work and let the processor handle the results asynchronously
231
188
```
0 commit comments