package
0.0.0-20240429090853-b1246d0e0032
Repository: https://github.com/chettriyuvraj/leveldb-clone.git
Documentation: pkg.go.dev

# README

README

This is a directory to test the goleveldb package - e.g. creating db and examining files, running goleveldb against the test suite / benchmarks created for our implementation, etc

Benchmarks

  • goleveldb performance on benchmarks relative to my implementation(s) (refer to sample_test.go)
    • naive implementation alt text
    • skip list implementation alt text
    • goleveldb alt text

File Format

.log file

  • The .log format for goleveldb holds true to what is described in leveldb's official docs, however there are a few things to note

  • For reference, this is the format for each record in .log file:

        block := record* trailer?
    record :=
    checksum: uint32     // crc32c of type and data[] ; little-endian
    length: uint16       // little-endian
    type: uint8          // One of FULL, FIRST, MIDDLE, LAST
    data: uint8[length]
    
  • Using the function testDBWithLittleData to generate the .log file, we examine it as follows:

    • The first 4 bytes are checksum: 8c 5b
    • Next 2 bytes represents the length in little-endian: 1b 00 to be read as 00 1b = 27 bytes
    • Next 1 byte is the type: 01 which is full
    • Since the length is 27 bytes, the next 27 bytes equals the data: If you count 27 bytes, they will end exactly at the last byte of trash:dustbin
    • Note: There are a lot of empty blocks in the 27 bytes of data, this is what surprised me. I am not sure if leveldb does the exact same thing.

alt text

  • TODO: the docs mention a certain recordio format, what is that?