shrinkbolt

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 5 Imported by: 0

README

shrinkbolt

shrink bolt (bbolt) database

entire database is not copied to RAM at once, so this may be suitable for extra large bolt database files.

untested, use at your own risk.

Usage
    // this is experimental
    shrinkbolt.DangerZone = true

    // "some.db" will be processed into a new file named "some.shrunken.db"
    err := shrinkbolt.ShrinkBoltDatabase("some.db","some.shrunken.db")
    if err != nil {
        // do something
    }

Documentation

Overview

shrinkbolt package shrinks bolt database files

Index

Examples

Constants

This section is empty.

Variables

View Source
var DangerZone = false
View Source
var Options = &bbolt.Options{
	Timeout: time.Second,
}

Functions

func GetNestedBucket

func GetNestedBucket(tx *bbolt.Tx, bucketPath [][]byte, createIfNotExist bool) (*bbolt.Bucket, error)

getNestedBucket presents the bucket at bucketPath. createIfNotExist depends on tx being a write-transaction

func ShrinkBoltDatabase

func ShrinkBoltDatabase(oldDbPath string, newDbPath string) error
Example
package main

import (
	"github.com/aerth/shrinkbolt"
)

func main() {
	err := shrinkbolt.ShrinkBoltDatabase(
		"some.dat",
		"some.shrunken.dat",
	)
	if err != nil {
		// do something
	}
}
Output:

Types

type Upgrader

type Upgrader struct {
	Old *bbolt.DB
	New *bbolt.DB
}

func (Upgrader) ReadyWalker

func (u Upgrader) ReadyWalker(baseBucket [][]byte, tx *bbolt.Tx) error

func (Upgrader) Shrink

func (u Upgrader) Shrink() error

func (Upgrader) WriteCopy

func (u Upgrader) WriteCopy(v []byte, k ...[]byte) error

writeCopy creates nested buckets in new db, and puts data in the final k bucket

Jump to

Keyboard shortcuts

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