本文整理汇总了Golang中github.com/syndtr/goleveldb/leveldb/memdb.DB.NewIterator方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.NewIterator方法的具体用法?Golang DB.NewIterator怎么用?Golang DB.NewIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/syndtr/goleveldb/leveldb/memdb.DB
的用法示例。
在下文中一共展示了DB.NewIterator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: flushMemdb
func (s *session) flushMemdb(rec *sessionRecord, mdb *memdb.DB, level int) (level_ int, err error) {
// Create sorted table.
iter := mdb.NewIterator(nil)
defer iter.Release()
t, n, err := s.tops.createFrom(iter)
if err != nil {
return level, err
}
// Pick level and add to record.
if level < 0 {
level = s.pickMemdbLevel(t.imin.ukey(), t.imax.ukey())
}
rec.addTableFile(level, t)
s.logf("[email protected] created L%[email protected]%d N·%d S·%s %q:%q", level, t.file.Num(), n, shortenb(int(t.size)), t.imin, t.imax)
return level, nil
}
示例2: flush
func (c *cMem) flush(mem *memdb.DB, level int) error {
s := c.s
// Write memdb to table
t, n, err := s.tops.createFrom(mem.NewIterator(nil))
if err != nil {
return err
}
if level < 0 {
level = s.version_NB().pickLevel(t.min.ukey(), t.max.ukey())
}
c.rec.addTableFile(level, t)
s.logf("[email protected] created L%[email protected]%d N·%d S·%s %q:%q", level, t.file.Num(), n, shortenb(int(t.size)), t.min, t.max)
c.level = level
return nil
}
示例3: flush
func (c *cMem) flush(mem *memdb.DB, level int) error {
s := c.s
// Write memdb to table
t, n, err := s.tops.createFrom(mem.NewIterator())
if err != nil {
return err
}
if level < 0 {
level = s.version().pickLevel(t.min.ukey(), t.max.ukey())
}
c.rec.addTableFile(level, t)
s.printf("Compaction: table created, source=mem level=%d num=%d size=%d entries=%d min=%q max=%q",
level, t.file.Num(), t.size, n, t.min, t.max)
c.level = level
c.t = t
return nil
}
示例4: flushMemdb
func (s *session) flushMemdb(rec *sessionRecord, mdb *memdb.DB, maxLevel int) (int, error) {
// Create sorted table.
iter := mdb.NewIterator(nil)
defer iter.Release()
t, n, err := s.tops.createFrom(iter)
if err != nil {
return 0, err
}
// Pick level other than zero can cause compaction issue with large
// bulk insert and delete on strictly incrementing key-space. The
// problem is that the small deletion markers trapped at lower level,
// while key/value entries keep growing at higher level. Since the
// key-space is strictly incrementing it will not overlaps with
// higher level, thus maximum possible level is always picked, while
// overlapping deletion marker pushed into lower level.
// See: https://github.com/syndtr/goleveldb/issues/127.
flushLevel := s.pickMemdbLevel(t.imin.ukey(), t.imax.ukey(), maxLevel)
rec.addTableFile(flushLevel, t)
s.logf("[email protected] created L%[email protected]%d N·%d S·%s %q:%q", flushLevel, t.fd.Num, n, shortenb(int(t.size)), t.imin, t.imax)
return flushLevel, nil
}
示例5: flush
func (c *cMem) flush(mem *memdb.DB, level int) error {
s := c.s
// Write memdb to table.
iter := mem.NewIterator(nil)
defer iter.Release()
t, n, err := s.tops.createFrom(iter)
if err != nil {
return err
}
// Pick level.
if level < 0 {
v := s.version()
level = v.pickLevel(t.imin.ukey(), t.imax.ukey())
v.release()
}
c.rec.addTableFile(level, t)
s.logf("[email protected] created L%[email protected]%d N·%d S·%s %q:%q", level, t.file.Num(), n, shortenb(int(t.size)), t.imin, t.imax)
c.level = level
return nil
}
示例6: isMemOverlaps
func isMemOverlaps(icmp *iComparer, mem *memdb.DB, min, max []byte) bool {
iter := mem.NewIterator(nil)
defer iter.Release()
return (max == nil || (iter.First() && icmp.uCompare(max, internalKey(iter.Key()).ukey()) >= 0)) &&
(min == nil || (iter.Last() && icmp.uCompare(min, internalKey(iter.Key()).ukey()) <= 0))
}