Skip to content

Commit

Permalink
sstable: gofmt -s
Browse files Browse the repository at this point in the history
Noticed I was seeing spurious diffs when making unrelated edits to files in this
package, so just running everything though 'gofmt -s -w', as of go 1.17.2.
  • Loading branch information
dt committed Nov 29, 2021
1 parent badc275 commit e6abf34
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 126 deletions.
30 changes: 15 additions & 15 deletions sstable/block_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ type BlockPropertyFilter interface {
// Users must not expect this to preserve differences between empty sets --
// they will all get turned into the semantically equivalent [0,0).
type BlockIntervalCollector struct {
name string
dbic DataBlockIntervalCollector
name string
dbic DataBlockIntervalCollector

blockInterval interval
indexInterval interval
Expand Down Expand Up @@ -182,7 +182,7 @@ type interval struct {

func (i interval) encode(buf []byte) []byte {
if i.lower < i.upper {
var encoded [binary.MaxVarintLen64*2]byte
var encoded [binary.MaxVarintLen64 * 2]byte
n := binary.PutUvarint(encoded[:], i.lower)
n += binary.PutUvarint(encoded[n:], i.upper-i.lower)
buf = append(buf, encoded[:n]...)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (i interval) intersects(x interval) bool {
// corresponding collector is a BlockIntervalCollector. That is, the set is of
// the form [lower, upper).
type BlockIntervalFilter struct {
name string
name string
filterInterval interval
}

Expand All @@ -255,7 +255,7 @@ type BlockIntervalFilter struct {
func NewBlockIntervalFilter(
name string, lower uint64, upper uint64) *BlockIntervalFilter {
return &BlockIntervalFilter{
name: name,
name: name,
filterInterval: interval{lower: lower, upper: upper},
}
}
Expand All @@ -282,7 +282,7 @@ type shortID uint8

type blockPropertiesEncoder struct {
propsBuf []byte
scratch []byte
scratch []byte
}

func (e *blockPropertiesEncoder) getScratchForProp() []byte {
Expand All @@ -296,24 +296,24 @@ func (e *blockPropertiesEncoder) resetProps() {
func (e *blockPropertiesEncoder) addProp(id shortID, scratch []byte) {
const lenID = 1
lenProp := uvarintLen(uint32(len(scratch)))
n := lenID + lenProp + len(scratch)
if cap(e.propsBuf) - len(e.propsBuf) < n {
n := lenID + lenProp + len(scratch)
if cap(e.propsBuf)-len(e.propsBuf) < n {
size := len(e.propsBuf) + 2*n
if size < 2*cap(e.propsBuf) {
size = 2*cap(e.propsBuf)
size = 2 * cap(e.propsBuf)
}
buf := make([]byte, len(e.propsBuf), size)
copy(buf, e.propsBuf)
e.propsBuf = buf
}
pos := len(e.propsBuf)
b := e.propsBuf[pos:pos+lenID]
b := e.propsBuf[pos : pos+lenID]
b[0] = byte(id)
pos += lenID
b = e.propsBuf[pos:pos+lenProp]
b = e.propsBuf[pos : pos+lenProp]
n = binary.PutUvarint(b, uint64(len(scratch)))
pos += n
b = e.propsBuf[pos:pos+len(scratch)]
b = e.propsBuf[pos : pos+len(scratch)]
pos += len(scratch)
copy(b, scratch)
e.propsBuf = e.propsBuf[0:pos]
Expand Down Expand Up @@ -344,10 +344,10 @@ func (d *blockPropertiesDecoder) next() (id shortID, prop []byte, err error) {
id = shortID(d.props[0])
propLen, m := binary.Uvarint(d.props[lenID:])
n := lenID + m
if m <= 0 || propLen == 0 || (n + int(propLen)) > len(d.props) {
if m <= 0 || propLen == 0 || (n+int(propLen)) > len(d.props) {
return 0, nil, base.CorruptionErrorf("corrupt block property length")
}
prop = d.props[n:n+int(propLen)]
prop = d.props[n : n+int(propLen)]
d.props = d.props[n+int(propLen):]
return id, prop, nil
}
Expand Down Expand Up @@ -450,7 +450,7 @@ func (f *BlockPropertiesFilterer) intersects(props []byte) (bool, error) {
}
id = int(shortID)
} else {
id = math.MaxUint8+1
id = math.MaxUint8 + 1
}
for i < len(f.shortIDToFiltersIndex) && id > i {
if f.shortIDToFiltersIndex[i] >= 0 {
Expand Down
Loading

0 comments on commit e6abf34

Please sign in to comment.