Documentation ¶
Index ¶
- Constants
- func CompressionDecodeHookFunc() mapstructure.DecodeHookFuncType
- func Get(db *badger.DB, key []byte) (value []byte, err error)
- func Search(db *badger.DB, key string, reverse bool, f PerItemFunc, a AfterIterFunc) error
- type AfterIterFunc
- type DB
- func (db *DB) Close()
- func (db *DB) Closest(_ context.Context, search index.ClosestRequest, ...) error
- func (db *DB) GetCdx(key string) (*schema.Cdx, error)
- func (db *DB) GetFileInfo(_ context.Context, filename string) (*schema.Fileinfo, error)
- func (db *DB) GetStorageRef(ctx context.Context, warcId string) (string, error)
- func (db *DB) Index(path string) error
- func (db *DB) List(ctx context.Context, limit int, results chan<- index.CdxResponse) error
- func (db *DB) ListFileInfo(ctx context.Context, limit int, results chan<- index.FileResponse) error
- func (db *DB) ListRecords(fn func(warcId string, cdx *schema.Cdx) (stopIteration bool)) error
- func (db *DB) ListStorageRef(ctx context.Context, limit int, results chan<- index.IdResponse) error
- func (db *DB) Resolve(_ context.Context, warcId string) (storageRef string, err error)
- func (db *DB) ResolvePath(filename string) (filePath string, err error)
- func (db *DB) Search(ctx context.Context, search index.SearchRequest, ...) error
- func (db *DB) Write(rec index.Record) error
- type Option
- func WithBatchMaxSize(size int) Option
- func WithBatchMaxWait(t time.Duration) Option
- func WithCompression(c badgerOptions.CompressionType) Option
- func WithDatabase(db string) Option
- func WithDir(d string) Option
- func WithGcInterval(t time.Duration) Option
- func WithIndexer(indexer index.Indexer) Option
- func WithReadOnly(readOnly bool) Option
- type Options
- type PerCdxFunc
- type PerItemFunc
- type Sorter
Constants ¶
View Source
const ( SnappyCompression = "snappy" NoCompression = "none" ZstdCompression = "zstd" )
Variables ¶
This section is empty.
Functions ¶
func CompressionDecodeHookFunc ¶
func CompressionDecodeHookFunc() mapstructure.DecodeHookFuncType
CompressionDecodeHookFunc helps decode a string to a badger compression type using viper.
Example: var c options.CompressionType _ = viper.UnmarshalKey("compression", &c, viper.DecodeHook(CompressionDecodeHookFunc())
func Search ¶
func Search(db *badger.DB, key string, reverse bool, f PerItemFunc, a AfterIterFunc) error
Search iterates over keys in db prefixed with key and applies PerItemFunc f to each item value.
Types ¶
type AfterIterFunc ¶
type AfterIterFunc func(txn *badger.Txn) error
type DB ¶
type DB struct { // IdIndex maps record id to storage ref IdIndex *badger.DB // FileIndex maps filepath to fileinfo FileIndex *badger.DB // CdxIndex maps cdx key to cdx record CdxIndex *badger.DB // contains filtered or unexported fields }
func (*DB) Close ¶
func (db *DB) Close()
Close stops the gc and batch workers and closes the index databases.
func (*DB) Closest ¶
func (db *DB) Closest(_ context.Context, search index.ClosestRequest, results chan<- index.CdxResponse) error
Closest returns the first closest cdx value
func (*DB) GetFileInfo ¶
func (*DB) GetStorageRef ¶
func (*DB) ListFileInfo ¶
func (*DB) ListRecords ¶
func (*DB) ListStorageRef ¶
func (*DB) Resolve ¶
Resolve looks up warcId in the id index of the database and returns corresponding storageRef, or an error if not found.
func (*DB) ResolvePath ¶
ResolvePath looks up filename in file index and returns the path field.
func (*DB) Search ¶
func (db *DB) Search(ctx context.Context, search index.SearchRequest, results chan<- index.CdxResponse) error
type Option ¶
type Option func(opts *Options)
func WithBatchMaxSize ¶
func WithBatchMaxWait ¶
func WithCompression ¶
func WithCompression(c badgerOptions.CompressionType) Option
func WithDatabase ¶
func WithGcInterval ¶
func WithIndexer ¶
func WithReadOnly ¶
type PerCdxFunc ¶
type PerItemFunc ¶
type PerItemFunc func(*badger.Item) (stopIteration bool)
Click to show internal directories.
Click to hide internal directories.