GitHub user PragmaTwice edited a comment on the discussion: TimeSeries Proposal

Looks good to me.

I'll try to propose a detailed design here.

encoding:
```
chunk size M (order of the "B-tree")

chunk_id: first timestamp in the chunk

user_key | CHUNK | chunk_id => count | ts1 | v1 | ... | tsN | vN
```

inserting algorithm (insert ts1, v1):
- search for the `chunk_id` (`chunk_id <= ts1 < next chunk_id`), `O(log N)`
- if it is the HEAD chunk:
  - just insert ts1, v1 into HEAD if `count < M - 1`
  - otherwise create a new chunk and insert ts1, v1
- else if `count < 2*M - 1`, then:
  - just insert ts1, v1 into this chunk
- else:
  - split this chunk into two chunks, by the middle ts in the chunk
  - insert ts1, v1 into one of these two chunks properly
 
cc @mapleFU 

GitHub link: 
https://github.com/apache/kvrocks/discussions/3044#discussioncomment-13728330

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to