added documentation for versionstamped tuples to python docs
This commit is contained in:
parent
2868908c14
commit
fc97fa3c8d
|
@ -353,7 +353,7 @@ def _encode(value, nested=False):
|
|||
raise ValueError("Unsupported data type: " + str(type(value)))
|
||||
|
||||
# packs the specified tuple into that may be used for versionstamp operations but may be used for regular ops
|
||||
def pack_maybe_with_versionstamp(t, prefix=None, prefix_len=0):
|
||||
def _pack_maybe_with_versionstamp(t, prefix=None, prefix_len=0):
|
||||
if prefix is not None and prefix_len > 0 and len(prefix) != prefix_len:
|
||||
raise ValueError("Inconsistent values specified for prefix and prefix_len")
|
||||
if prefix_len < 0:
|
||||
|
@ -375,14 +375,14 @@ def pack_maybe_with_versionstamp(t, prefix=None, prefix_len=0):
|
|||
|
||||
# packs the specified tuple into a key
|
||||
def pack(t, prefix=None):
|
||||
res, version_pos = pack_maybe_with_versionstamp(t, prefix)
|
||||
res, version_pos = _pack_maybe_with_versionstamp(t, prefix)
|
||||
if version_pos >= 0:
|
||||
raise ValueError("Incomplete versionstamp included in vanilla tuple pack")
|
||||
return res
|
||||
|
||||
# packs the specified tuple into a key for versionstamp operations
|
||||
def pack_with_versionstamp(t, prefix=None, prefix_len=0):
|
||||
res, version_pos = pack_maybe_with_versionstamp(t, prefix, prefix_len)
|
||||
res, version_pos = _pack_maybe_with_versionstamp(t, prefix, prefix_len)
|
||||
if version_pos < 0:
|
||||
raise ValueError("No incomplete versionstamp included in tuple pack with versionstamp")
|
||||
return res
|
||||
|
@ -396,6 +396,19 @@ def unpack(key, prefix_len=0):
|
|||
res.append(r)
|
||||
return tuple(res)
|
||||
|
||||
# determines if there is at least one incomplete versionstamp in a tuple
|
||||
def has_incomplete_versionstamp(t):
|
||||
def _elem_has_incomplete(item):
|
||||
if item is None:
|
||||
return False
|
||||
elif isinstance(item, Versionstamp):
|
||||
return not item.is_complete()
|
||||
elif isinstance(item, tuple) or isinstance(item, list):
|
||||
return has_incomplete_versionstamp(item)
|
||||
else:
|
||||
return False
|
||||
return any(map(_elem_has_incomplete, t))
|
||||
|
||||
_range = range
|
||||
def range(t):
|
||||
"""Returns a slice of keys that includes all tuples of greater
|
||||
|
|
|
@ -171,9 +171,9 @@ Status: Reserved
|
|||
Typecode: `0x33`
|
||||
Length: 12 bytes
|
||||
Encoding: Big endian 12-byte integer. First/high 8 bytes are a database version, next two are batch version, next two are ordering within transaction.
|
||||
Status: Reserved
|
||||
Status: Python, Java
|
||||
|
||||
The two versionstamp typecodes are reserved for future work adding compatibility between the tuple layer and versionstamp operations. Note that the first 80 bits of the 96 bit versionstamp are the same as the contents of the 80 bit versionstamp, and they correspond to what the `SET_VERSIONSTAMP_KEY` mutation will write into a database key , i.e., the first 8 bytes are a big-endian, unsigned version corresponding to the commit version of a transaction, and the next to bytes are a big-endian, unsigned batch number ordering transactions are committed at the same version. The final two bytes of the 96 bit versionstamp are written by the client and should order writes within a single transaction, thereby providing a global order for all versions.
|
||||
The two versionstamp typecodes are reserved for ongoing work adding compatibility between the tuple layer and versionstamp operations. Note that the first 80 bits of the 96 bit versionstamp are the same as the contents of the 80 bit versionstamp, and they correspond to what the `SET_VERSIONSTAMP_KEY` mutation will write into a database key , i.e., the first 8 bytes are a big-endian, unsigned version corresponding to the commit version of a transaction, and the next to bytes are a big-endian, unsigned batch number ordering transactions are committed at the same version. The final two bytes of the 96 bit versionstamp are written by the client and should order writes within a single transaction, thereby providing a global order for all versions.
|
||||
|
||||
### **User type codes**
|
||||
|
||||
|
|
Loading…
Reference in New Issue