本文整理汇总了Golang中github.com/syndtr/goleveldb/leveldb/storage.Reader类的典型用法代码示例。如果您正苦于以下问题:Golang Reader类的具体用法?Golang Reader怎么用?Golang Reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Reader类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: open
// Opens table. It returns a cache handle, which should
// be released after use.
func (t *tOps) open(f *tFile) (ch *cache.Handle, err error) {
ch = t.cache.Get(0, uint64(f.fd.Num), func() (size int, value cache.Value) {
var r storage.Reader
r, err = t.s.stor.Open(f.fd)
if err != nil {
return 0, nil
}
var bcache *cache.NamespaceGetter
if t.bcache != nil {
bcache = &cache.NamespaceGetter{Cache: t.bcache, NS: uint64(f.fd.Num)}
}
var tr *table.Reader
tr, err = table.NewReader(r, f.size, f.fd, bcache, t.bpool, t.s.o.Options)
if err != nil {
r.Close()
return 0, nil
}
return 1, tr
})
if ch == nil && err == nil {
err = ErrClosed
}
return
}
开发者ID:KosyanMedia,项目名称:burlesque,代码行数:29,代码来源:table.go
示例2: lookup
func (t *tOps) lookup(f *tFile) (c cache.Object, err error) {
num := f.file.Num()
c, ok := t.cacheNS.Get(num, func() (ok bool, value interface{}, charge int, fin cache.SetFin) {
var r storage.Reader
r, err = f.file.Open()
if err != nil {
return
}
o := t.s.o
var cacheNS cache.Namespace
if bc := o.GetBlockCache(); bc != nil {
cacheNS = bc.GetNamespace(num)
}
ok = true
value = table.NewReader(r, int64(f.size), cacheNS, o)
charge = 1
fin = func() {
r.Close()
}
return
})
if !ok && err == nil {
err = ErrClosed
}
return
}
开发者ID:paultyng,项目名称:padlock-cloud,代码行数:29,代码来源:table.go
示例3: open
// Opens table. It returns a cache handle, which should
// be released after use.
func (t *tOps) open(f *tFile) (ch *cache.Handle, err error) {
num := f.file.Num()
ch = t.cache.Get(0, num, func() (size int, value cache.Value) {
var r storage.Reader
r, err = f.file.Open()
if err != nil {
return 0, nil
}
var bcache *cache.CacheGetter
if t.bcache != nil {
bcache = &cache.CacheGetter{Cache: t.bcache, NS: num}
}
var tr *table.Reader
tr, err = table.NewReader(r, int64(f.size), storage.NewFileInfo(f.file), bcache, t.bpool, t.s.o.Options)
if err != nil {
r.Close()
return 0, nil
}
return 1, tr
})
if ch == nil && err == nil {
err = ErrClosed
}
return
}
开发者ID:CowLeo,项目名称:qdb,代码行数:30,代码来源:table.go
示例4: open
// Opens table. It returns a cache handle, which should
// be released after use.
func (t *tOps) open(f *tFile) (ch cache.Handle, err error) {
num := f.file.Num()
ch = t.cacheNS.Get(num, func() (charge int, value interface{}) {
var r storage.Reader
r, err = f.file.Open()
if err != nil {
return 0, nil
}
var bcacheNS cache.Namespace
if bc := t.s.o.GetBlockCache(); bc != nil {
bcacheNS = bc.GetNamespace(num)
}
var tr *table.Reader
tr, err = table.NewReader(r, int64(f.size), storage.NewFileInfo(f.file), bcacheNS, t.bpool, t.s.o.Options)
if err != nil {
r.Close()
return 0, nil
}
return 1, tr
})
if ch == nil && err == nil {
err = ErrClosed
}
return
}
开发者ID:ericcapricorn,项目名称:syncthing,代码行数:28,代码来源:table.go
示例5: lookup
func (t *tOps) lookup(f *tFile) (c cache.Object, err error) {
num := f.file.Num()
c, _ = t.cachens.Get(num, func() (ok bool, value interface{}, charge int, fin func()) {
var r storage.Reader
r, err = f.file.Open()
if err != nil {
return
}
o := t.s.o
var ns cache.Namespace
bc := o.GetBlockCache()
if bc != nil {
ns = bc.GetNamespace(num)
}
var p *table.Reader
p, err = table.NewReader(r, f.size, t.s.o, ns)
if err != nil {
return
}
ok = true
value = p
charge = 1
fin = func() {
r.Close()
}
return
})
return
}
开发者ID:29n,项目名称:goleveldb,代码行数:36,代码来源:table.go
示例6: Recover
// Recover recovers and opens a DB with missing or corrupted manifest files
// for the given storage. It will ignore any manifest files, valid or not.
// The DB must already exist or it will returns an error.
// Also, Recover will ignore ErrorIfMissing and ErrorIfExist options.
//
// The DB must be closed after use, by calling Close method.
func Recover(p storage.Storage, o *opt.Options) (db *DB, err error) {
s, err := newSession(p, o)
if err != nil {
return
}
defer func() {
if err != nil {
s.close()
s.release()
}
}()
// get all files
ff0, err := s.getFiles(storage.TypeAll)
if err != nil {
return
}
ff := files(ff0)
ff.sort()
s.logf("[email protected] F·%d", len(ff))
rec := new(sessionRecord)
// recover tables
var nt *tFile
for _, f := range ff {
if f.Type() != storage.TypeTable {
continue
}
var r storage.Reader
r, err = f.Open()
if err != nil {
return
}
var size int64
size, err = r.Seek(0, 2)
r.Close()
if err != nil {
return
}
t := newTFile(f, uint64(size), nil, nil)
iter := s.tops.newIterator(t, nil, nil)
// min ikey
if iter.First() {
t.min = iter.Key()
} else {
err = iter.Error()
iter.Release()
if err != nil {
return
} else {
continue
}
}
// max ikey
if iter.Last() {
t.max = iter.Key()
} else {
err = iter.Error()
iter.Release()
if err != nil {
return
} else {
continue
}
}
iter.Release()
s.logf("[email protected] found table @%d S·%s %q:%q", t.file.Num(), shortenb(int(t.size)), t.min, t.max)
// add table to level 0
rec.addTableFile(0, t)
nt = t
}
// extract largest seq number from newest table
if nt != nil {
var lseq uint64
iter := s.tops.newIterator(nt, nil, nil)
for iter.Next() {
seq, _, ok := iKey(iter.Key()).parseNum()
if !ok {
continue
}
if seq > lseq {
lseq = seq
}
}
iter.Release()
rec.setSeq(lseq)
}
//.........这里部分代码省略.........
开发者ID:kennylixi,项目名称:goleveldb,代码行数:101,代码来源:db.go
注:本文中的github.com/syndtr/goleveldb/leveldb/storage.Reader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论