Documentation
Returns the buffer, id, nr-slots and schema-id of the object
containing the compatible version for the given transaction id. The
buffer points to the first octet after the standard object fields.
As a fifth value, it returns a boolean that's true when the object
version is the most recent committed object version (i.e. in the head
of the object version list).
Source
(defun find-committed-object-version (object-id current-transaction-id heap)
"Returns the buffer, id, nr-slots and schema-id of the object
containing the compatible version for the given transaction id. The
buffer points to the first octet after the standard object fields.
As a fifth value, it returns a boolean that's true when the object
version is the most recent committed object version (i.e. in the head
of the object version list)."
;; The object table points to a list of object versions (youngest
;; transaction first).
(let ((block (object-heap-position (object-table heap) object-id))
(most-recent-p t))
(loop
(let ((buffer (load-block heap block :skip-header t)))
(multiple-value-bind (id nr-slots schema-id transaction-id prev-version)
(load-object-fields buffer object-id)
(cond ((<= transaction-id current-transaction-id)
;; We found the 'compatible' object version: the most recent
;; version that's not younger than the current transaction.
(return (values buffer id nr-slots schema-id most-recent-p)))
((null prev-version)
;; Oh oh.
(internal-rucksack-error "Can't find compatible object
version for object #~D and transaction ~D."
object-id current-transaction-id))
(t
;; Keep trying previous versions.
(setq block prev-version
most-recent-p nil))))))))
Source Context