This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce and default to a second chunk format including chunkspan
By default all new chunks will be written in the new format. This means the second byte of the chunk specifies the chunkspan. We chose to use a lookup table because: - Using a log2 notation to define the chunk size would optimize for space, but it makes us have to deal with awkward numbers. - Writing down a static multiple of seconds would result in a relatively narrow range of chunk lengths that could be represented. Using the lookup table combines the advantages of the two above solutions while excluding the disadvantages.
- Loading branch information
Showing
12 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package chunk | ||
|
||
type SpanCode uint8 | ||
|
||
const min = 60 | ||
const hour = 60 * min | ||
|
||
var ChunkSpans = [32]uint32{ | ||
1, | ||
5, | ||
10, | ||
15, | ||
20, | ||
30, | ||
60, // 1m | ||
90, // 1.5m | ||
2 * 60, // 2m | ||
3 * 60, // 3m | ||
5 * 60, // 5m | ||
10 * 60, // 10m | ||
15 * 60, // 15m | ||
20 * 60, // 20m | ||
30 * 60, // 30m | ||
45 * 60, // 45m | ||
3600, // 1h | ||
90 * 60, // 1.5h | ||
2 * 3600, // 2h | ||
150 * 60, // 2.5h | ||
3 * 3600, // 3h | ||
4 * 3600, // 4h | ||
5 * 3600, // 5h | ||
6 * 3600, // 6h | ||
7 * 3600, // 7h | ||
8 * 3600, // 8h | ||
9 * 3600, // 9h | ||
10 * 3600, // 10h | ||
12 * 3600, // 12h | ||
15 * 3600, // 15h | ||
18 * 3600, // 18h | ||
24 * 3600, // 24h | ||
} | ||
|
||
var RevChunkSpans = make(map[uint32]SpanCode, len(ChunkSpans)) | ||
|
||
func init() { | ||
for k, v := range ChunkSpans { | ||
RevChunkSpans[v] = SpanCode(k) | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -20,4 +20,5 @@ type ChunkWriteRequest struct { | |
chunk *chunk.Chunk | ||
ttl uint32 | ||
timestamp time.Time | ||
span uint32 | ||
} |
This file contains 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 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 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 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 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