69.4 Space
A Space is a lightweight logical namespace containing serial
elements indexed by 32-bit Seids. Each Space belongs to a
Partition and is indexed within that partition by a 32-bit
SpaceId.
The LSS API represents a Space in an immutable partition snapshot with an
ISpaceView. It is owned by its
IPartitionView and directly refers to the Space state in that
snapshot. A client can therefore call FindSpace() once and use
the returned interface for repeated reads without repeatedly looking up the
SpaceId in the SpaceDirectory's
radix map.
A partition transaction similarly owns an IMutableSpace for each
Space it accesses. It initially refers to the state selected from the transaction's base snapshot.
On first mutation, copy-on-write may create mutable Space state and make the same interface refer to
that copy. The interface is local to the transaction and becomes invalid when the transaction is
closed.
The next Seid used for sequential allocation belongs to the
Space, while the RPM owns the
radix mapping from Seids to log-record positions:
struct Space
{
SpaceId id;
Seid nextSeid;
RPM rpm;
};
A checkpointed or published Space state contains both the allocation state and the corresponding
RPM root. Readers use the RPM root; the writer uses nextSeid for
allocation.
The allocation state and RPM are separate but coupled. Every explicitly reserved or inserted Seid
must be less than nextSeid. Inserting a caller-supplied Seid therefore
goes through IMutableSpace, which advances
nextSeid when required as well as updating the RPM.