Skip to content

Commit 3f5a080

Browse files
committed
Explanation comment
1 parent 82f4ca2 commit 3f5a080

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

object_store/src/azure/client.rs

+34
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,40 @@ fn marker_for_offset(offset: &str, is_emulator: bool) -> String {
564564
if is_emulator {
565565
return offset.to_string();
566566
} else {
567+
// Here we reconstruct an Azure marker (continuation token) from a key to be able to seek
568+
// into an arbitrary position in the key space.
569+
// The current format (July 2024) for the marker is as follows:
570+
//
571+
// +-> unpadded length of next field
572+
// |
573+
// | +-> unpadded length of base64 encoded field
574+
// | |
575+
// | | +-> base64 encoded field with padding characters (=) repaced with -
576+
// | | |
577+
// 2!72!MDAwMDA4IWZpbGUudHh0ITAwMDAyOCE5OTk5LTEyLTMxVDIzOjU5OjU5Ljk5OTk5OTlaIQ--
578+
// | | ^
579+
// terminators |
580+
// |
581+
// +------------+
582+
// Decoding the |base64 field| gives:
583+
// +------------+
584+
//
585+
// +-> length of key field padded to 6 digits
586+
// |
587+
// | +-> key to start listing at
588+
// | |
589+
// | | +-> length of timestamp field padded to 6 digits
590+
// | | |
591+
// | | | +-> constant max timestamp field
592+
// | | | |
593+
// 000008!file.txt!000028!9999-12-31T23:59:59.9999999Z!
594+
// | | | |
595+
// +----> field terminators <-------------------+
596+
//
597+
// When recostructing we add a space character (ASCII 0x20) to the end of the key to change the
598+
// `start_at` behavior into a `start_after` behavior as the space character is the first valid character
599+
// in the lexicographical order.
600+
567601
let encoded_part = BASE64_STANDARD.encode(
568602
&format!("{:06}!{} !000028!9999-12-31T23:59:59.9999999Z!", offset.len() + 1, offset)
569603
).replace("=", "-");

0 commit comments

Comments
 (0)