Skip to content

Commit

Permalink
WIP new load iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrakhman committed Jul 3, 2024
1 parent 426339d commit bb74b84
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.22.1
require (
github.com/ahmetb/govvv v0.3.0
github.com/akrylysov/pogreb v0.10.2
github.com/anyproto/any-sync v0.4.22-0.20240625165343-0352d658fc7f
github.com/anyproto/any-sync v0.4.22-0.20240703165104-49ad49acbeba
github.com/anyproto/go-chash v0.1.0
github.com/gogo/protobuf v1.3.2
github.com/prometheus/client_golang v1.19.1
Expand Down Expand Up @@ -81,3 +81,5 @@ require (
google.golang.org/protobuf v1.33.0 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
)

replace github.com/akrylysov/pogreb => github.com/anyproto/pogreb v0.0.0-20240703122929-76639f85e02d
10 changes: 4 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/ahmetb/govvv v0.3.0 h1:YGLGwEyiUwHFy5eh/RUhdupbuaCGBYn5T5GWXp+WJB0=
github.com/ahmetb/govvv v0.3.0/go.mod h1:4WRFpdWtc/YtKgPFwa1dr5+9hiRY5uKAL08bOlxOR6s=
github.com/akrylysov/pogreb v0.10.2 h1:e6PxmeyEhWyi2AKOBIJzAEi4HkiC+lKyCocRGlnDi78=
github.com/akrylysov/pogreb v0.10.2/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI=
github.com/anyproto/any-sync v0.4.22-0.20240625122430-43ebec49a9ad h1:99pHR5WC/RDOe7ZEjZK//e53mD2ewVdufFeWdo7C+C0=
github.com/anyproto/any-sync v0.4.22-0.20240625122430-43ebec49a9ad/go.mod h1:sO/zUrmnCZKnH/3KaRH3JQSZMuINS3X7ZJa+d4YgfkA=
github.com/anyproto/any-sync v0.4.22-0.20240625165343-0352d658fc7f h1:hU6/xrxlMuc82TcFcPsAk2qQ6lZzNPMVuqBL9pxxuzU=
github.com/anyproto/any-sync v0.4.22-0.20240625165343-0352d658fc7f/go.mod h1:sO/zUrmnCZKnH/3KaRH3JQSZMuINS3X7ZJa+d4YgfkA=
github.com/anyproto/any-sync v0.4.22-0.20240703165104-49ad49acbeba h1:b/kXcIBlc1oz3Ijd1bbKcJBUwMZleWOZvWpypVFVUI0=
github.com/anyproto/any-sync v0.4.22-0.20240703165104-49ad49acbeba/go.mod h1:sO/zUrmnCZKnH/3KaRH3JQSZMuINS3X7ZJa+d4YgfkA=
github.com/anyproto/go-chash v0.1.0 h1:I9meTPjXFRfXZHRJzjOHC/XF7Q5vzysKkiT/grsogXY=
github.com/anyproto/go-chash v0.1.0/go.mod h1:0UjNQi3PDazP0fINpFYu6VKhuna+W/V+1vpXHAfNgLY=
github.com/anyproto/go-slip10 v1.0.0 h1:uAEtSuudR3jJBOfkOXf3bErxVoxbuKwdoJN55M1i6IA=
github.com/anyproto/go-slip10 v1.0.0/go.mod h1:BCmIlM1KB8wX6K4/8pOvxPl9oVKfEvZ5vsmO5rkK6vg=
github.com/anyproto/go-slip21 v1.0.0 h1:CI7lUqTIwmPOEGVAj4jyNLoICvueh++0U2HoAi3m2ZY=
github.com/anyproto/go-slip21 v1.0.0/go.mod h1:gbIJt7HAdr5DuT4f2pFTKCBSUWYsm/fysHBNqgsuxT0=
github.com/anyproto/pogreb v0.0.0-20240703122929-76639f85e02d h1:l/LUeTGhID9hdr1bgMnbmqmLi4Yie8YzqoIaw4Iidm0=
github.com/anyproto/pogreb v0.0.0-20240703122929-76639f85e02d/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
11 changes: 9 additions & 2 deletions nodespace/nodecache/treecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ package nodecache
import (
"context"
"errors"
"github.com/anyproto/any-sync-node/nodespace"
"time"

"github.com/anyproto/any-sync/app"
"github.com/anyproto/any-sync/app/logger"
"github.com/anyproto/any-sync/app/ocache"
"github.com/anyproto/any-sync/commonspace/object/tree/objecttree"
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
"github.com/anyproto/any-sync/commonspace/object/treemanager"
"github.com/anyproto/any-sync/commonspace/objecttreebuilder"
"github.com/anyproto/any-sync/metric"
"go.uber.org/zap"
"time"

"github.com/anyproto/any-sync-node/nodespace"
)

var log = logger.NewNamed("treecache")
Expand All @@ -28,6 +31,10 @@ type treeCache struct {
nodeService nodespace.Service
}

func (c *treeCache) ValidateAndPutTree(ctx context.Context, spaceId string, payload treestorage.TreeStorageCreatePayload) error {
panic("implement me")
}

func New(ttl int) treemanager.TreeManager {
return &treeCache{
gcttl: ttl,
Expand Down
17 changes: 17 additions & 0 deletions nodestorage/treestorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nodestorage

import (
"context"

"github.com/akrylysov/pogreb"
"github.com/anyproto/any-sync/commonspace/object/tree/treechangeproto"
"github.com/anyproto/any-sync/commonspace/object/tree/treestorage"
Expand Down Expand Up @@ -116,6 +117,22 @@ func (t *treeStorage) AddRawChange(change *treechangeproto.RawTreeChangeWithId)
return t.db.Put(t.keys.RawChangeKey(change.Id), change.RawChange)
}

func (t *treeStorage) GetAppendRawChange(ctx context.Context, buf []byte, id string) (raw *treechangeproto.RawTreeChangeWithId, err error) {
res, err := t.db.GetAppend(t.keys.RawChangeKey(id), buf)
if err != nil {
return
}
if res == nil {
err = treestorage.ErrUnknownChange
}

raw = &treechangeproto.RawTreeChangeWithId{
RawChange: res,
Id: id,
}
return
}

func (t *treeStorage) GetRawChange(ctx context.Context, id string) (raw *treechangeproto.RawTreeChangeWithId, err error) {
res, err := t.db.Get(t.keys.RawChangeKey(id))
if err != nil {
Expand Down

0 comments on commit bb74b84

Please sign in to comment.