Created
June 1, 2023 23:43
-
-
Save thewisenerd/eade1bb2ec9b5df42ff87c0d3e1817ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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