Skip to content

Commit

Permalink
Add versions to nodes (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
outofforest authored Oct 3, 2024
1 parent ed873a1 commit e16caa9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
27 changes: 12 additions & 15 deletions snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,23 @@ func NewSnapshot(config SnapshotConfig) (Snapshot, error) {
})

s := Snapshot{
config: config,
snapshots: snapshots,
spaces: spaces,
deallocator: deallocator,
spacesToCommit: map[SpaceID]spaceToCommit{},
config: config,
snapshots: snapshots,
spaces: spaces,
deallocator: deallocator,
pointerNodeAllocator: pointerNodeAllocator,
spacesToCommit: map[SpaceID]spaceToCommit{},
}
return s, nil
}

// Snapshot represents the state at particular point in time.
type Snapshot struct {
config SnapshotConfig
snapshots *Space[SnapshotID, SnapshotInfo]
spaces *Space[SpaceID, SpaceInfo]
deallocator Deallocator
config SnapshotConfig
snapshots *Space[SnapshotID, SnapshotInfo]
spaces *Space[SpaceID, SpaceInfo]
deallocator Deallocator
pointerNodeAllocator SpaceNodeAllocator[NodeAddress]

spacesToCommit map[SpaceID]spaceToCommit
}
Expand Down Expand Up @@ -211,11 +213,6 @@ func GetSpace[K, V comparable](spaceID SpaceID, snapshot Snapshot) (*Space[K, V]
snapshot.spacesToCommit[spaceID] = space
}

pointerNodeAllocator, err := NewSpaceNodeAllocator[NodeAddress](snapshot.config.Allocator)
if err != nil {
return nil, err
}

dataNodeAllocator, err := NewSpaceNodeAllocator[DataItem[K, V]](snapshot.config.Allocator)
if err != nil {
return nil, err
Expand All @@ -225,7 +222,7 @@ func GetSpace[K, V comparable](spaceID SpaceID, snapshot Snapshot) (*Space[K, V]
SnapshotID: snapshot.config.SnapshotID,
HashMod: space.HashMod,
SpaceRoot: space.PInfo,
PointerNodeAllocator: pointerNodeAllocator,
PointerNodeAllocator: snapshot.pointerNodeAllocator,
DataNodeAllocator: dataNodeAllocator,
Deallocator: snapshot.deallocator,
}), nil
Expand Down
3 changes: 3 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type (

// SpaceNodeHeader is the header common to all space node types.
type SpaceNodeHeader struct {
Version uint64
SnapshotID SnapshotID
HashMod uint64
}
Expand All @@ -40,6 +41,7 @@ type SpaceNode[T comparable] struct {

// ListNodeHeader is the header of the list node.
type ListNodeHeader struct {
Version uint64
SnapshotID SnapshotID
NumOfItems uint64
NumOfSideLists uint64
Expand Down Expand Up @@ -80,6 +82,7 @@ type SnapshotInfo struct {

// SingularityNode is the root of the store.
type SingularityNode struct {
Version uint64
SnapshotID SnapshotID
SnapshotRoot SpaceInfo
}

0 comments on commit e16caa9

Please sign in to comment.