This repository was archived by the owner on Aug 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 177
Add ChunksIterator method to Series interface. #665
Open
bwplotka
wants to merge
10
commits into
master
Choose a base branch
from
add-chunks-to-queriers-iterator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
64eeed9
Add ChunksIterator method to Series interface.
tomwilkie 4ed00e1
Added commentary.
bwplotka d097d3f
Return not implemented error on vertical iterators for not used chunk…
bwplotka c407499
Added simple `verticalMergeChunkIterator` implementation - no tests s…
bwplotka af8fb41
Added Seek to Chunk/ChunkIterator interfaces.
bwplotka 6f6dd39
Reusing same vertical merging strategy in both compact and querier.
bwplotka 78e9e36
Reused same interface in chunkenc.
bwplotka f09fb89
Fixed CHANGELOG.
bwplotka 220c3dd
Added tests to xor iterator seek.
bwplotka b84c439
Refactored TestSeriesIterator.
bwplotka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,19 @@ type Series interface { | |
| ChunkIterator() ChunkIterator | ||
| } | ||
|
|
||
| // ChunkIterator iterates over the chunk of a time series. | ||
| type ChunkIterator interface { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved to be near |
||
| // Seek advances the iterator forward to the given timestamp. | ||
| // It advances to the chunk with min time at t or first chunk with min time after t. | ||
| Seek(t int64) bool | ||
| // At returns the meta. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "current value". This makes it sounds like it's dropping memes :) |
||
| At() chunks.Meta | ||
| // Next advances the iterator by one. | ||
| Next() bool | ||
| // Err returns optional error if Next is false. | ||
| Err() error | ||
| } | ||
|
|
||
| // querier aggregates querying results from time blocks within | ||
| // a single partition. | ||
| type querier struct { | ||
|
|
@@ -942,7 +955,7 @@ func (it *chainedSeriesIterator) Next() bool { | |
| if it.cur.Next() { | ||
| return true | ||
| } | ||
| if err := it.cur.Err(); err != nil { | ||
| if it.cur.Err() != nil { | ||
| return false | ||
| } | ||
| if it.i == len(it.series)-1 { | ||
|
|
@@ -1007,6 +1020,10 @@ func newVerticalMergeSeriesIterator(s ...Series) chunkenc.Iterator { | |
| } | ||
|
|
||
| func (it *verticalMergeSeriesIterator) Seek(t int64) bool { | ||
| if it.initialized && it.curT >= t { | ||
| return true | ||
| } | ||
|
|
||
| it.aok, it.bok = it.a.Seek(t), it.b.Seek(t) | ||
| it.initialized = true | ||
| return it.Next() | ||
|
|
@@ -1157,7 +1174,7 @@ func mergeOverlappingChunks(a, b chunks.Meta, aReuseIter, bReuseIter chunkenc.It | |
| } | ||
|
|
||
| mint := int64(math.MaxInt64) | ||
| maxt := int64(0) | ||
| maxt := int64(math.MinInt64) | ||
|
|
||
| // TODO: This can end up being up to 240 samples per chunk, so we need to have a case to split to two. | ||
bwplotka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for seriesIter.Next() { | ||
|
|
@@ -1243,38 +1260,51 @@ func (it *chunkSeriesIterator) resetCurIterator() { | |
| it.cur = it.bufDelIter | ||
| } | ||
|
|
||
| func (it *chunkSeriesIterator) Seek(t int64) (ok bool) { | ||
| if t > it.maxt { | ||
| func (it *chunkSeriesIterator) Seek(t int64) bool { | ||
| if it.Err() != nil || t > it.maxt || it.i > len(it.chunks)-1 { | ||
krasi-georgiev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Exhaust iterator. | ||
| it.i = len(it.chunks) | ||
| return false | ||
| } | ||
|
|
||
| // Seek to the first valid value after t. | ||
| if t < it.mint { | ||
| t = it.mint | ||
| } | ||
|
|
||
| currI := it.i | ||
| for ; it.chunks[it.i].MaxTime < t; it.i++ { | ||
| if it.i == len(it.chunks)-1 { | ||
| // Exhaust iterator. | ||
| it.i = len(it.chunks) | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| it.resetCurIterator() | ||
| if currI != it.i { | ||
| it.resetCurIterator() | ||
| } | ||
|
|
||
| for it.cur.Next() { | ||
| t0, _ := it.cur.At() | ||
| if t0 >= t { | ||
| return true | ||
| tc, _ := it.cur.At() | ||
| for t > tc { | ||
| if !it.cur.Next() { | ||
| // Exhaust iterator. | ||
| it.i = len(it.chunks) | ||
| return false | ||
| } | ||
| tc, _ = it.cur.At() | ||
| } | ||
| return false | ||
| return true | ||
| } | ||
|
|
||
| func (it *chunkSeriesIterator) At() (t int64, v float64) { | ||
| return it.cur.At() | ||
| } | ||
|
|
||
| func (it *chunkSeriesIterator) Next() bool { | ||
| if it.Err() != nil || it.i > len(it.chunks)-1 { | ||
| return false | ||
| } | ||
|
|
||
| if it.cur.Next() { | ||
| t, _ := it.cur.At() | ||
|
|
||
|
|
@@ -1369,19 +1399,6 @@ func (s errSeriesSet) Next() bool { return false } | |
| func (s errSeriesSet) At() Series { return nil } | ||
| func (s errSeriesSet) Err() error { return s.err } | ||
|
|
||
| // ChunkIterator iterates over the chunk of a time series. | ||
| type ChunkIterator interface { | ||
| // Seek advances the iterator forward to the given timestamp. | ||
| // It advances to the chunk with min time at t or first chunk with min time after t. | ||
| Seek(t int64) bool | ||
| // At returns the meta. | ||
| At() chunks.Meta | ||
| // Next advances the iterator by one. | ||
| Next() bool | ||
| // Err returns optional error if Next is false. | ||
| Err() error | ||
| } | ||
|
|
||
| type chunkIterator struct { | ||
| chunks []chunks.Meta // series in time order | ||
| i int | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.