commit
e690828cb1
|
@ -32,14 +32,14 @@ import (
|
|||
func ExampleOpenDefault() {
|
||||
var e error
|
||||
|
||||
e = fdb.APIVersion(400)
|
||||
e = fdb.APIVersion(630)
|
||||
if e != nil {
|
||||
fmt.Printf("Unable to set API version: %v\n", e)
|
||||
return
|
||||
}
|
||||
|
||||
// OpenDefault opens the database described by the platform-specific default
|
||||
// cluster file and the database name []byte("DB").
|
||||
// cluster file
|
||||
db, e := fdb.OpenDefault()
|
||||
if e != nil {
|
||||
fmt.Printf("Unable to open default database: %v\n", e)
|
||||
|
@ -47,16 +47,18 @@ func ExampleOpenDefault() {
|
|||
}
|
||||
|
||||
_ = db
|
||||
|
||||
// Output:
|
||||
}
|
||||
|
||||
func ExampleVersionstamp(t *testing.T) {
|
||||
fdb.MustAPIVersion(400)
|
||||
func TestVersionstamp(t *testing.T) {
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
setVs := func(t fdb.Transactor, key fdb.Key) (fdb.FutureKey, error) {
|
||||
fmt.Printf("setOne called with: %T\n", t)
|
||||
ret, e := t.Transact(func(tr fdb.Transaction) (interface{}, error) {
|
||||
tr.SetVersionstampedValue(key, []byte("blahblahbl"))
|
||||
tr.SetVersionstampedValue(key, []byte("blahblahbl\x00\x00\x00\x00"))
|
||||
return tr.GetVersionstamp(), nil
|
||||
})
|
||||
return ret.(fdb.FutureKey), e
|
||||
|
@ -76,16 +78,27 @@ func ExampleVersionstamp(t *testing.T) {
|
|||
var v []byte
|
||||
var fvs fdb.FutureKey
|
||||
var k fdb.Key
|
||||
var e error
|
||||
|
||||
fvs, _ = setVs(db, fdb.Key("foo"))
|
||||
v, _ = getOne(db, fdb.Key("foo"))
|
||||
t.Log(v)
|
||||
k, _ = fvs.Get()
|
||||
fvs, e = setVs(db, fdb.Key("foo"))
|
||||
if e != nil {
|
||||
t.Errorf("setOne failed %v", e)
|
||||
}
|
||||
v, e = getOne(db, fdb.Key("foo"))
|
||||
if e != nil {
|
||||
t.Errorf("getOne failed %v", e)
|
||||
}
|
||||
t.Logf("getOne returned %s", v)
|
||||
k, e = fvs.Get()
|
||||
if e != nil {
|
||||
t.Errorf("setOne wait failed %v", e)
|
||||
}
|
||||
t.Log(k)
|
||||
t.Logf("setOne returned %s", k)
|
||||
}
|
||||
|
||||
func ExampleTransactor() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
setOne := func(t fdb.Transactor, key fdb.Key, value []byte) error {
|
||||
|
@ -136,7 +149,7 @@ func ExampleTransactor() {
|
|||
}
|
||||
|
||||
func ExampleReadTransactor() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
getOne := func(rt fdb.ReadTransactor, key fdb.Key) ([]byte, error) {
|
||||
|
@ -189,7 +202,7 @@ func ExampleReadTransactor() {
|
|||
}
|
||||
|
||||
func ExamplePrefixRange() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
tr, e := db.CreateTransaction()
|
||||
|
@ -228,7 +241,7 @@ func ExamplePrefixRange() {
|
|||
}
|
||||
|
||||
func ExampleRangeIterator() {
|
||||
fdb.MustAPIVersion(400)
|
||||
fdb.MustAPIVersion(630)
|
||||
db := fdb.MustOpenDefault()
|
||||
|
||||
tr, e := db.CreateTransaction()
|
||||
|
@ -278,6 +291,8 @@ func TestKeyToString(t *testing.T) {
|
|||
t.Errorf("got '%v', want '%v' at case %v", s, c.expect, i)
|
||||
}
|
||||
}
|
||||
|
||||
// Output:
|
||||
}
|
||||
|
||||
func ExamplePrintable() {
|
||||
|
|
|
@ -700,8 +700,6 @@ Applications must provide error handling and an appropriate retry loop around th
|
|||
|
||||
|atomic-versionstamps-2|
|
||||
|
||||
|atomic-set-versionstamped-key-2|
|
||||
|
||||
.. warning :: |atomic-versionstamps-tuple-warning-key|
|
||||
|
||||
``FDB_MUTATION_TYPE_SET_VERSIONSTAMPED_VALUE``
|
||||
|
|
|
@ -132,9 +132,6 @@
|
|||
.. |atomic-set-versionstamped-key-1| replace::
|
||||
Transforms ``key`` using a versionstamp for the transaction. This key must be at least 14 bytes long. The final 4 bytes will be interpreted as a 32-bit little-endian integer denoting an index into the key at which to perform the transformation, and then trimmed off the key. The 10 bytes in the key beginning at the index will be overwritten with the versionstamp. If the index plus 10 bytes points past the end of the key, the result will be an error. Sets the transformed key in the database to ``param``.
|
||||
|
||||
.. |atomic-set-versionstamped-key-2| replace::
|
||||
This operation is not compatible with |read-your-writes-disable-option| and will generate an error if used with it.
|
||||
|
||||
.. |atomic-set-versionstamped-value| replace::
|
||||
Transforms ``param`` using a versionstamp for the transaction. This parameter must be at least 14 bytes long. The final 4 bytes will be interpreted as a 32-bit little-endian integer denoting an index into the parameter at which to perform the transformation, and then trimmed off the key. The 10 bytes in the parameter beginning at the index will be overwritten with the versionstamp. If the index plus 10 bytes points past the end of the parameter, the result will be an error. Sets ``key`` in the database to the transformed parameter.
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ FoundationDB may return the following error codes from API functions. If you nee
|
|||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| proxy_memory_limit_exceeded | 1042| Proxy commit memory limit exceeded |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| batch_transaction_throttled | 1051| Batch GRV request rate limit exceeded |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| operation_cancelled | 1101| Asynchronous operation cancelled |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| future_released | 1102| Future has been released |
|
||||
|
@ -112,6 +114,8 @@ FoundationDB may return the following error codes from API functions. If you nee
|
|||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| transaction_read_only | 2023| Attempted to commit a transaction specified as read-only |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| network_cannot_be_restarted | 2025| Network can only be started once |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| incompatible_protocol_version | 2100| Incompatible protocol version |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| transaction_too_large | 2101| Transaction exceeds byte limit |
|
||||
|
@ -136,6 +140,12 @@ FoundationDB may return the following error codes from API functions. If you nee
|
|||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| too_many_tag_throttles | 2111| Too many tag throttles have been created |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| special_keys_cross_module_read | 2112| Special key space range read crosses modules. |
|
||||
| | | Refer to the ``SPECIAL_KEY_SPACE_RELAXED`` transaction option for more details.|
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| special_keys_no_module_found | 2113| Special key space range read does not intersect a module. |
|
||||
| | | Refer to the ``SPECIAL_KEY_SPACE_RELAXED`` transaction option for more details.|
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| api_version_unset | 2200| API version is not set |
|
||||
+-----------------------------------------------+-----+--------------------------------------------------------------------------------+
|
||||
| api_version_already_set | 2201| API version may be set only once |
|
||||
|
|
|
@ -678,8 +678,6 @@ In each of the methods below, ``param`` should be a string appropriately packed
|
|||
|
||||
|atomic-versionstamps-2|
|
||||
|
||||
|atomic-set-versionstamped-key-2|
|
||||
|
||||
.. warning :: |atomic-versionstamps-tuple-warning-key|
|
||||
|
||||
.. method:: Transaction.set_versionstamped_value(key, param)
|
||||
|
|
|
@ -627,8 +627,6 @@ In each of the methods below, ``param`` should be a string appropriately packed
|
|||
|
||||
|atomic-versionstamps-2|
|
||||
|
||||
|atomic-set-versionstamped-key-2|
|
||||
|
||||
.. warning :: |atomic-versionstamps-tuple-warning-key|
|
||||
|
||||
.. method:: Transaction.set_versionstamped_value(key, param) -> nil
|
||||
|
|
Loading…
Reference in New Issue