Skip to content

Commit

Permalink
remove unnecessary bytes written
Browse files Browse the repository at this point in the history
  • Loading branch information
Thejas-bhat committed Oct 25, 2024
1 parent a72794c commit b6b60ac
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
7 changes: 3 additions & 4 deletions contentcoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"encoding/binary"
"io"
"reflect"
"sync/atomic"

"github.com/golang/snappy"
)
Expand All @@ -37,7 +36,7 @@ var (
)

type chunkedContentCoder struct {
bytesWritten uint64 // atomic access to this variable, moved to top to correct alignment issues on ARM, 386 and 32-bit MIPS.
bytesWritten uint64 // moved to top to correct alignment issues on ARM, 386 and 32-bit MIPS.

final []byte
chunkSize uint64
Expand Down Expand Up @@ -112,11 +111,11 @@ func (c *chunkedContentCoder) Close() error {
}

func (c *chunkedContentCoder) incrementBytesWritten(val uint64) {
atomic.AddUint64(&c.bytesWritten, val)
c.bytesWritten += val
}

func (c *chunkedContentCoder) getBytesWritten() uint64 {
return atomic.LoadUint64(&c.bytesWritten)
return c.bytesWritten
}

func (c *chunkedContentCoder) flushContents() error {
Expand Down
1 change: 0 additions & 1 deletion docvalues.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ type docValueReader struct {
curChunkData []byte // compressed data cache
uncompressed []byte // temp buf for snappy decompression

// atomic access to this variable
bytesRead uint64
}

Expand Down
1 change: 0 additions & 1 deletion intDecoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type chunkedIntDecoder struct {
data []byte
r *memUvarintReader

// atomic access to this variable
bytesRead uint64
}

Expand Down
6 changes: 2 additions & 4 deletions intcoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"bytes"
"encoding/binary"
"io"
"sync/atomic"
)

// We can safely use 0 to represent termNotEncoded since 0
Expand All @@ -36,7 +35,6 @@ type chunkedIntCoder struct {

buf []byte

// atomic access to this variable
bytesWritten uint64
}

Expand Down Expand Up @@ -79,11 +77,11 @@ func (c *chunkedIntCoder) SetChunkSize(chunkSize uint64, maxDocNum uint64) {
}

func (c *chunkedIntCoder) incrementBytesWritten(val uint64) {
atomic.AddUint64(&c.bytesWritten, val)
c.bytesWritten += val
}

func (c *chunkedIntCoder) getBytesWritten() uint64 {
return atomic.LoadUint64(&c.bytesWritten)
return c.bytesWritten
}

// Add encodes the provided integers into the correct chunk for the provided
Expand Down
5 changes: 2 additions & 3 deletions new.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ type interim struct {
lastNumDocs int
lastOutSize int

// atomic access to this variable
bytesWritten uint64
}

Expand Down Expand Up @@ -497,11 +496,11 @@ func (s *interim) processDocument(docNum uint64,
}

func (s *interim) getBytesWritten() uint64 {
return atomic.LoadUint64(&s.bytesWritten)
return s.bytesWritten
}

func (s *interim) incrementBytesWritten(val uint64) {
atomic.AddUint64(&s.bytesWritten, val)
s.bytesWritten += val
}

func (s *interim) writeStoredFields() (
Expand Down

0 comments on commit b6b60ac

Please sign in to comment.