@@ -52,6 +52,7 @@ namespace FoundationDB.Client
5252 private const ulong PLACEHOLDER_VERSION = ulong . MaxValue ;
5353 private const ushort PLACEHOLDER_ORDER = ushort . MaxValue ;
5454 private const ushort NO_USER_VERSION = 0 ;
55+ private const ulong HSB_VERSION = 0x8000000000000000UL ;
5556
5657 private const ushort FLAGS_NONE = 0x0 ;
5758 private const ushort FLAGS_HAS_VERSION = 0x1 ; // unset: 80-bits, set: 96-bits
@@ -262,46 +263,22 @@ public static bool TryParse(Slice data, out VersionStamp vs)
262263 {
263264 fixed ( byte * ptr = & data . DangerousGetPinnableReference ( ) )
264265 {
265- ReadUnsafe ( ptr , data . Count , FLAGS_NONE , out vs ) ;
266+ ReadUnsafe ( ptr , data . Count , out vs ) ;
266267 return true ;
267268 }
268269 }
269270 }
270271
271- /// <summary>Parse a VersionStamp from a sequence of 10 bytes</summary>
272- /// <exception cref="FormatException">If the buffer length is not exactly 12 bytes</exception>
273- [ Pure ]
274- public static VersionStamp ParseIncomplete ( Slice data )
275- {
276- return TryParseIncomplete ( data , out var vs ) ? vs : throw new FormatException ( "A VersionStamp is either 10 or 12 bytes." ) ;
277- }
278-
279- /// <summary>Try parsing a VersionStamp from a sequence of bytes</summary>
280- public static bool TryParseIncomplete ( Slice data , out VersionStamp vs )
281- {
282- if ( data . Count != 10 && data . Count != 12 )
283- {
284- vs = default ;
285- return false ;
286- }
287- unsafe
288- {
289- fixed ( byte * ptr = & data . DangerousGetPinnableReference ( ) )
290- {
291- ReadUnsafe ( ptr , data . Count , FLAGS_IS_INCOMPLETE , out vs ) ;
292- return true ;
293- }
294- }
295- }
296-
297- internal static unsafe void ReadUnsafe ( byte * ptr , int len , ushort flags , out VersionStamp vs )
272+ internal static unsafe void ReadUnsafe ( byte * ptr , int len , out VersionStamp vs )
298273 {
299274 Contract . Debug . Assert ( len == 10 || len == 12 ) ;
300275 // reads a complete 12 bytes Versionstamp
301276 ulong ver = UnsafeHelpers . LoadUInt64BE ( ptr ) ;
302277 ushort order = UnsafeHelpers . LoadUInt16BE ( ptr + 8 ) ;
303278 ushort idx = len == 10 ? NO_USER_VERSION : UnsafeHelpers . LoadUInt16BE ( ptr + 10 ) ;
304- flags |= len == 12 ? FLAGS_HAS_VERSION : FLAGS_NONE ;
279+ ushort flags = FLAGS_NONE ;
280+ if ( len == 12 ) flags |= FLAGS_HAS_VERSION ;
281+ if ( ( ver & HSB_VERSION ) != 0 ) flags |= FLAGS_IS_INCOMPLETE ;
305282 vs = new VersionStamp ( ver , order , idx , flags ) ;
306283 }
307284
0 commit comments