To help a client application to implement "copy on write" snapshot feature, add the following lightweight server-side operations. These operations should be very efficient because they are metadata-only operations and do not have to read/copy the value on a disk.
copy/6 - copy the value and user metadata to other key(s).
From::key() and To:key() must have the same key prefix (they must be stored in the same chain.)
Design Notes:
To be a lightweight operation, use in-memory operation ?KEY_SWITCHAROO to copy only the pointer to the value.
When an hlog file containing From key is frozen, do not to use ?KEY_SWITCHAROO. Instead, do a disk-based operation; load the value of From key from an hlog on a disk and put the value to To key(s). More details on https://github.com/hibari/hibari/issues/33#issuecomment-31649930
Maybe we want remove rename/6 operation from brick_server? The same thing can be done by a micro-transaction: do([txn, copy(OldKey, NewKey), delete(OldKey)]) Note that the current implementation of rename/6 is not an equivalent of the micro-transaction but a simple do operation: do([copy(OldKey, NewKey), delete(OldKey)]) One good thing to keep rename/6 is that it has its own operation counter for the brick operation statistics, but it does not seem to be a must-have feature.
To help a client application to implement "copy on write" snapshot feature, add the following lightweight server-side operations. These operations should be very efficient because they are metadata-only operations and do not have to read/copy the value on a disk.
copy/6
- copy the value and user metadata to other key(s).copy(table(), From::key(), To::key(), exp_time(), [do_op_flag()], timeout())
copy(table(), From::key(), To::[key()], exp_time(), [do_op_flag()], timeout())
Limitation:
From::key()
andTo:key()
must have the same key prefix (they must be stored in the same chain.)Design Notes:
?KEY_SWITCHAROO
to copy only the pointer to the value.?KEY_SWITCHAROO
. Instead, do a disk-based operation; load the value of From key from an hlog on a disk and put the value to To key(s). More details on https://github.com/hibari/hibari/issues/33#issuecomment-31649930rename/6
operation from brick_server? The same thing can be done by a micro-transaction:do([txn, copy(OldKey, NewKey), delete(OldKey)])
Note that the current implementation ofrename/6
is not an equivalent of the micro-transaction but a simple do operation:do([copy(OldKey, NewKey), delete(OldKey)])
One good thing to keeprename/6
is that it has its own operation counter for the brick operation statistics, but it does not seem to be a must-have feature.