biter

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2021 License: Unlicense Imports: 2 Imported by: 1

README

bIter

Go Report Card PkgGoDev Maintainability codecov GitHub License

Iterator for badgerDB

// Iterator adds an implementable target for variations of different Iterator's
// for simplification of functional code, that you can then implement this reduced
// interface such that primarily methods Rewind and Valid and Next are overloaded.
// usage:
// 		for iterator.Rewind(); iterator.Valid(); iterator.Next() {
//			iterator.Item()
//			...
//		}
// this is a general snippet of code that using this interface may have overloaded
// only Rewind and Valid are changes
type Iterator interface {
	Rewind()
	Valid() bool
	Next()
	Item() *badger.Item
}

This library also add 5 concrete iterators: prefix, from-to, from, to, prefix-from.

The library does not support backward key-scan (whence only a prefix-from)

Use the method biter.KeyRangeIterator and throw any combination of prefix, from and to at it to get the corresponding Iterator.

for some examples of functionality refer to queries_test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

type Iterator interface {
	Rewind()
	Valid() bool
	Next()
	Item() *badger.Item
}

Iterator adds an implementable target for variations of different Iterator(s) for simplification of functional code, that you can then implement this reduced interface such that primarily methods Rewind and Valid and Next are overloaded. usage:

for iterator.Rewind(); iterator.Valid(); iterator.Next() {
	iterator.Item()
	...
}

this is a general snippet of code that using this interface may have changed implementation only Rewind and Valid are changes

func KeyRangeIterator

func KeyRangeIterator(it *badger.Iterator, prefix, from, to []byte) Iterator

KeyRangeIterator returns an Iterator interface implementation, that wraps the badger.Iterator in order to simplify iterating with from-to and/or prefix.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL