-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[b][basic] Add Endianness in primitive
- Loading branch information
Showing
10 changed files
with
119 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,8 @@ | ||
# Node rules: | ||
## Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
# IDE Start | ||
.idea | ||
.vscode | ||
# IDE End | ||
|
||
## Dependency directory | ||
## Commenting this out is preferred by some people, see | ||
## https://docs.npmjs.com/misc/faq#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
|
||
# Book build output | ||
_book | ||
|
||
# eBook build output | ||
*.epub | ||
*.mobi | ||
# Example Start | ||
*.out | ||
# Example End |
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,8 @@ | ||
# Abbreviation | ||
|
||
## TODO | ||
|
||
- [ ] support building index for abbreviation and point them to definition | ||
|
||
- MSB: Most Significant Byte | ||
- LSB: Least Significant Byte |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Chapter 02 Basic | ||
# Chapter 02: Basic | ||
|
||
- [Primitive Data Type](primitive) Representation of primitive type like integer, float, string. |
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 @@ | ||
# |
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,33 @@ | ||
/* | ||
* project: ntsdb | ||
* file: endianness.c | ||
* chapter: basic | ||
* section: primitive | ||
* description: show endianess of integer | ||
* compile: gcc endianess.c | ||
* run: ./a.out | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
// NOTE: based on CSAPP Figure 2.4 | ||
|
||
void show_bytes(unsigned char* start, size_t len) { | ||
for (int i = 0; i < len; i++) { | ||
printf(" %.2x", start[i]); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
void show_int(int x) { | ||
show_bytes((unsigned char*) &x, sizeof(x)); | ||
} | ||
|
||
int main() { | ||
// 01 04 00 00 | ||
// 1025 is 2^10+1, which is 0x0401, print starts from smaller memory address, 01 is LSB and prints before 04 | ||
show_int(1025); | ||
|
||
// 1024 2048 | ||
printf("%d %d\n", 0x0400, 0x0400 << 1); | ||
} |
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,23 @@ | ||
# Endianness | ||
|
||
- `byte` i.e. 8 bits is the atomic unit, endianness is for byte ordering. (for the scope in this book) | ||
- big-endian, save MSB (Most Significant Byte) in the smallest address | ||
- little-endian, save LSB (Least Significant Byte) in the smallest address | ||
- most processors are little endian | ||
- network order is big endian | ||
- numeric literal, left is MSB | ||
- bit shift, shift left shift towards MSB, e.g. `0x0400 << 1` is `0x0800` | ||
|
||
Example [code](code/endianness.c) | ||
|
||
`2^10+1` when written in literal is `100_0000_0001` or `0x0401` (hex), it requires two bytes | ||
|
||
```text | ||
memory address: 0 8 | ||
big-endian : 0000_0100 0000_0001 | ||
little-endian : 0000_0001 0000_0100 | ||
``` | ||
|
||
## Reference | ||
|
||
- https://en.wikipedia.org/wiki/Endianness |
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,5 @@ | ||
# Facebook Gorilla Compression | ||
|
||
## TODO | ||
|
||
- [ ] merge notes from libtsdb-go |
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 @@ | ||
# Chapter 01: Overview |
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,39 @@ | ||
# Time Series Database Survey | ||
|
||
This folder contains survey on implementation of various TSDBs. | ||
|
||
Required list in README | ||
|
||
- link to [awesome tsdb](https://github.com/xephonhq/awesome-time-series-database), which should contain basic meta data. | ||
- link to required files within the folder | ||
- a short overview | ||
- highlight in this database | ||
- design flaw/limitation | ||
|
||
Required files for describing each database. | ||
|
||
Code walk through | ||
|
||
- **read.md** Read path, link to source w/ commit hash. | ||
- **write.md** Write path, link to source w/ commit hash. | ||
|
||
API | ||
|
||
- **protocol.md** Wire protocol format and transport, mainly about write because many TSDB have dedicated query language. | ||
- **query-language.md** Query language. | ||
|
||
Internal | ||
|
||
- **model.md** General data model, what is a time series for this TSDB (yeah, this definition varies). | ||
- **compression.md** Compression related algorithm or code. | ||
- **query-execution.md** Query execution and optimization, especially for those with query language and distributed ones. | ||
- **storage-engine.md** Only applies to TSDB w/ their own storage format, i.e. write opaque blob to local fs or object store. | ||
- **schema.md** Only applies to TSDB w/ underlying database i.e. Cassandra, ElasticSearch | ||
- **distributed.md** Only applies to distributed TSDB, replication model, consensus protocol. Including those built on top of distributed data store i.e. Cassandra, S3. | ||
|
||
Operation | ||
|
||
- **build.md** How to build from source locally | ||
- **docker.md** How to run it using docker(-compose) locally | ||
- **config.md** Config file example, how to config the system (underlying database, operating system) properly | ||
- **k8s.md** How to run it on k8s, operator and special things about their operator e.g. local volume |