Skip to content

Commit

Permalink
WIP - Remove unhelpful cache
Browse files Browse the repository at this point in the history
The contents are very cheap, possibly more so than the cache.
  • Loading branch information
AndrewSisley committed Nov 20, 2024
1 parent df0a6c3 commit eb788d8
Showing 1 changed file with 15 additions and 27 deletions.
42 changes: 15 additions & 27 deletions internal/db/fetcher/versioned.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ type VersionedFetcher struct {
acp immutable.Option[acp.ACP]

col client.Collection
// @todo index *client.IndexDescription
mCRDTs map[client.FieldID]merklecrdt.MerkleCRDT
}

// Init initializes the VersionedFetcher.
Expand All @@ -115,7 +113,6 @@ func (vf *VersionedFetcher) Init(
vf.acp = acp
vf.col = col
vf.queuedCids = list.New()
vf.mCRDTs = make(map[client.FieldID]merklecrdt.MerkleCRDT)
vf.txn = txn

// create store
Expand Down Expand Up @@ -323,16 +320,11 @@ func (vf *VersionedFetcher) merge(c cid.Cid) error {
return err
}

// first arg 0 is the index for the composite DAG in the mCRDTs cache
mcrdt, exists := vf.mCRDTs[0]
if !exists {
mcrdt = merklecrdt.NewMerkleCompositeDAG(
vf.store,
keys.NewCollectionSchemaVersionKey(block.Delta.GetSchemaVersionID(), vf.col.Description().RootID),
vf.dsKey.WithFieldID(core.COMPOSITE_NAMESPACE),
)
vf.mCRDTs[0] = mcrdt
}
mcrdt := merklecrdt.NewMerkleCompositeDAG(
vf.store,
keys.NewCollectionSchemaVersionKey(block.Delta.GetSchemaVersionID(), vf.col.Description().RootID),
vf.dsKey.WithFieldID(core.COMPOSITE_NAMESPACE),
)
err = mcrdt.Clock().ProcessBlock(vf.ctx, block, link)
if err != nil {
return err
Expand All @@ -351,20 +343,16 @@ func (vf *VersionedFetcher) merge(c cid.Cid) error {
return client.NewErrFieldNotExist(l.Name)
}

mcrdt, exists := vf.mCRDTs[field.ID]
if !exists {
mcrdt, err = merklecrdt.FieldLevelCRDTWithStore(
vf.store,
keys.NewCollectionSchemaVersionKey(block.Delta.GetSchemaVersionID(), vf.col.Description().RootID),
field.Typ,
field.Kind,
vf.dsKey.WithFieldID(fmt.Sprint(field.ID)),
field.Name,
)
if err != nil {
return err
}
vf.mCRDTs[field.ID] = mcrdt
mcrdt, err := merklecrdt.FieldLevelCRDTWithStore(
vf.store,
keys.NewCollectionSchemaVersionKey(block.Delta.GetSchemaVersionID(), vf.col.Description().RootID),
field.Typ,
field.Kind,
vf.dsKey.WithFieldID(fmt.Sprint(field.ID)),
field.Name,
)
if err != nil {
return err
}

err = mcrdt.Clock().ProcessBlock(vf.ctx, subBlock, l.Link)
Expand Down

0 comments on commit eb788d8

Please sign in to comment.