Skip to content

Commit

Permalink
*: format files according to gofmt
Browse files Browse the repository at this point in the history
Run `gofmt -s -w` across all files, excluding the `vendor` directory
using the `make format` target.

Most of these changes are adding the equivalent `//go:build` lines to
source files that are built conditionally (per the [Go 1.17 release
notes][1]).

[1]: https://go.dev/doc/go1.17
  • Loading branch information
nicktrav committed Nov 30, 2021
1 parent fc3ffab commit 7fb375f
Show file tree
Hide file tree
Showing 54 changed files with 118 additions and 72 deletions.
12 changes: 6 additions & 6 deletions cmd/pebble/ycsb.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,27 @@ func (w ycsbWeights) get(i int) float64 {
}

var ycsbWorkloads = map[string]ycsbWeights{
"A": ycsbWeights{
"A": {
ycsbRead: 0.5,
ycsbUpdate: 0.5,
},
"B": ycsbWeights{
"B": {
ycsbRead: 0.95,
ycsbUpdate: 0.05,
},
"C": ycsbWeights{
"C": {
ycsbRead: 1.0,
},
"D": ycsbWeights{
"D": {
ycsbInsert: 0.05,
ycsbRead: 0.95,
// TODO(peter): default to skewed-latest distribution.
},
"E": ycsbWeights{
"E": {
ycsbInsert: 0.05,
ycsbScan: 0.95,
},
"F": ycsbWeights{
"F": {
ycsbInsert: 1.0,
// TODO(peter): the real workload is read-modify-write.
},
Expand Down
1 change: 1 addition & 0 deletions internal/arenaskl/race_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build race
// +build race

// Copyright 2020 The LevelDB-Go and Pebble Authors. All rights reserved. Use
Expand Down
1 change: 1 addition & 0 deletions internal/cache/cgo_disabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build !cgo
// +build !cgo

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/cache/cgo_enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build cgo
// +build cgo

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/cache/entry_invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
//go:build (invariants && !race) || (tracing && !race)
// +build invariants,!race tracing,!race

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/cache/entry_normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.
//
//go:build (!invariants && !tracing) || race
// +build !invariants,!tracing race

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/cache/refcnt_normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build !tracing
// +build !tracing

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/cache/refcnt_tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build tracing
// +build tracing

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/cache/value_invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build (invariants && !race) || (tracing && !race)
// +build invariants,!race tracing,!race

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/cache/value_normal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build (!invariants && !tracing) || race
// +build !invariants,!tracing race

package cache
Expand Down
1 change: 1 addition & 0 deletions internal/invariants/finalizer_off.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build (!invariants && !tracing) || race
// +build !invariants,!tracing race

package invariants
Expand Down
1 change: 1 addition & 0 deletions internal/invariants/finalizer_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build (invariants && !race) || (tracing && !race)
// +build invariants,!race tracing,!race

package invariants
Expand Down
1 change: 1 addition & 0 deletions internal/invariants/off.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build !invariants && !race
// +build !invariants,!race

package invariants
Expand Down
1 change: 1 addition & 0 deletions internal/invariants/on.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build invariants || race
// +build invariants race

package invariants
Expand Down
1 change: 1 addition & 0 deletions internal/invariants/race_off.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build !race
// +build !race

package invariants
Expand Down
1 change: 1 addition & 0 deletions internal/invariants/race_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build race
// +build race

package invariants
Expand Down
3 changes: 2 additions & 1 deletion internal/manual/manual_32bit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

// +build 386 amd64p32 arm armbe mips mipsle mips64p32 mips64p32le ppc sparc
//go:build 386 || amd64p32 || arm || armbe || mips || mipsle || mips64p32 || mips64p32le || ppc || sparc
// +build 386 amd64p32 arm armbe mips mipsle mips64p32 mips64p32le ppc sparc

package manual

Expand Down
1 change: 1 addition & 0 deletions internal/manual/manual_64bit.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build amd64 || arm64 || arm64be || ppc64 || ppc64le || mips64 || mips64le || s390x || sparc64
// +build amd64 arm64 arm64be ppc64 ppc64le mips64 mips64le s390x sparc64

package manual
Expand Down
1 change: 1 addition & 0 deletions internal/manual/manual_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// of this source code is governed by a BSD-style license that can be found in
// the LICENSE file.

//go:build !cgo
// +build !cgo

package manual
Expand Down
6 changes: 3 additions & 3 deletions internal/metamorphic/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (g *generator) newIter() {
if iters := g.readers[readerID]; iters != nil {
iters[iterID] = struct{}{}
g.iters[iterID] = iters
//lint:ignore SA9003 - readability
//lint:ignore SA9003 - readability
} else {
// NB: the DB object does not track its open iterators because it never
// closes.
Expand Down Expand Up @@ -369,7 +369,7 @@ func (g *generator) newIterUsingClone() {
if iters := g.iters[existingIterID]; iters != nil {
iters[iterID] = struct{}{}
g.iters[iterID] = iters
//lint:ignore SA9003 - readability
//lint:ignore SA9003 - readability
} else {
// NB: the DB object does not track its open iterators because it never
// closes.
Expand All @@ -391,7 +391,7 @@ func (g *generator) iterClose() {
if readerIters, ok := g.iters[iterID]; ok {
delete(g.iters, iterID)
delete(readerIters, iterID)
//lint:ignore SA9003 - readability
//lint:ignore SA9003 - readability
} else {
// NB: the DB object does not track its open iterators because it never
// closes.
Expand Down
16 changes: 8 additions & 8 deletions internal/metamorphic/key_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ type keyMeta struct {
objKey

// The number of Sets of the key in this writer.
sets int
sets int
// The number of Merges of the key in this writer.
merges int
merges int
// singleDel can be true only if sets <= 1 && merges == 0 and the
// SingleDelete was added to this writer after the set.
singleDel bool
Expand Down Expand Up @@ -102,11 +102,11 @@ type keyManager struct {
byObjKey map[string]*keyMeta
// List of keys per writer, and what has happened to it in that writer.
// Will be transferred when needed.
byObj map[objID][]*keyMeta
byObj map[objID][]*keyMeta

// globalKeys represents all the keys that have been generated so far. Not
// all these keys have been written to.
globalKeys [][]byte
globalKeys [][]byte
// globalKeysMap contains the same keys as globalKeys. It ensures no
// duplication, and contains the aggregate state of the key across all
// writers, including inflight state that has not made its way to the DB
Expand Down Expand Up @@ -161,8 +161,8 @@ var dbObjID objID = makeObjID(dbTag, 0)
// canTolerateApplyFailure methods only.
func newKeyManager() *keyManager {
m := &keyManager{
byObjKey: make(map[string]*keyMeta),
byObj: make(map[objID][]*keyMeta),
byObjKey: make(map[string]*keyMeta),
byObj: make(map[objID][]*keyMeta),
globalKeysMap: make(map[string]*keyMeta),
}
m.byObj[dbObjID] = []*keyMeta{}
Expand Down Expand Up @@ -298,7 +298,7 @@ func (k *keyManager) update(o op) {
case *setOp:
meta := k.getOrInit(s.writerID, s.key)
globalMeta := k.globalKeysMap[string(s.key)]
meta.sets++ // Update the set count on this specific (id, key) pair.
meta.sets++ // Update the set count on this specific (id, key) pair.
meta.del = false
globalMeta.sets++
if meta.singleDel || globalMeta.singleDel {
Expand Down Expand Up @@ -396,7 +396,7 @@ func (k *keyManager) eligibleSingleDeleteKeys(id objID) (keys [][]byte) {

func (k *keyManager) globalStateIndicatesEligibleForSingleDelete(key []byte) bool {
m := k.globalKeysMap[string(key)]
return m.merges==0 && m.sets==1 && m.dels==0 && !m.singleDel
return m.merges == 0 && m.sets == 1 && m.dels == 0 && !m.singleDel
}

// canTolerateApplyFailure is called with a batch ID and returns true iff a
Expand Down
60 changes: 30 additions & 30 deletions internal/metamorphic/key_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ func TestGlobalStateIndicatesEligibleForSingleDelete(t *testing.T) {
meta: keyMeta{
objKey: key,
sets: 1,
dels: 1,
dels: 1,
},
want: false,
},
{
meta: keyMeta{
objKey: key,
sets: 1,
objKey: key,
sets: 1,
singleDel: true,
},
want: false,
Expand All @@ -93,7 +93,7 @@ func TestGlobalStateIndicatesEligibleForSingleDelete(t *testing.T) {
func TestKeyMeta_MergeInto(t *testing.T) {
testCases := []struct {
existing keyMeta
toMerge keyMeta
toMerge keyMeta
expected keyMeta
}{
{
Expand All @@ -107,49 +107,49 @@ func TestKeyMeta_MergeInto(t *testing.T) {
merges: 0,
singleDel: true,
},
expected: keyMeta {
expected: keyMeta{
sets: 1,
merges: 0,
singleDel: true,
},
},
{
existing: keyMeta{
sets: 3,
merges: 1,
dels: 7,
sets: 3,
merges: 1,
dels: 7,
},
toMerge: keyMeta{
sets: 4,
merges: 2,
dels: 8,
del: true,
sets: 4,
merges: 2,
dels: 8,
del: true,
},
expected: keyMeta {
sets: 7,
merges: 3,
dels: 15,
del: true,
expected: keyMeta{
sets: 7,
merges: 3,
dels: 15,
del: true,
},
},
{
existing: keyMeta{
sets: 3,
merges: 1,
dels: 7,
del: true,
sets: 3,
merges: 1,
dels: 7,
del: true,
},
toMerge: keyMeta{
sets: 1,
merges: 0,
dels: 8,
del: false,
sets: 1,
merges: 0,
dels: 8,
del: false,
},
expected: keyMeta {
sets: 4,
merges: 1,
dels: 15,
del: false,
expected: keyMeta{
sets: 4,
merges: 1,
dels: 15,
del: false,
},
},
}
Expand Down
Loading

0 comments on commit 7fb375f

Please sign in to comment.