diff --git a/contentcoder.go b/contentcoder.go index 68638d80..388e5d00 100644 --- a/contentcoder.go +++ b/contentcoder.go @@ -110,9 +110,7 @@ func (c *chunkedContentCoder) Close() error { } func (c *chunkedContentCoder) incrementBytesWritten(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&c.bytesWritten, val) - } + atomic.AddUint64(&c.bytesWritten, val) } func (c *chunkedContentCoder) getBytesWritten() uint64 { diff --git a/docvalues.go b/docvalues.go index afbe5394..bd3574da 100644 --- a/docvalues.go +++ b/docvalues.go @@ -147,9 +147,7 @@ func (di *docValueReader) ResetBytesRead(val uint64) { } func (di *docValueReader) incrementBytesRead(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&di.bytesRead, val) - } + atomic.AddUint64(&di.bytesRead, val) } func (di *docValueReader) BytesWritten() uint64 { diff --git a/intDecoder.go b/intDecoder.go index 630d2104..c8751f0a 100644 --- a/intDecoder.go +++ b/intDecoder.go @@ -59,9 +59,9 @@ func newChunkedIntDecoder(buf []byte, offset uint64, rv *chunkedIntDecoder) *chu rv.chunkOffsets[i], read = binary.Uvarint(buf[offset+n : offset+n+binary.MaxVarintLen64]) n += uint64(read) } - if CollectDiskStats { - atomic.AddUint64(&rv.bytesRead, n) - } + + atomic.AddUint64(&rv.bytesRead, n) + rv.dataStartOffset = offset + n return rv } @@ -91,9 +91,9 @@ func (d *chunkedIntDecoder) loadChunk(chunk int) error { start += s end += e d.curChunkBytes = d.data[start:end] - if CollectDiskStats { - atomic.AddUint64(&d.bytesRead, uint64(len(d.curChunkBytes))) - } + + atomic.AddUint64(&d.bytesRead, uint64(len(d.curChunkBytes))) + if d.r == nil { d.r = newMemUvarintReader(d.curChunkBytes) } else { diff --git a/intcoder.go b/intcoder.go index 52dbb1ef..5b716b3f 100644 --- a/intcoder.go +++ b/intcoder.go @@ -78,9 +78,7 @@ func (c *chunkedIntCoder) SetChunkSize(chunkSize uint64, maxDocNum uint64) { } func (c *chunkedIntCoder) incrementBytesWritten(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&c.bytesWritten, val) - } + atomic.AddUint64(&c.bytesWritten, val) } func (c *chunkedIntCoder) getBytesWritten() uint64 { diff --git a/new.go b/new.go index d6b0ac43..edbf45d1 100644 --- a/new.go +++ b/new.go @@ -33,10 +33,6 @@ var NewSegmentBufferNumResultsBump int = 100 var NewSegmentBufferNumResultsFactor float64 = 1.0 var NewSegmentBufferAvgBytesPerDocFactor float64 = 1.0 -// This flag controls the disk stats collection from the segment files -// during indexing and querying -var CollectDiskStats bool - // ValidateDocFields can be set by applications to perform additional checks // on fields in a document being added to a new segment, by default it does // nothing. @@ -498,9 +494,7 @@ func (s *interim) getBytesWritten() uint64 { } func (s *interim) incrementBytesWritten(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&s.bytesWritten, val) - } + atomic.AddUint64(&s.bytesWritten, val) } func (s *interim) writeStoredFields() ( @@ -617,9 +611,7 @@ func (s *interim) writeStoredFields() ( } func (s *interim) setBytesWritten(val uint64) { - if CollectDiskStats { - atomic.StoreUint64(&s.bytesWritten, val) - } + atomic.StoreUint64(&s.bytesWritten, val) } func (s *interim) writeDicts() (fdvIndexOffset uint64, dictOffsets []uint64, err error) { diff --git a/posting.go b/posting.go index cc80d39b..dcae817f 100644 --- a/posting.go +++ b/posting.go @@ -263,9 +263,7 @@ func (p *PostingsList) BytesRead() uint64 { } func (p *PostingsList) incrementBytesRead(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&p.bytesRead, val) - } + atomic.AddUint64(&p.bytesRead, val) } func (p *PostingsList) BytesWritten() uint64 { @@ -378,9 +376,7 @@ func (i *PostingsIterator) BytesRead() uint64 { } func (i *PostingsIterator) incrementBytesRead(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&i.bytesRead, val) - } + atomic.AddUint64(&i.bytesRead, val) } func (i *PostingsIterator) BytesWritten() uint64 { diff --git a/segment.go b/segment.go index 68981d71..f62918c8 100644 --- a/segment.go +++ b/segment.go @@ -228,9 +228,7 @@ func (s *Segment) loadConfig() error { // read from the on-disk segment as part of the current // query. func (s *Segment) ResetBytesRead(val uint64) { - if CollectDiskStats { - atomic.StoreUint64(&s.SegmentBase.bytesRead, val) - } + atomic.StoreUint64(&s.SegmentBase.bytesRead, val) } func (s *Segment) BytesRead() uint64 { @@ -243,9 +241,7 @@ func (s *Segment) BytesWritten() uint64 { } func (s *Segment) incrementBytesRead(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&s.bytesRead, val) - } + atomic.AddUint64(&s.bytesRead, val) } func (s *SegmentBase) BytesWritten() uint64 { @@ -253,9 +249,7 @@ func (s *SegmentBase) BytesWritten() uint64 { } func (s *SegmentBase) setBytesWritten(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&s.bytesWritten, val) - } + atomic.AddUint64(&s.bytesWritten, val) } func (s *SegmentBase) BytesRead() uint64 { @@ -265,9 +259,7 @@ func (s *SegmentBase) BytesRead() uint64 { func (s *SegmentBase) ResetBytesRead(val uint64) {} func (s *SegmentBase) incrementBytesRead(val uint64) { - if CollectDiskStats { - atomic.AddUint64(&s.bytesRead, val) - } + atomic.AddUint64(&s.bytesRead, val) } func (s *SegmentBase) loadFields() error {