update readme & add header_test sample cmd
This commit is contained in:
parent
a5e92623ce
commit
094afdb15a
3 changed files with 30 additions and 2 deletions
|
@ -1,3 +1,3 @@
|
|||
# Project in progress.
|
||||
|
||||
[Click here for more](https://zutto.fi/posts/data-structure/)
|
||||
[Click here for more](https://zutto.fi/posts/db/headers/)
|
||||
|
|
27
cmd/samples/header_encode.go
Normal file
27
cmd/samples/header_encode.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
|
||||
"git.zutto.fi/zutto/db/pkg/headers"
|
||||
)
|
||||
|
||||
func main() {
|
||||
h := headers.Headers{
|
||||
HeaderString: []byte(headers.HeaderString),
|
||||
PageSize: uint64(256 ^ 2),
|
||||
DBVersion: uint16(1),
|
||||
|
||||
WAL: false,
|
||||
Commit: make([]byte, headers.CommitDataLength),
|
||||
}
|
||||
|
||||
//generate random string for the commit..
|
||||
_, err := rand.Read(h.Commit[:headers.CommitDataLength])
|
||||
if err != nil {
|
||||
fmt.Errorf("Failed to generate random string")
|
||||
}
|
||||
|
||||
fmt.Printf("%c", h.Generate())
|
||||
}
|
|
@ -2,6 +2,7 @@ package headers
|
|||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
@ -23,7 +24,7 @@ func TestHeaders_Generate(t *testing.T) {
|
|||
}
|
||||
|
||||
output := h.Generate()
|
||||
|
||||
fmt.Printf("%c", output)
|
||||
h2 := Headers{}
|
||||
h2.Parse(output, 0)
|
||||
|
||||
|
|
Loading…
Reference in a new issue