aboutsummaryrefslogtreecommitdiff
path: root/hash
diff options
context:
space:
mode:
Diffstat (limited to 'hash')
-rw-r--r--hash/hash.go36
-rw-r--r--hash/hash_test.go8
2 files changed, 24 insertions, 20 deletions
diff --git a/hash/hash.go b/hash/hash.go
index 861dd90..3d6392a 100644
--- a/hash/hash.go
+++ b/hash/hash.go
@@ -1,10 +1,14 @@
package hash
-import "os"
+import (
+ "os"
+
+ "dim13.org/db"
+)
const (
- Magic = 0x061561
- Version = 2
+ magic = 0x061561
+ version = 2
)
type Hash struct {
@@ -16,37 +20,37 @@ type Hash struct {
Hash func([]byte) uint32 // user defined hash function
}
-func New(file *os.File) *Hash {
+func New(file *os.File) db.DB {
return &Hash{
file: file,
Hash: defaultHash,
}
}
-func (h *Hash) Close() error {
+func (h *Hash) Close() (err error) {
return h.file.Close()
}
-func (h *Hash) Del(key []byte, flags uint) error {
- panic("not implemented")
+func (h *Hash) Del(key []byte, flag uint) (err error) {
+ panic("not implemented") // TODO: Implement
}
-func (h *Hash) Fd() uintptr {
+func (h *Hash) Fd() (fd uintptr) {
return h.file.Fd()
}
-func (h *Hash) Get(key []byte, flags uint) ([]byte, error) {
- panic("not implemented")
+func (h *Hash) Get(key []byte, flag uint) (data []byte, err error) {
+ panic("not implemented") // TODO: Implement
}
-func (h *Hash) Put(key []byte, data []byte, flags uint) error {
- panic("not implemented")
+func (h *Hash) Put(key []byte, data []byte, flag uint) (err error) {
+ panic("not implemented") // TODO: Implement
}
-func (h *Hash) Sync(flags uint) error {
- panic("not implemented")
+func (h *Hash) Sync(flag uint) (err error) {
+ panic("not implemented") // TODO: Implement
}
-func (h *Hash) Seq(key []byte, flags uint) ([]byte, error) {
- panic("not implemented")
+func (h *Hash) Seq(flag uint) (key []byte, data []byte, err error) {
+ panic("not implemented") // TODO: Implement
}
diff --git a/hash/hash_test.go b/hash/hash_test.go
index da3a4a6..66eca95 100644
--- a/hash/hash_test.go
+++ b/hash/hash_test.go
@@ -16,11 +16,11 @@ func TestOpen(t *testing.T) {
if err := binary.Read(fd, binary.BigEndian, &hdr); err != nil {
t.Fatal(err)
}
- if hdr.Magic != Magic {
- t.Errorf("got %x, want %x", hdr.Magic, Magic)
+ if hdr.Magic != magic {
+ t.Errorf("got %x, want %x", hdr.Magic, magic)
}
- if hdr.Version != Version {
- t.Errorf("got %x, want %x", hdr.Version, Version)
+ if hdr.Version != version {
+ t.Errorf("got %x, want %x", hdr.Version, version)
}
t.Logf("%+v", hdr)
}