Skip to content

Instantly share code, notes, and snippets.

@maxpospischil
Created February 26, 2018 18:40
Show Gist options
  • Save maxpospischil/ffd7ebb452a7eb5518232b0d64eb098a to your computer and use it in GitHub Desktop.
Save maxpospischil/ffd7ebb452a7eb5518232b0d64eb098a to your computer and use it in GitHub Desktop.
Strongly consistent local secondary index query
private def recordsQuery =
ScanamoOps.query(
ScanamoQueryRequest(
tableName,
Some("incomplete_index"),
'pkey -> s"$uuid.${schema.id}",
new ScanamoQueryOptions(consistent = true, limit = Some(concurrencyLimit), None, None)
)
).map {
_.getItems.asScala.map { r =>
DynamoFormat[BatchRecord].read(new AttributeValue().withM(r))
}.toSet
}
def nextRecords: Task[Set[BatchRecord]] = Task {
Scanamo.exec(client)(recordsQuery).collect {
case Right(r) => r
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment