This repository has been archived by the owner on Sep 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Add ScanDeleteBatch request. (#137)
- Loading branch information
1 parent
acda2f1
commit b22296c
Showing
7 changed files
with
150 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
80 changes: 80 additions & 0 deletions
80
d4s/src/main/scala/d4s/models/query/requests/ScanDeleteBatch.scala
This file contains 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,80 @@ | ||
package d4s.models.query.requests | ||
|
||
import java.util | ||
|
||
import d4s.models.conditions.Condition | ||
import d4s.models.conditions.Condition.ZeroCondition | ||
import d4s.models.query.DynamoRequest | ||
import d4s.models.query.DynamoRequest._ | ||
import d4s.models.table.TableReference | ||
import d4s.models.table.index.TableIndex | ||
import software.amazon.awssdk.services.dynamodb.model.{AttributeValue, BatchWriteItemResponse, ScanRequest, Select} | ||
|
||
final case class ScanDeleteBatch( | ||
table: TableReference, | ||
maxParallelDeletes: Option[Int] = None, | ||
index: Option[String] = None, | ||
filterExpression: Condition = ZeroCondition, | ||
attributeValues: Map[String, AttributeValue] = Map.empty, | ||
attributeNames: Map[String, String] = Map.empty, | ||
projectionExpression: Option[String] = None, | ||
limit: Option[Int] = None, | ||
select: Option[Select] = None, | ||
startKey: Option[java.util.Map[String, AttributeValue]] = None, | ||
consistent: Boolean = false, | ||
) extends DynamoRequest | ||
with WithFilterExpression[ScanDeleteBatch] | ||
with WithAttributeValues[ScanDeleteBatch] | ||
with WithAttributeNames[ScanDeleteBatch] | ||
with WithProjectionExpression[ScanDeleteBatch] | ||
with WithSelect[ScanDeleteBatch] | ||
with WithStartKey[ScanDeleteBatch] | ||
with WithLimit[ScanDeleteBatch] | ||
with WithTableReference[ScanDeleteBatch] | ||
with WithIndex[ScanDeleteBatch] | ||
with WithConsistent[ScanDeleteBatch] | ||
with WithParallelism[ScanDeleteBatch] | ||
with WithWrappedRequest[Scan] { | ||
|
||
override type Rq = ScanRequest | ||
override type Rsp = List[BatchWriteItemResponse] | ||
|
||
override def withParallelism(parallelism: Int): ScanDeleteBatch = copy(maxParallelDeletes = Some(parallelism)) | ||
|
||
override def withAttributeNames(an: Map[String, String] => Map[String, String]): ScanDeleteBatch = copy(attributeNames = an(attributeNames)) | ||
|
||
override def withConsistent(consistentRead: Boolean): ScanDeleteBatch = copy(consistent = consistentRead) | ||
|
||
override def withSelect(newSelect: Select): ScanDeleteBatch = copy(select = Some(newSelect)) | ||
|
||
override def withIndex(index: TableIndex[_, _]): ScanDeleteBatch = copy(index = Some(index.name)) | ||
|
||
override def withStartKeyMap(startKey: util.Map[String, AttributeValue]): ScanDeleteBatch = copy(startKey = Some(startKey)) | ||
|
||
override def withTableReference(t: TableReference => TableReference): ScanDeleteBatch = copy(table = t(table)) | ||
|
||
override def withProjectionExpression(f: Option[String] => Option[String]): ScanDeleteBatch = copy(projectionExpression = f(projectionExpression)) | ||
|
||
override def withFilterExpression(t: Condition): ScanDeleteBatch = copy(filterExpression = filterExpression && t) | ||
|
||
override def withAttributeValues(f: Map[String, AttributeValue] => Map[String, AttributeValue]): ScanDeleteBatch = copy(attributeValues = f(attributeValues)) | ||
|
||
override def withLimit(l: Int): ScanDeleteBatch = copy(limit = Some(l)) | ||
|
||
override def toAmz: ScanRequest = wrapped.toAmz | ||
|
||
override def wrapped: Scan = { | ||
Scan( | ||
table = table, | ||
index = index, | ||
filterExpression = filterExpression, | ||
attributeValues = attributeValues, | ||
attributeNames = attributeNames, | ||
projectionExpression = projectionExpression, | ||
limit = limit, | ||
select = select, | ||
startKey = startKey, | ||
consistent = consistent, | ||
) | ||
} | ||
} |
This file contains 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