当前位置: 首页>>代码示例>>Golang>>正文


Golang DB.NewIterator方法代码示例

本文整理汇总了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
}
开发者ID:CowLeo,项目名称:qdb,代码行数:18,代码来源:session_compaction.go

示例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
}
开发者ID:paultyng,项目名称:padlock-cloud,代码行数:19,代码来源:db_compaction.go

示例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
}
开发者ID:29n,项目名称:goleveldb,代码行数:21,代码来源:db_compaction.go

示例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
}
开发者ID:PrFalken,项目名称:prometheus,代码行数:23,代码来源:session_compaction.go

示例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
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:24,代码来源:db_compaction.go

示例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))
}
开发者ID:PrFalken,项目名称:prometheus,代码行数:6,代码来源:db_write.go


注:本文中的github.com/syndtr/goleveldb/leveldb/memdb.DB.NewIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。