Skip to content

Commit

Permalink
Merge pull request #41 from SaveTheRbtz/dependabot/go_modules/github.…
Browse files Browse the repository at this point in the history
…com/google/btree-1.1.1

build(deps): bump github.com/google/btree from 1.0.1 to 1.1.1
  • Loading branch information
SaveTheRbtz authored Jul 4, 2022
2 parents b3125d8 + 7bd6080 commit 7d1e377
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 22 deletions.
9 changes: 3 additions & 6 deletions decoder.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package seekable

import (
"github.com/google/btree"

"github.com/SaveTheRbtz/zstd-seekable-format-go/env"
"github.com/SaveTheRbtz/zstd-seekable-format-go/options"
)
Expand Down Expand Up @@ -73,8 +71,8 @@ func (r *readerImpl) GetIndexByDecompOffset(off uint64) (found *env.FrameOffsetE
return nil
}

r.index.DescendLessOrEqual(&env.FrameOffsetEntry{DecompOffset: off}, func(i btree.Item) bool {
found = i.(*env.FrameOffsetEntry)
r.index.DescendLessOrEqual(&env.FrameOffsetEntry{DecompOffset: off}, func(index *env.FrameOffsetEntry) bool {
found = index
return false
})
return
Expand All @@ -85,8 +83,7 @@ func (r *readerImpl) GetIndexByID(id int64) (found *env.FrameOffsetEntry) {
return nil
}

r.index.Descend(func(i btree.Item) bool {
index := i.(*env.FrameOffsetEntry)
r.index.Descend(func(index *env.FrameOffsetEntry) bool {
if index.ID == id {
found = index
return false
Expand Down
4 changes: 2 additions & 2 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def go_dependencies():
name = "com_github_google_btree",
build_directives = ["gazelle:exclude **/**_test.go", "gazelle:exclude testing", "gazelle:exclude **/testdata"],
importpath = "github.com/google/btree",
sum = "h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=",
version = "v1.0.1",
sum = "h1:OMJCfqwmbcwNihVCadalGMZiHclz5T0mRv12gnIaV0Q=",
version = "v1.1.1",
)

go_repository(
Expand Down
5 changes: 1 addition & 4 deletions env/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@ go_library(
],
importpath = "github.com/SaveTheRbtz/zstd-seekable-format-go/env",
visibility = ["//visibility:public"],
deps = [
"@com_github_google_btree//:btree",
"@org_uber_go_zap//zapcore",
],
deps = ["@org_uber_go_zap//zapcore"],
)
5 changes: 2 additions & 3 deletions env/frame_offset.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package env

import (
"github.com/google/btree"
"go.uber.org/zap/zapcore"
)

Expand Down Expand Up @@ -34,6 +33,6 @@ func (o *FrameOffsetEntry) MarshalLogObject(enc zapcore.ObjectEncoder) error {
return nil
}

func (o *FrameOffsetEntry) Less(than btree.Item) bool {
return o.DecompOffset < than.(*FrameOffsetEntry).DecompOffset
func Less(a, b *FrameOffsetEntry) bool {
return a.DecompOffset < b.DecompOffset
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/cespare/xxhash/v2 v2.1.2
github.com/google/btree v1.0.1
github.com/google/btree v1.1.1
github.com/klauspost/compress v1.15.7
github.com/restic/chunker v0.4.0
github.com/stretchr/testify v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
github.com/google/btree v1.1.1 h1:OMJCfqwmbcwNihVCadalGMZiHclz5T0mRv12gnIaV0Q=
github.com/google/btree v1.1.1/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/klauspost/compress v1.15.7 h1:7cgTQxJCU/vy+oP/E3B9RGbQTgbiVzIJWIKOLoAsPok=
github.com/klauspost/compress v1.15.7/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
Expand Down
10 changes: 6 additions & 4 deletions reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (rs *readSeekerEnvImpl) ReadSkipFrame(skippableFrameOffset int64) ([]byte,

type readerImpl struct {
dec ZSTDDecoder
index *btree.BTree
index *btree.BTreeG[*env.FrameOffsetEntry]

checksums bool

Expand Down Expand Up @@ -309,7 +309,7 @@ func (r *readerImpl) Seek(offset int64, whence int) (int64, error) {
return r.offset, nil
}

func (r *readerImpl) indexFooter() (*btree.BTree, *env.FrameOffsetEntry, error) {
func (r *readerImpl) indexFooter() (*btree.BTreeG[*env.FrameOffsetEntry], *env.FrameOffsetEntry, error) {
// read seekTableFooter
buf, err := r.o.Env.ReadFooter()
if err != nil {
Expand Down Expand Up @@ -374,13 +374,15 @@ func (r *readerImpl) indexFooter() (*btree.BTree, *env.FrameOffsetEntry, error)
return r.indexSeekTableEntries(buf[8:len(buf)-seekTableFooterOffset], uint64(seekTableEntrySize))
}

func (r *readerImpl) indexSeekTableEntries(p []byte, entrySize uint64) (*btree.BTree, *env.FrameOffsetEntry, error) {
func (r *readerImpl) indexSeekTableEntries(p []byte, entrySize uint64) (
*btree.BTreeG[*env.FrameOffsetEntry], *env.FrameOffsetEntry, error,
) {
if uint64(len(p))%entrySize != 0 {
return nil, nil, fmt.Errorf("seek table size is not multiple of %d", entrySize)
}

// TODO: make fan-out tunable?
t := btree.New(8)
t := btree.NewG[*env.FrameOffsetEntry](8, env.Less)
entry := seekTableEntry{}
var compOffset, decompOffset uint64

Expand Down

0 comments on commit 7d1e377

Please sign in to comment.