Skip to content

Commit 637291d

Browse files
committed
FIX: typo in docs/metadata-design.md
1 parent b18c603 commit 637291d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/metadata-design.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Design Complex Structure On Rocksdb
22

3-
kvrocks use the rocksdb as storage, it's developed by facebook which built on LevelDB with many extra features supports, like column family, transaction, backup, see the rocksdb wiki: [Features Not In LevelDB](https://github.com/facebook/rocksdb/wiki/Features-Not-in-LevelDB). the basic operations in rocksdb are `Put(key, value)`, `Get(key)`, `Delete(key)`, other complex structures weren't supported. the main goal of this doc would explain how we built the Redis hash/list/set/zset/bitmap on rocksdb. most of the design was derived from Qihoo360 `Blackwidow`, but with little modified, like the bitmap design, it's really interesting part.
3+
kvrocks use the rocksdb as storage, it's developed by facebook which built on LevelDB with many extra features supports, like column family, transaction, backup, see the rocksdb wiki: [Features Not In LevelDB](https://github.com/facebook/rocksdb/wiki/Features-Not-in-LevelDB). the basic operations in rocksdb are `Put(key, value)`, `Get(key)`, `Delete(key)`, other complex structures weren't supported. the main goal of this doc would explain how we built the Redis hash/list/set/zset/bitmap on rocksdb. most of the design was derived from Qihoo360 `Blackwidow`, but with little modified, like the bitmap design, it's a really interesting part.
44

55
## String
66

@@ -35,7 +35,7 @@ key => | flags | expire | version | size |
3535
the value of key we call it metadata here, it stored the metadata of hash key includes:
3636

3737
- `flags` like the string, the field was used to tell which type of this key
38-
- `expire ` is same with string type, record the expire time
38+
- `expire ` is same as the string type, record the expire time
3939
- `version` is used to accomplish fast delete when the number of sub keys/values grew bigger
4040
- `size` records the number sub of keys/values in this hash key
4141

@@ -49,23 +49,23 @@ key|version|field => | value |
4949
+---------------+
5050
```
5151

52-
we prepend the hash `key` and `version` before the hash field, the value of `version` was from the metdata. for exmple, when request `hget h1 f1` was received, kvrocks would fetch the metadata by hash key(here is `h1`) first, and concat the hash key, version, field as new key, then fetch the value with new key.
52+
we prepend the hash `key` and `version` before the hash field, the value of `version` was from the metadata. for example, when the request `hget h1 f1` was received, kvrocks would fetch the metadata by hash key(here is `h1`) first, and concat the hash key, version, field as new key, then fetch the value with new key.
5353

5454

5555

56-
***Question1: why store version in metadata***
56+
***Question1: why store version in the metadata***
5757

5858
> we store the hash keys/values into single key-value, if the store millions of sub keys-values in one hash key . if user delete this key, the kvrocks must iterator millions of sub keys-values and delete, and it would cause performance problem. with version we can fast delete the metadata and then recycle the others keys-values in compaction background threads. the cost is those tombstone key would take some disk stroage. you can regard the version as atomic increment number, but it's combined with timestamp.
5959
6060

6161

62-
***Question2: what can we do if the user key was conflicted with composed key?***
62+
***Question2: what can we do if the user key was conflicted with the composed key?***
6363

6464
> we store the metadata key and composed key in different column families, so it wouldn't happend
6565
6666
## Set
6767

68-
Redis set can be regared as hash with value of sub-key always be null, the metadata was same with the hash:
68+
Redis set can be regarded as a hash, with the value of sub-key always be null, the metadata was same with the hash:
6969

7070
```shell
7171
+----------+------------+-----------+-----------+
@@ -86,7 +86,7 @@ key|version|member => | NULL |
8686

8787
#### list metadata
8888

89-
Redis list also organized by metadata and sub keys-values, and sub key is index instead of user key. metadata like below:
89+
Redis list also organized by metadata and sub keys-values, and sub key is index instead of the user key. metadata like below:
9090

9191
```shell
9292
+----------+------------+-----------+-----------+-----------+-----------+
@@ -95,14 +95,14 @@ key => | flags | expire | version | size | head | tail
9595
+----------+------------+-----------+-----------+-----------+-----------+
9696
```
9797

98-
- `head` was used to indicate the start position of list head
99-
- `tail` was used to indicate the stop position of list tail
98+
- `head` was used to indicate the start position of the list head
99+
- `tail` was used to indicate the stop position of the list tail
100100

101-
the meaning of other fields were same with other types, just add extra head/tail to record the boundary of list.
101+
the meaning of other fields was the same as other types, just add extra head/tail to record the boundary of the list.
102102

103103
#### list sub keys-values
104104

105-
the sub key in list was compsed by list key,version,index, and index was calculated from metadata's head or tail. for example, when user request the `rpush list elem`, kvrocks would fetch fetch the metadata with list key first, and generate the sub key with list key, version, and tail, simply increase the tail, then write the medata and sub key value back to rocksdb.
105+
the subkey in list was composed by list key, version, index, index was calculated from metadata's head or tail. for example, when the user requests the `rpush list elem`, kvrocks would fetch the metadata with list key first, and generate the subkey with list key, version, and tail, simply increase the tail, then write the metadata and subkey's value back to rocksdb.
106106

107107
```shell
108108
+---------------+
@@ -112,7 +112,7 @@ key|version|index => | value |
112112

113113
## ZSet
114114

115-
Redis zset was set with sorted property, so it's a little different with other types. it must be able to search with member, as well as retrieve members with score range.
115+
Redis zset was set with sorted property, so it's a little different with other types. it must be able to search with the member, as well as retrieve members with score range.
116116

117117
#### zset metadata
118118

@@ -140,11 +140,11 @@ key|version|score|member => | NULL | (2)
140140

141141
```
142142

143-
if user want to get the score of member or check the member exists or not, it would try first one.
143+
if the user wants to get the score of the member or check the member exists or not, it would try first one.
144144

145145
## Bitmap
146146

147-
Redis bitmap is the most interesting part in kvrocks design, while unlike other types, it's not subkey and the value would be very large if the user treats it as a sparse array. it's apparent that the things would break down if store the bitmap into a single value, so we should break the bitmap value into multi fragments. another behavior of bitmap is the position would write always arbitrary, it's very similar to access model of Linux virtual memory, so the idea of the bitmap design came from that.
147+
Redis bitmap is the most interesting part in kvrocks design, while unlike other types, it's not subkey and the value would be very large if the user treats it as a sparse array. it's apparent that the things would break down if store the bitmap into a single value, so we should break the bitmap value into multi fragments. another behavior of bitmap is the position would write always arbitrary, it's very similar to the access model of Linux virtual memory, so the idea of the bitmap design came from that.
148148

149149
#### bitmap metadata
150150

0 commit comments

Comments
 (0)