Installing Ruby
brew update
brew install rbenv ruby-build
rbenv install 3.2.2
rbenv global 3.2.2
Add the following to your .zshrc
file - use code ~/.zshrc
to open in VSCode
eval "$(rbenv init -)"
export PATH="$HOME/.gem/ruby/3.2.0/bin:$PATH"
Then refresh via source ~/.zshrc
Install Bundler if needed
gem install bundler --user-install
Installing RSpec if needed
gem install rspec --user-install
Architecture of SQLite:
- Virtual Machine: takes bytecode generated by the front-end as instructions
- Can perform operations on one or more tables or indexes
- Basically a big
switch
statement on the type of bytecode instruction
- Pager: receives commands to read/write pages of data
- Persistence to disk: we can save the database to a file and read it back out again
- Done via a pager, which asks for page number x, and the pager gives us back a block of memory
- First, it looks in its cache and on a cache miss, it copies data from disk into memory
- When the user closes the connection to the db, we flush the cache to disk, close the DB file, and free the memory for Pager/Table data structures
- Cursor: represents a location in the table
- B-Tree: Data structure that represents both tables and indexes
- Each node corresponds to one page, even if it's not full, so no need to handle for partial pages
- Order: each node can have up to m children, where m is the tree's "order"
void *memcpy(void *dest, const void *src, size_t n);
- Copies exactly
n
bytes, regardless of the data or content. - Does not stop at null characters (
'\0'
). - Often used for binary data, structs, or raw memory.
- No null-termination logic.
char *strncpy(char *dest, const char *src, size_t n);
- Copies a null-terminated string with a size limit.
- Copies up to
n
characters or until a'\0'
is encountered insrc
. - If
src
is shorter thann
, the rest of dest is padded with'\0'
. - If
src
is longer than or equal ton
, the result is not null-terminated — this is a common gotcha.
When including #include <stdint.h>
, we have:
uint8_t
→ unsigned 8-bit integeruint16_t
→ unsigned 16-bit integeruint32_t
→ unsigned 32-bit integeruint64_t
→ unsigned 64-bit integer