From 15b2bef41569c846a8a8209b1b840e75595e24f0 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 15 Jan 2019 23:55:32 +0100 Subject: add interface --- internal/btree/btree.go | 42 ++++++++++++++++++++++++++++++++++++++++-- internal/hash/hash.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ internal/hash/hash_def.go | 5 ----- internal/recno/rec.go | 1 - internal/recno/recno.go | 39 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+), 8 deletions(-) create mode 100644 internal/hash/hash.go delete mode 100644 internal/recno/rec.go create mode 100644 internal/recno/recno.go diff --git a/internal/btree/btree.go b/internal/btree/btree.go index 0681aa0..9936325 100644 --- a/internal/btree/btree.go +++ b/internal/btree/btree.go @@ -1,6 +1,44 @@ package btree +import "os" + const ( - btreeMagic = 0x053162 - btreeVersion = 3 + Magic = 0x053162 + Version = 3 ) + +type BTree struct { + file *os.File +} + +func New(file *os.File) *BTree { + return &BTree{file: file} +} + +func (b *BTree) Close() error { + return b.file.Close() +} + +func (b *BTree) Del(key []byte, flags uint) error { + panic("not implemented") +} + +func (b *BTree) Fd() uintptr { + return b.file.Fd() +} + +func (b *BTree) Get(key []byte, flags uint) ([]byte, error) { + panic("not implemented") +} + +func (b *BTree) Put(key []byte, data []byte, flags uint) error { + panic("not implemented") +} + +func (b *BTree) Sync(flags uint) error { + panic("not implemented") +} + +func (b *BTree) Seq(key []byte, flags uint) ([]byte, error) { + panic("not implemented") +} diff --git a/internal/hash/hash.go b/internal/hash/hash.go new file mode 100644 index 0000000..4a718be --- /dev/null +++ b/internal/hash/hash.go @@ -0,0 +1,44 @@ +package hash + +import "os" + +const ( + Magic = 0x061561 + Version = 2 +) + +type Hash struct { + file *os.File +} + +func New(file *os.File) *Hash { + return &Hash{file: file} +} + +func (h *Hash) Close() error { + return h.file.Close() +} + +func (h *Hash) Del(key []byte, flags uint) error { + panic("not implemented") +} + +func (h *Hash) Fd() uintptr { + return h.file.Fd() +} + +func (h *Hash) Get(key []byte, flags uint) ([]byte, error) { + panic("not implemented") +} + +func (h *Hash) Put(key []byte, data []byte, flags uint) error { + panic("not implemented") +} + +func (h *Hash) Sync(flags uint) error { + panic("not implemented") +} + +func (h *Hash) Seq(key []byte, flags uint) ([]byte, error) { + panic("not implemented") +} diff --git a/internal/hash/hash_def.go b/internal/hash/hash_def.go index c159e78..f84edeb 100644 --- a/internal/hash/hash_def.go +++ b/internal/hash/hash_def.go @@ -76,8 +76,3 @@ type HashHdr struct { Spares [nCached]int32 // spare pages for overflow Bitmaps [nCached]uint16 // address of overflow page bitmaps } - -const ( - hashMagic = 0x061561 - hashVersion = 2 -) diff --git a/internal/recno/rec.go b/internal/recno/rec.go deleted file mode 100644 index 57f331a..0000000 --- a/internal/recno/rec.go +++ /dev/null @@ -1 +0,0 @@ -package recno diff --git a/internal/recno/recno.go b/internal/recno/recno.go new file mode 100644 index 0000000..07a2050 --- /dev/null +++ b/internal/recno/recno.go @@ -0,0 +1,39 @@ +package recno + +import "os" + +type RecNo struct { + file *os.File +} + +func New(file *os.File) *RecNo { + return &RecNo{file: file} +} + +func (r *RecNo) Close() error { + return r.file.Close() +} + +func (r *RecNo) Del(key []byte, flags uint) error { + panic("not implemented") +} + +func (r *RecNo) Fd() uintptr { + return r.file.Fd() +} + +func (r *RecNo) Get(key []byte, flags uint) ([]byte, error) { + panic("not implemented") +} + +func (r *RecNo) Put(key []byte, data []byte, flags uint) error { + panic("not implemented") +} + +func (r *RecNo) Sync(flags uint) error { + panic("not implemented") +} + +func (r *RecNo) Seq(key []byte, flags uint) ([]byte, error) { + panic("not implemented") +} -- cgit v1.2.3