Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thewisenerd/eade1bb2ec9b5df42ff87c0d3e1817ef to your computer and use it in GitHub Desktop.
Save thewisenerd/eade1bb2ec9b5df42ff87c0d3e1817ef to your computer and use it in GitHub Desktop.
import java.util.Base64
private data class ContinuationDebugPart(
val a: Int,
val b: Int,
val key: String
) {
override fun toString(): String {
return "[$a!$b!$key]"
}
fun encode(): String {
return "${a}!${b}!${Base64.getUrlEncoder().encodeToString(key.toByteArray())}"
}
}
private data class ContinuationDebugParts(
val pk: ContinuationDebugPart,
val rk: ContinuationDebugPart
)
private fun ResultContinuation.debugParts(): ContinuationDebugParts {
// m ! n ! {partitionKey}
val pk = this.nextPartitionKey.split("!")
// https://base64.guru/standards/base64url/decode
// p ! q ! {rowKey}>
// http://blog.smarx.com/posts/using-numbers-as-keys-in-windows-azure
// Together, the partition key and the row key form a unique identifier for the entity.
// They also define the order in which entities are returned in queries.
val rk = this.nextRowKey.split("!")
return ContinuationDebugParts(
ContinuationDebugPart(pk[0].toInt(), pk[1].toInt(), String(Base64.getUrlDecoder().decode(pk[2]))),
ContinuationDebugPart(rk[0].toInt(), rk[1].toInt(), String(Base64.getUrlDecoder().decode(rk[2])))
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment