Commit 8c736e77 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent fa68b9e4
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
package main package main
import ( import (
"../../storage" // XXX rel ok? _ "../../storage" // XXX rel ok?
) )
......
This diff is collapsed.
...@@ -3,8 +3,13 @@ ...@@ -3,8 +3,13 @@
// filestorage support XXX text // filestorage support XXX text
package storage package storage
import (
"os"
. "../"
)
type FileStorage struct { type FileStorage struct {
fd int f *os.File // XXX naming -> file ?
} }
// IStorage // IStorage
...@@ -36,32 +41,32 @@ type DataRec struct { ...@@ -36,32 +41,32 @@ type DataRec struct {
} }
func (TxnRecHead *rh) MarshalFS() []byte { func (rh *TxnRecHead) MarshalFS() []byte {
panic("TODO") panic("TODO")
} }
func (TxnRecHead *rh) UnmarshalFS(data []byte) { func (rh *TxnRecHead) UnmarshalFS(data []byte) {
TODO //TODO
} }
func NewFileStorage(path string) (*FileStorage, error) { func NewFileStorage(path string) (*FileStorage, error) {
fd, err := ...Open(path, O_RDONLY) f, err := os.Open(path) // note opens in O_RDONLY
if err != nil { if err != nil {
return nil, err return nil, err
} }
// TODO read file header // TODO read file header
Read(fd, 4) != "FS21" -> invalid header //Read(f, 4) != "FS21" -> invalid header
return &FileStorage{fd: fd} return &FileStorage{f: f}, nil
} }
func (f *FileStorage) Close() error { func (f *FileStorage) Close() error {
err := Os.Close(f.fd) err := f.f.Close()
if err != nil { if err != nil {
return err return err
} }
f.fd = -1 f.f = nil
return nil return nil
} }
...@@ -70,5 +75,6 @@ func (f *FileStorage) Iterate(start, stop Tid) IStorageIterator { ...@@ -70,5 +75,6 @@ func (f *FileStorage) Iterate(start, stop Tid) IStorageIterator {
panic("TODO start/stop support") panic("TODO start/stop support")
} }
// TODO
return nil
} }
...@@ -18,10 +18,13 @@ const ( ...@@ -18,10 +18,13 @@ const (
INVALID_TID Tid = 1<<64 - 1 // 0xffffffffffffffff TODO recheck it is the same INVALID_TID Tid = 1<<64 - 1 // 0xffffffffffffffff TODO recheck it is the same
INVALID_OID Oid = 0xffffffffffffffff // 1<<64 - 1 INVALID_OID Oid = 0xffffffffffffffff // 1<<64 - 1
ZERO_TID Tid = 0 // XXX or simply TID{} ? // XXX -> TID0 ? ZERO_TID Tid = 0 // XXX or simply TID{} ? // XXX -> TID0 ?
TID0 Tid = ZERO_TID // XXX ^^^ choose 1
ZERO_OID Oid = 0 // XXX or simply OID{} ? // XXX -> OID0 ZERO_OID Oid = 0 // XXX or simply OID{} ? // XXX -> OID0
// OID_LEN = 8 // OID_LEN = 8
// TID_LEN = 8 // TID_LEN = 8
MAX_TID Tid = 0x7fffffffffffffff // SQLite does not accept numbers above 2^63-1 // XXX -> TIDMAX ? MAX_TID Tid = 0x7fffffffffffffff // SQLite does not accept numbers above 2^63-1 // XXX -> TIDMAX ?
TIDMAX Tid = MAX_TID // XXX ^^^ choose 1
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment