mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-09 22:51:02 +00:00
linter fix
This commit is contained in:
parent
59d2d89a5c
commit
7c5c693fcb
7 changed files with 119 additions and 93 deletions
|
|
@ -80,7 +80,7 @@ func TestCursor_FirstNext_Quick(t *testing.T) {
|
|||
t.Skip("race detection enabled, skipping")
|
||||
}
|
||||
|
||||
const n = 100000
|
||||
const n = 10000
|
||||
|
||||
QuickCheck(t, func(t *testing.T, rand *rand.Rand) {
|
||||
t.Parallel()
|
||||
|
|
@ -202,7 +202,7 @@ func TestCursor_LastPrev_Quick(t *testing.T) {
|
|||
t.Skip("race detection enabled, skipping")
|
||||
}
|
||||
|
||||
const n = 100000
|
||||
const n = 10000
|
||||
|
||||
QuickCheck(t, func(t *testing.T, rand *rand.Rand) {
|
||||
t.Parallel()
|
||||
|
|
@ -323,7 +323,7 @@ func TestCursor_Union(t *testing.T) {
|
|||
defer MustCloseDB(t, db)
|
||||
tx := MustBegin(t, db, true)
|
||||
defer MustRollback(t, tx)
|
||||
values := GenerateValues(rand, 100000)
|
||||
values := GenerateValues(rand, 10000)
|
||||
rows := ToRows(values)
|
||||
|
||||
if err := tx.CreateBitmap("x"); err != nil {
|
||||
|
|
@ -404,7 +404,7 @@ func TestCursor_Intersect(t *testing.T) {
|
|||
defer MustCloseDB(t, db)
|
||||
tx := MustBegin(t, db, true)
|
||||
defer MustRollback(t, tx)
|
||||
values := GenerateValues(rand, rand.Intn(100000))
|
||||
values := GenerateValues(rand, rand.Intn(10000))
|
||||
rows := ToRows(values)
|
||||
|
||||
if err := tx.CreateBitmap("x"); err != nil {
|
||||
|
|
|
|||
93
rbf/helpers_test.go
Normal file
93
rbf/helpers_test.go
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
package rbf_test
|
||||
|
||||
/*
|
||||
func itohex(v int) string { return fmt.Sprintf("0x%x", v) }
|
||||
|
||||
func hexdump(b []byte) { println(hex.Dump(b)) }
|
||||
|
||||
// treedump recursively writes the tree representation starting from a given page to STDERR.
|
||||
func treedump(tx *rbf.Tx, pgno uint32, indent string, writer io.Writer) {
|
||||
page, err := tx.readPage(pgno)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if rbf.IsMetaPage(page) {
|
||||
fmt.Fprintf(writer, "META(%d)\n", pgno)
|
||||
fmt.Fprintf(writer, "└── <FREELIST>\n")
|
||||
//treedump(tx, readMetaFreelistPageNo(page), indent+" ")
|
||||
|
||||
visitor := func(pgno uint32, records []*rbf.RootRecord) {
|
||||
fmt.Fprintf(writer, "└── ROOT RECORD(%d): n=%d\n", pgno, len(records))
|
||||
for _, record := range records {
|
||||
fmt.Fprintf(writer, "└── ROOT(%q) %d\n", record.Name, record.Pgno)
|
||||
treedump(tx, record.Pgno, indent+" ", writer)
|
||||
|
||||
}
|
||||
}
|
||||
rrdump(tx, readMetaRootRecordPageNo(page), visitor)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Handle
|
||||
switch typ := readFlags(page); typ {
|
||||
case PageTypeBranch:
|
||||
fmt.Fprintf(writer, "%s BRANCH(%d) n=%d\n", fmtindent(indent), pgno, readCellN(page))
|
||||
|
||||
for i, n := 0, readCellN(page); i < n; i++ {
|
||||
cell := readBranchCell(page, i)
|
||||
treedump(tx, cell.Pgno, " "+indent, writer)
|
||||
}
|
||||
case PageTypeLeaf:
|
||||
fmt.Fprintf(writer, "%s LEAF(%d) n=%d\n", fmtindent(indent), pgno, readCellN(page))
|
||||
pagedumpi(page, fmtindent(" "+indent), writer)
|
||||
default:
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func rrdump(tx *Tx, pgno uint32, v func(uint32, []*RootRecord)) {
|
||||
for pgno := readMetaRootRecordPageNo(tx.meta[:]); pgno != 0; {
|
||||
page, err := tx.readPage(pgno)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Read all records on the page.
|
||||
a, err := readRootRecords(page)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
v(pgno, a)
|
||||
// Read next overflow page number.
|
||||
pgno = WalkRootRecordPages(page)
|
||||
}
|
||||
}
|
||||
|
||||
func fmtindent(s string) string {
|
||||
if s == "" {
|
||||
return ""
|
||||
}
|
||||
return s + "└──"
|
||||
}
|
||||
|
||||
// RowValues returns a list of integer values from a row bitmap.
|
||||
func RowValues(b []uint64) []uint64 {
|
||||
a := make([]uint64, 0)
|
||||
for i, v := range b {
|
||||
for j := uint(0); j < 64; j++ {
|
||||
if v&(1<<j) != 0 {
|
||||
a = append(a, (uint64(i)*64)+uint64(j))
|
||||
}
|
||||
}
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func onpanic(fn func()) {
|
||||
if r := recover(); r != nil {
|
||||
fn()
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -21,8 +21,11 @@ import (
|
|||
// This function exists to mark debugging helper function as "used" by the linter.
|
||||
func TestUsed(t *testing.T) {
|
||||
t.Skip("This function is always skipped")
|
||||
dump(nil)
|
||||
//hexdump(nil)
|
||||
/* dump(nil)
|
||||
hexdump(nil)
|
||||
pagedumpi(nil, "", nil)
|
||||
treedump(nil, 0, "", nil)
|
||||
onpanic(nil)
|
||||
itohex(0)
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
82
rbf/rbf.go
82
rbf/rbf.go
|
|
@ -261,7 +261,6 @@ type leafCell struct {
|
|||
N int
|
||||
Data []byte
|
||||
}
|
||||
type leafArgs leafCell
|
||||
|
||||
// Size returns the size of the leaf cell, in bytes.
|
||||
func (c *leafCell) Size() int {
|
||||
|
|
@ -487,6 +486,7 @@ func search(n int, f func(int) int) (index int, exact bool) {
|
|||
return i, false
|
||||
}
|
||||
|
||||
/*
|
||||
func pagedumpi(b []byte, indent string, writer io.Writer) {
|
||||
pgno := readPageNo(b)
|
||||
if pgno == Magic32() {
|
||||
|
|
@ -525,6 +525,7 @@ func pagedumpi(b []byte, indent string, writer io.Writer) {
|
|||
fmt.Fprintf(writer, "==!PAGE %d flags=%d\n", pgno, flags)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
func Walk(tx *Tx, pgno uint32, v func(uint32, []*RootRecord)) {
|
||||
for pgno := readMetaRootRecordPageNo(tx.meta[:]); pgno != 0; {
|
||||
|
|
@ -544,71 +545,10 @@ func Walk(tx *Tx, pgno uint32, v func(uint32, []*RootRecord)) {
|
|||
}
|
||||
}
|
||||
|
||||
// treedump recursively writes the tree representation starting from a given page to STDERR.
|
||||
func treedump(tx *Tx, pgno uint32, indent string, writer io.Writer) {
|
||||
page, err := tx.readPage(pgno)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
func assert(condition bool) {
|
||||
if !condition {
|
||||
panic("assertion failed")
|
||||
}
|
||||
|
||||
if IsMetaPage(page) {
|
||||
fmt.Fprintf(writer, "META(%d)\n", pgno)
|
||||
fmt.Fprintf(writer, "└── <FREELIST>\n")
|
||||
//treedump(tx, readMetaFreelistPageNo(page), indent+" ")
|
||||
|
||||
visitor := func(pgno uint32, records []*RootRecord) {
|
||||
fmt.Fprintf(writer, "└── ROOT RECORD(%d): n=%d\n", pgno, len(records))
|
||||
for _, record := range records {
|
||||
fmt.Fprintf(writer, "└── ROOT(%q) %d\n", record.Name, record.Pgno)
|
||||
treedump(tx, record.Pgno, indent+" ", writer)
|
||||
|
||||
}
|
||||
}
|
||||
rrdump(tx, readMetaRootRecordPageNo(page), visitor)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Handle
|
||||
switch typ := readFlags(page); typ {
|
||||
case PageTypeBranch:
|
||||
fmt.Fprintf(writer, "%s BRANCH(%d) n=%d\n", fmtindent(indent), pgno, readCellN(page))
|
||||
|
||||
for i, n := 0, readCellN(page); i < n; i++ {
|
||||
cell := readBranchCell(page, i)
|
||||
treedump(tx, cell.Pgno, " "+indent, writer)
|
||||
}
|
||||
case PageTypeLeaf:
|
||||
fmt.Fprintf(writer, "%s LEAF(%d) n=%d\n", fmtindent(indent), pgno, readCellN(page))
|
||||
pagedumpi(page, fmtindent(" "+indent), writer)
|
||||
default:
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func rrdump(tx *Tx, pgno uint32, v func(uint32, []*RootRecord)) {
|
||||
for pgno := readMetaRootRecordPageNo(tx.meta[:]); pgno != 0; {
|
||||
page, err := tx.readPage(pgno)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Read all records on the page.
|
||||
a, err := readRootRecords(page)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
v(pgno, a)
|
||||
// Read next overflow page number.
|
||||
pgno = WalkRootRecordPages(page)
|
||||
}
|
||||
}
|
||||
|
||||
func fmtindent(s string) string {
|
||||
if s == "" {
|
||||
return ""
|
||||
}
|
||||
return s + "└──"
|
||||
}
|
||||
|
||||
// RowValues returns a list of integer values from a row bitmap.
|
||||
|
|
@ -623,15 +563,3 @@ func RowValues(b []uint64) []uint64 {
|
|||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func onpanic(fn func()) {
|
||||
if r := recover(); r != nil {
|
||||
fn()
|
||||
}
|
||||
}
|
||||
|
||||
func assert(condition bool) {
|
||||
if !condition {
|
||||
panic("assertion failed")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
rbf/tx.go
12
rbf/tx.go
|
|
@ -79,9 +79,12 @@ func (tx *Tx) Rollback() error {
|
|||
|
||||
// Disconnect transaction from DB.
|
||||
err := tx.db.removeTx(tx)
|
||||
if err != nil {
|
||||
//TODO need to fix this error
|
||||
}
|
||||
_ = err
|
||||
/*
|
||||
if err != nil {
|
||||
//TODO need to fix this error
|
||||
}
|
||||
*/
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -149,12 +152,15 @@ func (tx *Tx) CreateBitmap(name string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
func dump(r []*RootRecord) {
|
||||
for _, i := range r {
|
||||
fmt.Println("RECORD", i.Name, i.Pgno)
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
// DeleteBitmap removes a bitmap with the given name.
|
||||
// Returns an error if the bitmap does not exist.
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ func TestTx_Add_Quick(t *testing.T) {
|
|||
defer MustCloseDB(t, db)
|
||||
tx := MustBegin(t, db, true)
|
||||
defer MustRollback(t, tx)
|
||||
values := GenerateValues(rand, 100000)
|
||||
values := GenerateValues(rand, 10000)
|
||||
|
||||
if err := tx.CreateBitmap("x"); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -265,7 +265,7 @@ func TestTx_AddRemove_Quick(t *testing.T) {
|
|||
defer MustCloseDB(t, db)
|
||||
tx := MustBegin(t, db, true)
|
||||
defer MustRollback(t, tx)
|
||||
values := GenerateValues(rand, 100000)
|
||||
values := GenerateValues(rand, 10000)
|
||||
|
||||
if err := tx.CreateBitmap("x"); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ package rbf_test
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"encoding/hex"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"os"
|
||||
|
|
@ -27,9 +26,6 @@ import (
|
|||
"github.com/pilosa/pilosa/v2/rbf"
|
||||
)
|
||||
|
||||
func itohex(v int) string { return fmt.Sprintf("0x%x", v) }
|
||||
|
||||
func hexdump(b []byte) { println(hex.Dump(b)) }
|
||||
|
||||
func TestWALSegment_Open(t *testing.T) {
|
||||
t.Run("OK", func(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue