Commit fe823e9c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 399f16c9
// XXX license
// filestorage support XXX text
package neo
type FileStorage struct {
fd int
}
// IStorage
var _ IStorage = (*FileStorage)(nil)
type TxnRecHead struct {
Tid Tid
RecLenm8 uint64
Status TxnStatus
//UserLen uint16
//DescriptionLen uint16
//ExtensionLen uint16
User []byte // TODO Encode ^^^
Description []byte
Extension []byte
Datav []DataRec
}
type DataRec struct {
Oid Oid
Tid Tid
PrevDataRecPos uint64 // previous-record file-position
TxnPos uint64 // beginning of transaction record file position
// 2-bytes with zero values. (Was version length.)
//DataLen uint64
Data []byte
DataRecPos uint64 // if Data == nil -> byte position of data record containing data
}
func (TxnRecHead *rh) MarshalFS() []byte {
panic("TODO")
}
func (TxnRecHead *rh) UnmarshalFS(data []byte) {
TODO
}
func NewFileStorage(path string) (*FileStorage, error) {
fd, err := ...Open(path, O_RDONLY)
if err != nil {
return nil, err
}
// TODO read file header
Read(fd, 4) != "FS21" -> invalid header
return &FileStorage{fd: fd}
}
func (f *FileStorage) Close() error {
err := Os.Close(f.fd)
if err != nil {
return err
}
f.fd = -1
return nil
}
func (f *FileStorage) Iterate(start, stop Tid) IStorageIterator {
if start != TID0 || stop != TIDMAX {
panic("TODO start/stop support")
}
}
......@@ -74,21 +74,6 @@ const (
GRANTED_TO_OTHER
)
// XXX move out of here ?
type TID uint64 // XXX or [8]byte ?
type OID uint64 // XXX or [8]byte ?
const (
INVALID_UUID UUID = 0
INVALID_TID TID = 0xffffffffffffffff // 1<<64 - 1
INVALID_OID OID = 0xffffffffffffffff // 1<<64 - 1
ZERO_TID TID = 0 // XXX or simply TID{} ?
ZERO_OID OID = 0 // XXX or simply OID{} ?
// OID_LEN = 8
// TID_LEN = 8
MAX_TID TID = 0x7fffffffffffffff // SQLite does not accept numbers above 2^63-1
)
// An UUID (node identifier, 4-bytes signed integer)
type UUID int32
......
// XXX license
// ZODB types
package neo // XXX -> zodb ?
// XXX naming -> TID, OID ?
type Tid uint64 // XXX or [8]byte ?
type Oid uint64 // XXX or [8]byte ?
// XXX "extended" oid - oid + serial, completely specifying object revision
type Xid struct {
Tid
Oid
}
const (
INVALID_UUID UUID = 0
INVALID_TID TID = 0xffffffffffffffff // 1<<64 - 1
INVALID_OID OID = 0xffffffffffffffff // 1<<64 - 1
ZERO_TID TID = 0 // XXX or simply TID{} ? // XXX -> TID0 ?
ZERO_OID OID = 0 // XXX or simply OID{} ? // XXX -> OID0
// OID_LEN = 8
// TID_LEN = 8
MAX_TID TID = 0x7fffffffffffffff // SQLite does not accept numbers above 2^63-1 // XXX -> TIDMAX ?
)
type TxnStatus byte
// TODO Tid.String(), Oid.String() +verbose, scanning (?)
// Information about single storage transaction
// XXX -> storage.ITransactionInformation
//type IStorageTransactionInformation interface {
type IStorageTransactionInformation struct {
Tid Tid
Status TxnStatus
User []byte
Description []byte
Extension []byte
// TODO iter -> IStorageRecordInformation
Iter() IStorageRecordIterator
}
// Information about single storage record
type StorageRecordInformation struct {
Oid Oid
Tid Tid
Data []byte
// XXX .version ?
// XXX .data_txn (The previous transaction id)
}
type IStorage interface {
Close() error
// TODO:
// Name()
// History(oid, size=1)
// LastTid()
// LoadBefore(oid Oid, beforeTid Tid) (data []bytes, tid Tid, err error)
// LoadSerial(oid Oid, serial Tid) (data []bytes, err error)
// PrefetchBefore(oidv []Oid, beforeTid Tid) error (?)
// Store(oid Oid, serial Tid, data []byte, txn ITransaction) error
// XXX Restore ?
// CheckCurrentSerialInTransaction(oid Oid, serial Tid, txn ITransaction) // XXX naming
// tpc_begin(txn)
// tpc_vote(txn)
// tpc_finish(txn, callback) XXX clarify about callback
// tpc_abort(txn)
Iterate(start, stop Tid) IStorageIterator // XXX -> Iter() ?
}
type IStorageIterator interface {
Next() (*StorageTransactionInformation, error) // XXX -> NextTxn() ?
}
type IStorageRecordIterator interface { // XXX naming -> IRecordIterator
Next() (*StorageRecordInformation, error) // XXX vs ptr & nil ?
// XXX -> NextTxnObject() ?
}
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