Returns a string representing the specified position. Note that we adjust the actual position by incrementing it by 1 because we reserve 0 for storing the promise record (Record::Promise, DEPRECATED!), or the metadata (Record::Metadata).
| 86 | // reserve 0 for storing the promise record (Record::Promise, |
| 87 | // DEPRECATED!), or the metadata (Record::Metadata). |
| 88 | static string encode(uint64_t position, bool adjust = true) |
| 89 | { |
| 90 | // Adjusted stringified represenation is plus 1 of actual position. |
| 91 | position = adjust ? position + 1 : position; |
| 92 | |
| 93 | // TODO(benh): Use varint encoding for VarInt64Comparator! |
| 94 | // string s; |
| 95 | // google::protobuf::io::StringOutputStream _stream(&s); |
| 96 | // google::protobuf::io::CodedOutputStream stream(&_stream); |
| 97 | // position = adjust ? position + 1 : position; |
| 98 | // stream.WriteVarint64(position); |
| 99 | // return s; |
| 100 | |
| 101 | Try<string> s = strings::format("%.*d", 10, position); |
| 102 | CHECK_SOME(s); |
| 103 | return s.get(); |
| 104 | } |
| 105 | |
| 106 | |
| 107 | // Returns the position as represented in the specified slice |