Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6a00142

Browse files
committedAug 8, 2019
Simplified variable naming: 'ingestFromNextChunkT0' becomes 'ingestFromT0'
1 parent b8b6f89 commit 6a00142

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed
 

‎mdata/aggmetric.go

+27-27
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ type AggMetric struct {
3131
store Store
3232
cachePusher cache.CachePusher
3333
sync.RWMutex
34-
key schema.AMKey
35-
rob *ReorderBuffer
36-
currentChunkPos int // Chunks[CurrentChunkPos] is active. Others are finished. Only valid when len(chunks) > 0, e.g. when data has been written (excl ROB data)
37-
numChunks uint32 // max size of the circular buffer
38-
chunkSpan uint32 // span of individual chunks in seconds
39-
chunks []*chunk.Chunk
40-
aggregators []*Aggregator
41-
dropFirstChunk bool
42-
ingestFromNextChunkT0 uint32
43-
ttl uint32
44-
lastSaveStart uint32 // last chunk T0 that was added to the write Queue.
45-
lastSaveFinish uint32 // last chunk T0 successfully written to Cassandra.
46-
lastWrite uint32 // wall clock time of when last point was successfully added (possibly to the ROB)
47-
firstTs uint32 // timestamp of first point seen
34+
key schema.AMKey
35+
rob *ReorderBuffer
36+
currentChunkPos int // Chunks[CurrentChunkPos] is active. Others are finished. Only valid when len(chunks) > 0, e.g. when data has been written (excl ROB data)
37+
numChunks uint32 // max size of the circular buffer
38+
chunkSpan uint32 // span of individual chunks in seconds
39+
chunks []*chunk.Chunk
40+
aggregators []*Aggregator
41+
dropFirstChunk bool
42+
ingestFromT0 uint32
43+
ttl uint32
44+
lastSaveStart uint32 // last chunk T0 that was added to the write Queue.
45+
lastSaveFinish uint32 // last chunk T0 successfully written to Cassandra.
46+
lastWrite uint32 // wall clock time of when last point was successfully added (possibly to the ROB)
47+
firstTs uint32 // timestamp of first point seen
4848
}
4949

5050
// NewAggMetric creates a metric with given key, it retains the given number of chunks each chunkSpan seconds long
@@ -56,22 +56,22 @@ func NewAggMetric(store Store, cachePusher cache.CachePusher, key schema.AMKey,
5656
// note: during parsing of retentions, we assure there's at least 1.
5757
ret := retentions[0]
5858

59-
ingestFromNextChunkT0 := uint32(0)
59+
ingestFromT0 := uint32(0)
6060
if ingestFrom > 0 {
6161
// compute start of next chunk after ingestFrom
62-
ingestFromNextChunkT0 = uint32(ingestFrom-(ingestFrom%int64(ret.ChunkSpan))) + ret.ChunkSpan
62+
ingestFromT0 = uint32(ingestFrom-(ingestFrom%int64(ret.ChunkSpan))) + ret.ChunkSpan
6363
}
6464

6565
m := AggMetric{
66-
cachePusher: cachePusher,
67-
store: store,
68-
key: key,
69-
chunkSpan: ret.ChunkSpan,
70-
numChunks: ret.NumChunks,
71-
chunks: make([]*chunk.Chunk, 0, ret.NumChunks),
72-
dropFirstChunk: dropFirstChunk,
73-
ingestFromNextChunkT0: ingestFromNextChunkT0,
74-
ttl: uint32(ret.MaxRetention()),
66+
cachePusher: cachePusher,
67+
store: store,
68+
key: key,
69+
chunkSpan: ret.ChunkSpan,
70+
numChunks: ret.NumChunks,
71+
chunks: make([]*chunk.Chunk, 0, ret.NumChunks),
72+
dropFirstChunk: dropFirstChunk,
73+
ingestFromT0: ingestFromT0,
74+
ttl: uint32(ret.MaxRetention()),
7575
// we set LastWrite here to make sure a new Chunk doesn't get immediately
7676
// garbage collected right after creating it, before we can push to it.
7777
lastWrite: uint32(time.Now().Unix()),
@@ -432,10 +432,10 @@ func (a *AggMetric) persist(pos int) {
432432

433433
// don't ever call with a ts of 0, cause we use 0 to mean not initialized!
434434
func (a *AggMetric) Add(ts uint32, val float64) {
435-
if ts < a.ingestFromNextChunkT0 {
435+
if ts < a.ingestFromT0 {
436436
// TODO: add metric to keep track of the # of points discarded
437437
if log.IsLevelEnabled(log.DebugLevel) {
438-
log.Debugf("AM: discarding metric <%d,%f>: does not belong to a chunk starting after ingest-from. First chunk considered starts at %d", ts, val, a.ingestFromNextChunkT0)
438+
log.Debugf("AM: discarding metric <%d,%f>: does not belong to a chunk starting after ingest-from. First chunk considered starts at %d", ts, val, a.ingestFromT0)
439439
}
440440
return
441441
}

0 commit comments

Comments
 (0)
This repository has been archived.