本文整理匯總了Golang中camlistore/org/third_party/github.com/cznic/exp/lldb.Filer類的典型用法代碼示例。如果您正苦於以下問題:Golang Filer類的具體用法?Golang Filer怎麽用?Golang Filer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Filer類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: acidFiler
func (o *Options) acidFiler(db *DB, f lldb.Filer) (r lldb.Filer, err error) {
switch o.ACID {
default:
panic("internal error")
case ACIDNone:
r = f
case ACIDTransactions:
var rf *lldb.RollbackFiler
if rf, err = lldb.NewRollbackFiler(
f,
func(sz int64) error {
return f.Truncate(sz)
},
f,
); err != nil {
return
}
db.xact = true
r = rf
case ACIDFull:
if r, err = lldb.NewACIDFiler(f, o.wal); err != nil {
return
}
db.acidState = stIdle
db.gracePeriod = o.GracePeriod
db.xact = true
if o.GracePeriod == 0 {
db.acidState = stDisabled
break
}
// Ensure GOMAXPROCS > 1, required for ACID FSM
if n := runtime.GOMAXPROCS(0); n > 1 {
return
}
runtime.GOMAXPROCS(2)
}
return
}
示例2: create
func create(f *os.File, filer lldb.Filer, opts *Options, isMem bool) (db *DB, err error) {
defer func() {
lock := opts.lock
if err != nil && lock != nil {
lock.Close()
db = nil
}
}()
if err = opts.check(filer.Name(), true, !isMem); err != nil {
return
}
b := [16]byte{byte(magic[0]), byte(magic[1]), byte(magic[2]), byte(magic[3]), 0x00} // ver 0x00
if n, err := filer.WriteAt(b[:], 0); n != 16 {
return nil, &os.PathError{Op: "kv.create.WriteAt", Path: filer.Name(), Err: err}
}
db = &DB{f: f, lock: opts.lock}
if filer, err = opts.acidFiler(db, filer); err != nil {
return nil, err
}
db.filer = filer
if err = filer.BeginUpdate(); err != nil {
return
}
defer func() {
if e := filer.EndUpdate(); e != nil {
if err == nil {
err = e
}
}
}()
if db.alloc, err = lldb.NewAllocator(lldb.NewInnerFiler(filer, 16), &lldb.Options{}); err != nil {
return nil, &os.PathError{Op: "kv.create", Path: filer.Name(), Err: err}
}
db.alloc.Compress = true
db.isMem = isMem
var h int64
if db.root, h, err = lldb.CreateBTree(db.alloc, opts.Compare); err != nil {
return
}
if h != 1 {
panic("internal error")
}
db.wal = opts.wal
return db, db.boot()
}
示例3: create
func create(f *os.File, filer lldb.Filer, opts *Options, isMem bool) (db *DB, err error) {
defer func() {
lock := opts.lock
if err != nil && lock != nil {
n := lock.Name()
lock.Close()
os.Remove(n)
db = nil
}
}()
if err = opts.check(filer.Name(), true, !isMem); err != nil {
return
}
b := [16]byte{byte(magic[0]), byte(magic[1]), byte(magic[2]), byte(magic[3]), 0x00} // ver 0x00
if n, err := filer.WriteAt(b[:], 0); n != 16 {
return nil, &os.PathError{Op: "dbm.Create.WriteAt", Path: filer.Name(), Err: err}
}
db = &DB{emptySize: 128, f: f, lock: opts.lock, closed: make(chan bool)}
if filer, err = opts.acidFiler(db, filer); err != nil {
return nil, err
}
db.filer = filer
if err = filer.BeginUpdate(); err != nil {
return
}
defer func() {
if e := filer.EndUpdate(); e != nil {
if err == nil {
err = e
}
}
}()
if db.alloc, err = lldb.NewAllocator(lldb.NewInnerFiler(filer, 16), &lldb.Options{}); err != nil {
return nil, &os.PathError{Op: "dbm.Create", Path: filer.Name(), Err: err}
}
db.alloc.Compress = compress
db.isMem = isMem
return db, db.boot()
}