Skip to content

Commit

Permalink
mdbx: v0.12.3 (#88)
Browse files Browse the repository at this point in the history
also removed method env.Path(), if you need it please help me to fix it by PR, thank you
  • Loading branch information
AskAlexSharov authored Jan 7, 2023
1 parent f075c7f commit 381b931
Show file tree
Hide file tree
Showing 17 changed files with 31,612 additions and 21,460 deletions.
32 changes: 16 additions & 16 deletions mdbx/cursor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestCursor_Txn(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var db DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestCursor_Txn(t *testing.T) {
}

func TestCursor_DBI(t *testing.T) {
env := setup(t)
env, _ := setup(t)

err := env.Update(func(txn *Txn) (err error) {
db, err := txn.OpenDBI("db", Create, nil, nil)
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestCursor_DBI(t *testing.T) {
}

func TestCursor_Close(t *testing.T) {
env := setup(t)
env, _ := setup(t)

runtime.LockOSThread()
defer runtime.UnlockOSThread()
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestCursor_Close(t *testing.T) {
}

func TestCursor_bytesBuffer(t *testing.T) {
env := setup(t)
env, _ := setup(t)

db, err := openRoot(env, 0)
if err != nil {
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestCursor_bytesBuffer(t *testing.T) {
}

func TestCursor_PutReserve(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var db DBI
key := "reservekey"
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestCursor_PutReserve(t *testing.T) {
}

func TestCursor_Get_KV(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var dbi DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -271,7 +271,7 @@ func FromHex(in string) []byte {
}

func TestLastDup(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var dbi DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -337,7 +337,7 @@ func TestLastDup(t *testing.T) {
}

func TestCursor_Get_op_Set_bytesBuffer(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var dbi DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -412,7 +412,7 @@ func TestCursor_Get_op_Set_bytesBuffer(t *testing.T) {
}

func TestCursor_Get_DupFixed(t *testing.T) {
env := setup(t)
env, _ := setup(t)

const datasize = 16
pagesize := os.Getpagesize()
Expand Down Expand Up @@ -495,7 +495,7 @@ func TestCursor_Get_DupFixed(t *testing.T) {
}

func TestCursor_Get_reverse(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var dbi DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -619,7 +619,7 @@ func TestCursor_Get_reverse(t *testing.T) {
//}

func TestCursor_Del(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var db DBI
type Item struct{ k, v string }
Expand Down Expand Up @@ -718,7 +718,7 @@ func TestCursor_Del(t *testing.T) {

// This test verifies the behavior of Cursor.Count when DupSort is provided.
func TestCursor_Count_DupSort(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var db DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -772,7 +772,7 @@ func TestCursor_Count_DupSort(t *testing.T) {
// This test verifies the behavior of Cursor.Count when DupSort is not enabled
// on the database.
func TestCursor_Count_noDupSort(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var db DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -813,7 +813,7 @@ func TestCursor_Count_noDupSort(t *testing.T) {
}

func TestCursor_Renew(t *testing.T) {
env := setup(t)
env, _ := setup(t)

var db DBI
err := env.Update(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -887,7 +887,7 @@ func TestCursor_Renew(t *testing.T) {
}

func BenchmarkCursor(b *testing.B) {
env := setup(b)
env, _ := setup(b)

var db DBI
err := env.View(func(txn *Txn) (err error) {
Expand Down Expand Up @@ -922,7 +922,7 @@ func BenchmarkCursor(b *testing.B) {
}

func BenchmarkCursor_Renew(b *testing.B) {
env := setup(b)
env, _ := setup(b)

var cur *Cursor
err := env.View(func(txn *Txn) (err error) {
Expand Down
60 changes: 26 additions & 34 deletions mdbx/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,15 +315,18 @@ type EnvInfoGeo struct {
Grow uint64
}
type EnfInfoPageOps struct {
Newly uint64 /**< Quantity of a new pages added */
Cow uint64 /**< Quantity of pages copied for update */
Clone uint64 /**< Quantity of parent's dirty pages clones for nested transactions */
Split uint64 /**< Page splits */
Merge uint64 /**< Page merges */
Spill uint64 /**< Quantity of spilled dirty pages */
Unspill uint64 /**< Quantity of unspilled/reloaded pages */
Wops uint64 /**< Number of explicit write operations (not a pages) to a disk */
Gcrtime time.Duration /**< Time spent loading and searching inside GC */
Newly uint64 /**< Quantity of a new pages added */
Cow uint64 /**< Quantity of pages copied for update */
Clone uint64 /**< Quantity of parent's dirty pages clones for nested transactions */
Split uint64 /**< Page splits */
Merge uint64 /**< Page merges */
Spill uint64 /**< Quantity of spilled dirty pages */
Unspill uint64 /**< Quantity of unspilled/reloaded pages */
Wops uint64 /**< Number of explicit write operations (not a pages) to a disk */
Minicore uint64 /**< Number of mincore() calls */
Prefault uint64 /**< Number of prefault write operations (not a pages) */
Msync uint64 /**< Number of explicit write operations (not a pages) to a disk */
Fsync uint64 /**< Number of explicit write operations (not a pages) to a disk */
}

// EnvInfo contains information an environment.
Expand All @@ -343,6 +346,7 @@ type EnvInfo struct {
NumReaders uint // maximum number of threads used in the environment
PageSize uint //
SystemPageSize uint //
MiLastPgNo uint64 //
AutoSyncThreshold uint //
SinceSync time.Duration //
AutosyncPeriod time.Duration //
Expand Down Expand Up @@ -378,22 +382,26 @@ func (env *Env) Info(txn *Txn) (*EnvInfo, error) {
Grow: uint64(_info.mi_geo.grow),
},
PageOps: EnfInfoPageOps{
Newly: uint64(_info.mi_pgop_stat.newly),
Cow: uint64(_info.mi_pgop_stat.cow),
Clone: uint64(_info.mi_pgop_stat.clone),
Split: uint64(_info.mi_pgop_stat.split),
Merge: uint64(_info.mi_pgop_stat.merge),
Spill: uint64(_info.mi_pgop_stat.spill),
Unspill: uint64(_info.mi_pgop_stat.unspill),
Wops: uint64(_info.mi_pgop_stat.wops),
Gcrtime: toDurationU64(_info.mi_pgop_stat.gcrtime_seconds16dot16),
Newly: uint64(_info.mi_pgop_stat.newly),
Cow: uint64(_info.mi_pgop_stat.cow),
Clone: uint64(_info.mi_pgop_stat.clone),
Split: uint64(_info.mi_pgop_stat.split),
Merge: uint64(_info.mi_pgop_stat.merge),
Spill: uint64(_info.mi_pgop_stat.spill),
Unspill: uint64(_info.mi_pgop_stat.unspill),
Wops: uint64(_info.mi_pgop_stat.wops),
Prefault: uint64(_info.mi_pgop_stat.prefault),
Minicore: uint64(_info.mi_pgop_stat.mincore),
Msync: uint64(_info.mi_pgop_stat.msync),
Fsync: uint64(_info.mi_pgop_stat.fsync),
},
LastPNO: int64(_info.mi_last_pgno),
LastTxnID: int64(_info.mi_recent_txnid),
MaxReaders: uint(_info.mi_maxreaders),
NumReaders: uint(_info.mi_numreaders),
PageSize: uint(_info.mi_dxb_pagesize),
SystemPageSize: uint(_info.mi_sys_pagesize),
MiLastPgNo: uint64(_info.mi_last_pgno),

AutoSyncThreshold: uint(_info.mi_autosync_threshold),
SinceSync: toDuration(_info.mi_since_sync_seconds16dot16),
Expand Down Expand Up @@ -446,22 +454,6 @@ func (env *Env) SetDebug(logLvl LogLvl, dbg int, logger *C.MDBX_debug_func) erro
return nil
}

// Path returns the path argument passed to Open. Path returns a non-nil error
// if env.Open() was not previously called.
//
// See mdbx_env_get_path.
func (env *Env) Path() (string, error) {
var cpath *C.char
ret := C.mdbx_env_get_path(env._env, &cpath)
if ret != success {
return "", operrno("mdbx_env_get_path", ret)
}
if cpath == nil {
return "", errNotOpen
}
return C.GoString(cpath), nil
}

func (env *Env) SetOption(option uint, value uint64) error {
ret := C.mdbx_env_set_option(env._env, C.MDBX_option_t(option), C.uint64_t(value))
return operrno("mdbx_env_set_option", ret)
Expand Down
27 changes: 27 additions & 0 deletions mdbx/env_not_win.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//go:build !windows
// +build !windows

package mdbx

/*
#include "mdbxgo.h"
*/
import "C"

//TODO: fix me please

// Path returns the path argument passed to Open. Path returns a non-nil error
// if env.Open() was not previously called.
//
// See mdbx_env_get_path.
//func (env *Env) Path() (string, error) {
// var cpath *C.char
// ret := C.mdbx_env_get_path(env._env, &cpath)
// if ret != success {
// return "", operrno("mdbx_env_get_path", ret)
// }
// if cpath == nil {
// return "", errNotOpen
// }
// return C.GoString(cpath), nil
//}
Loading

0 comments on commit 381b931

Please sign in to comment.