mirror of
https://github.com/gogrlx/bitcask.git
synced 2026-04-14 00:38:21 -07:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ec5b07eea | ||
|
|
5ed43e5a20 | ||
| edd32cad0a | |||
| d23c355e72 | |||
| 40425394d7 | |||
| f4cc0fb434 |
10
CHANGELOG.md
10
CHANGELOG.md
@@ -1,4 +1,13 @@
|
|||||||
|
|
||||||
|
<a name="v1.0.2"></a>
|
||||||
|
## [v1.0.2](https://git.mills.io/prologic/bitcask/compare/v1.0.1...v1.0.2) (2021-11-01)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Fix a data race in Datafile.ReadAt()
|
||||||
|
* Fix release tool
|
||||||
|
|
||||||
|
|
||||||
<a name="v1.0.1"></a>
|
<a name="v1.0.1"></a>
|
||||||
## [v1.0.1](https://git.mills.io/prologic/bitcask/compare/v1.0.0...v1.0.1) (2021-10-31)
|
## [v1.0.1](https://git.mills.io/prologic/bitcask/compare/v1.0.0...v1.0.1) (2021-10-31)
|
||||||
|
|
||||||
@@ -9,6 +18,7 @@
|
|||||||
|
|
||||||
### Updates
|
### Updates
|
||||||
|
|
||||||
|
* Update CHANGELOG for v1.0.1
|
||||||
* Update image target
|
* Update image target
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
26
Makefile
26
Makefile
@@ -3,6 +3,10 @@
|
|||||||
CGO_ENABLED=0
|
CGO_ENABLED=0
|
||||||
VERSION=$(shell git describe --abbrev=0 --tags)
|
VERSION=$(shell git describe --abbrev=0 --tags)
|
||||||
COMMIT=$(shell git rev-parse --short HEAD)
|
COMMIT=$(shell git rev-parse --short HEAD)
|
||||||
|
BUILD=$(shell git show -s --pretty=format:%cI)
|
||||||
|
GOCMD=go
|
||||||
|
|
||||||
|
DESTDIR=/usr/local/bin
|
||||||
|
|
||||||
all: dev
|
all: dev
|
||||||
|
|
||||||
@@ -11,21 +15,21 @@ dev: build
|
|||||||
@./bitcaskd --version
|
@./bitcaskd --version
|
||||||
|
|
||||||
build: clean generate
|
build: clean generate
|
||||||
@go build \
|
@$(GOCMD) build \
|
||||||
-tags "netgo static_build" -installsuffix netgo \
|
-tags "netgo static_build" -installsuffix netgo \
|
||||||
-ldflags "-w -X $(shell go list)/internal.Version=$(VERSION) -X $(shell go list)/internal.Commit=$(COMMIT)" \
|
-ldflags "-w -X $(shell go list)/internal.Version=$(VERSION) -X $(shell go list)/internal.Commit=$(COMMIT) -X $(shell go list)/internal.Build=$(BUILD)" \
|
||||||
./cmd/bitcask/...
|
./cmd/bitcask/...
|
||||||
@go build \
|
@$(GOCMD) build \
|
||||||
-tags "netgo static_build" -installsuffix netgo \
|
-tags "netgo static_build" -installsuffix netgo \
|
||||||
-ldflags "-w -X $(shell go list)/internal.Version=$(VERSION) -X $(shell go list)/internal.Commit=$(COMMIT)" \
|
-ldflags "-w -X $(shell go list)/internal.Version=$(VERSION) -X $(shell go list)/internal.Commit=$(COMMIT) -X $(shell go list)/internal.Build=$(BUILD)" \
|
||||||
./cmd/bitcaskd/...
|
./cmd/bitcaskd/...
|
||||||
|
|
||||||
generate:
|
generate:
|
||||||
@go generate $(shell go list)/...
|
@$(GOCMD) generate $(shell go list)/...
|
||||||
|
|
||||||
install: build
|
install: build
|
||||||
@go install ./cmd/bitcask/...
|
@install -D -m 755 bitcask $(DESTDIR)/bitcask
|
||||||
@go install ./cmd/bitcaskd/...
|
@install -D -m 755 bitcaskd $(DESTDIR)/bitcaskd
|
||||||
|
|
||||||
ifeq ($(PUBLISH), 1)
|
ifeq ($(PUBLISH), 1)
|
||||||
image:
|
image:
|
||||||
@@ -40,23 +44,23 @@ release:
|
|||||||
@./tools/release.sh
|
@./tools/release.sh
|
||||||
|
|
||||||
profile: build
|
profile: build
|
||||||
@go test -cpuprofile cpu.prof -memprofile mem.prof -v -bench .
|
@$(GOCMD) test -cpuprofile cpu.prof -memprofile mem.prof -v -bench .
|
||||||
|
|
||||||
bench: build
|
bench: build
|
||||||
@go test -v -run=XXX -benchmem -bench=. .
|
@$(GOCMD) test -v -run=XXX -benchmem -bench=. .
|
||||||
|
|
||||||
mocks:
|
mocks:
|
||||||
@mockery -all -case underscore -output ./internal/mocks -recursive
|
@mockery -all -case underscore -output ./internal/mocks -recursive
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
@go test -v \
|
@$(GOCMD) test -v \
|
||||||
-cover -coverprofile=coverage.txt -covermode=atomic \
|
-cover -coverprofile=coverage.txt -covermode=atomic \
|
||||||
-coverpkg=$(shell go list) \
|
-coverpkg=$(shell go list) \
|
||||||
-race \
|
-race \
|
||||||
.
|
.
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
@go get github.com/vektra/mockery/...
|
@$(GOCMD) get github.com/vektra/mockery/...
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@git clean -f -d -X
|
@git clean -f -d -X
|
||||||
|
|||||||
12
bitcask.go
12
bitcask.go
@@ -264,7 +264,9 @@ func (b *Bitcask) Sift(f func(key []byte) (bool, error)) (err error) {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
b.mu.RUnlock()
|
b.mu.RUnlock()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
keysToDelete.ForEach(func(node art.Node) (cont bool) {
|
keysToDelete.ForEach(func(node art.Node) (cont bool) {
|
||||||
@@ -343,6 +345,10 @@ func (b *Bitcask) SiftScan(prefix []byte, f func(key []byte) (bool, error)) (err
|
|||||||
})
|
})
|
||||||
b.mu.RUnlock()
|
b.mu.RUnlock()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
keysToDelete.ForEach(func(node art.Node) (cont bool) {
|
keysToDelete.ForEach(func(node art.Node) (cont bool) {
|
||||||
@@ -422,6 +428,10 @@ func (b *Bitcask) SiftRange(start, end []byte, f func(key []byte) (bool, error))
|
|||||||
})
|
})
|
||||||
b.mu.RUnlock()
|
b.mu.RUnlock()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
defer b.mu.Unlock()
|
defer b.mu.Unlock()
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"git.mills.io/prologic/bitcask/internal"
|
"git.mills.io/prologic/bitcask/internal"
|
||||||
"git.mills.io/prologic/bitcask/internal/data/codec"
|
"git.mills.io/prologic/bitcask/internal/data/codec"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/exp/mmap"
|
"golang.org/x/exp/mmap"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -159,6 +159,9 @@ func (df *datafile) ReadAt(index, size int64) (e internal.Entry, err error) {
|
|||||||
|
|
||||||
b := make([]byte, size)
|
b := make([]byte, size)
|
||||||
|
|
||||||
|
df.RLock()
|
||||||
|
defer df.RUnlock()
|
||||||
|
|
||||||
if df.ra != nil {
|
if df.ra != nil {
|
||||||
n, err = df.ra.ReadAt(b, index)
|
n, err = df.ra.ReadAt(b, index)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,17 +2,49 @@ package internal
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultVersion = "0.0.0"
|
||||||
|
defaultCommit = "HEAD"
|
||||||
|
defaultBuild = "0000-01-01:00:00+00:00"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Version release version
|
// Version is the tagged release version in the form <major>.<minor>.<patch>
|
||||||
Version = "0.0.1"
|
// following semantic versioning and is overwritten by the build system.
|
||||||
|
Version = defaultVersion
|
||||||
|
|
||||||
// Commit will be overwritten automatically by the build system
|
// Commit is the commit sha of the build (normally from Git) and is overwritten
|
||||||
Commit = "HEAD"
|
// by the build system.
|
||||||
|
Commit = defaultCommit
|
||||||
|
|
||||||
|
// Build is the date and time of the build as an RFC3339 formatted string
|
||||||
|
// and is overwritten by the build system.
|
||||||
|
Build = defaultBuild
|
||||||
)
|
)
|
||||||
|
|
||||||
// FullVersion returns the full version and commit hash
|
// FullVersion display the full version and build
|
||||||
func FullVersion() string {
|
func FullVersion() string {
|
||||||
return fmt.Sprintf("%s@%s", Version, Commit)
|
var sb strings.Builder
|
||||||
|
|
||||||
|
isDefault := Version == defaultVersion && Commit == defaultCommit && Build == defaultBuild
|
||||||
|
|
||||||
|
if !isDefault {
|
||||||
|
sb.WriteString(fmt.Sprintf("%s@%s %s", Version, Commit, Build))
|
||||||
|
}
|
||||||
|
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
if isDefault {
|
||||||
|
sb.WriteString(fmt.Sprintf(" %s", info.Main.Version))
|
||||||
|
}
|
||||||
|
sb.WriteString(fmt.Sprintf(" %s", info.GoVersion))
|
||||||
|
if info.Main.Sum != "" {
|
||||||
|
sb.WriteString(fmt.Sprintf(" %s", info.Main.Sum))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ echo "Releasing ${TAG} ..."
|
|||||||
git-chglog --next-tag="${TAG}" --output CHANGELOG.md
|
git-chglog --next-tag="${TAG}" --output CHANGELOG.md
|
||||||
git commit -a -m "Update CHANGELOG for ${TAG}"
|
git commit -a -m "Update CHANGELOG for ${TAG}"
|
||||||
git tag -a -s -m "Release ${TAG}" "${TAG}"
|
git tag -a -s -m "Release ${TAG}" "${TAG}"
|
||||||
git push --tags
|
git push && git push --tags
|
||||||
goreleaser release \
|
goreleaser release \
|
||||||
--rm-dist \
|
--rm-dist \
|
||||||
--release-notes <(git-chglog "${TAG}" | tail -n+5)
|
--release-notes <(git-chglog "${TAG}" | tail -n+5)
|
||||||
|
|||||||
Reference in New Issue
Block a user