Commit cf3fbe5b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent cb061733
This diff is collapsed.
// XXX license/copyright // Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 2, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// FileStorage v1. Tests XXX text
package fs1 package fs1
import ( import (
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
// See COPYING file for full licensing terms. // See COPYING file for full licensing terms.
// //
// XXX partly based on code from ZODB ? // XXX partly based on code from ZODB ?
// TODO link to format in zodb/py
// FileStorage v1. Index // FileStorage v1. Index
package fs1 package fs1
...@@ -33,8 +34,8 @@ import ( ...@@ -33,8 +34,8 @@ import (
"lab.nexedi.com/kirr/go123/mem" "lab.nexedi.com/kirr/go123/mem"
) )
// fsIndex is Oid -> Tid's position mapping used to associate Oid with latest // fsIndex is Oid -> Data record position mapping used to associate Oid with
// transaction which changed it. // Data record in latest transaction which changed it. XXX text
type fsIndex struct { type fsIndex struct {
*fsb.Tree *fsb.Tree
} }
......
...@@ -36,6 +36,15 @@ const ( ...@@ -36,6 +36,15 @@ const (
//Oid0 Oid = 0 // XXX -> simply Oid(0) //Oid0 Oid = 0 // XXX -> simply Oid(0)
) )
func (tid Tid) Valid() bool {
// XXX if Tid becomes signed also check wrt 0
if tid <= TidMax {
return true
} else {
return false
}
}
func (tid Tid) String() string { func (tid Tid) String() string {
// XXX also print "tid:" prefix ? // XXX also print "tid:" prefix ?
return fmt.Sprintf("%016x", uint64(tid)) return fmt.Sprintf("%016x", uint64(tid))
...@@ -97,6 +106,17 @@ const ( ...@@ -97,6 +106,17 @@ const (
TxnInprogress = 'c' // checkpoint -- a transaction in progress; it's been thru vote() but not finish() TxnInprogress = 'c' // checkpoint -- a transaction in progress; it's been thru vote() but not finish()
) )
// Valid returns true if transaction status value is well-known and valid
func (ts TxnStatus) Valid() bool {
switch ts {
case TxnComplete, TxnPacked, TxnInprogress:
return true
default:
return false
}
}
// Metadata information about single transaction // Metadata information about single transaction
type TxnInfo struct { type TxnInfo struct {
Tid Tid Tid Tid
...@@ -154,12 +174,12 @@ type IStorageIterator interface { ...@@ -154,12 +174,12 @@ type IStorageIterator interface {
// NextTxn yields information about next database transaction: // NextTxn yields information about next database transaction:
// 1. transaction metadata, and // 1. transaction metadata, and
// 2. iterator over transaction data records. // 2. iterator over transaction data records.
// transaction mentadata is put into *txnInfo stays valid until next call to NextTxn(). // transaction metadata is put into *txnInfo and stays valid until next call to NextTxn().
NextTxn(txnInfo *TxnInfo) (dataIter IStorageRecordIterator, stop bool, err error) // XXX stop -> io.EOF ? NextTxn(txnInfo *TxnInfo) (dataIter IStorageRecordIterator, stop bool, err error) // XXX stop -> io.EOF ?
} }
type IStorageRecordIterator interface { // XXX naming -> IRecordIterator type IStorageRecordIterator interface { // XXX naming -> IRecordIterator
// NextData puts information about next storage data record into *dataInfo. // NextData puts information about next storage data record into *dataInfo.
// data put into *dataInfo stays vaild until next call to NextData(). // data put into *dataInfo stays valid until next call to NextData().
NextData(dataInfo *StorageRecordInformation) (stop bool, err error) // XXX stop -> io.EOF ? NextData(dataInfo *StorageRecordInformation) (stop bool, err error) // XXX stop -> io.EOF ?
} }
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