mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
thread logoutput index -> db -> frame -> fragment
also stop extra output to stderr from tests
This commit is contained in:
parent
43d4c0c670
commit
10d90f742a
8 changed files with 26 additions and 15 deletions
9
db.go
9
db.go
|
|
@ -3,6 +3,7 @@ package pilosa
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -34,10 +35,12 @@ type DB struct {
|
|||
profileAttrStore *AttrStore
|
||||
|
||||
stats StatsClient
|
||||
|
||||
LogOutput io.Writer
|
||||
}
|
||||
|
||||
// NewDB returns a new instance of DB.
|
||||
func NewDB(path, name string) *DB {
|
||||
func NewDB(path, name string, logOutput io.Writer) *DB {
|
||||
return &DB{
|
||||
path: path,
|
||||
name: name,
|
||||
|
|
@ -47,6 +50,8 @@ func NewDB(path, name string) *DB {
|
|||
profileAttrStore: NewAttrStore(filepath.Join(path, "data")),
|
||||
|
||||
stats: NopStatsClient,
|
||||
|
||||
LogOutput: logOutput,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,7 +275,7 @@ func (db *DB) createFrameIfNotExists(name string) (*Frame, error) {
|
|||
}
|
||||
|
||||
func (db *DB) newFrame(path, name string) *Frame {
|
||||
f := NewFrame(path, db.name, name)
|
||||
f := NewFrame(path, db.name, name, db.LogOutput)
|
||||
f.stats = db.stats.WithTags(fmt.Sprintf("frame:%s", name))
|
||||
return f
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ func NewDB() *DB {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
return &DB{DB: pilosa.NewDB(path, "d")}
|
||||
return &DB{DB: pilosa.NewDB(path, "d", ioutil.Discard)}
|
||||
}
|
||||
|
||||
// MustOpenDB returns a new, opened database at a temporary path. Panic on error.
|
||||
|
|
@ -115,7 +115,7 @@ func (db *DB) Reopen() error {
|
|||
}
|
||||
|
||||
path, name := db.Path(), db.Name()
|
||||
db.DB = pilosa.NewDB(path, name)
|
||||
db.DB = pilosa.NewDB(path, name, ioutil.Discard)
|
||||
|
||||
if err := db.Open(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -90,14 +90,14 @@ type Fragment struct {
|
|||
}
|
||||
|
||||
// NewFragment returns a new instance of Fragment.
|
||||
func NewFragment(path, db, frame string, slice uint64) *Fragment {
|
||||
func NewFragment(path, db, frame string, slice uint64, logOutput io.Writer) *Fragment {
|
||||
return &Fragment{
|
||||
path: path,
|
||||
db: db,
|
||||
frame: frame,
|
||||
slice: slice,
|
||||
|
||||
LogOutput: os.Stderr,
|
||||
LogOutput: logOutput,
|
||||
MaxOpN: DefaultFragmentMaxOpN,
|
||||
|
||||
stats: NopStatsClient,
|
||||
|
|
@ -861,7 +861,7 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error {
|
|||
// no real danger
|
||||
if i == 0 || bitmapID != lastID {
|
||||
lastID = bitmapID
|
||||
set[bitmapID] = struct{}{}
|
||||
set[bitmapID] = struct{}{}
|
||||
}
|
||||
if changed {
|
||||
bmCounter += 1
|
||||
|
|
|
|||
|
|
@ -505,7 +505,7 @@ func BenchmarkFragment_Blocks(b *testing.B) {
|
|||
}
|
||||
|
||||
// Open the fragment specified by the path.
|
||||
f := pilosa.NewFragment(*FragmentPath, "d", "f", 0)
|
||||
f := pilosa.NewFragment(*FragmentPath, "d", "f", 0, ioutil.Discard)
|
||||
if err := f.Open(); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
|
|
@ -566,7 +566,7 @@ func NewFragment(db, frame string, slice uint64) *Fragment {
|
|||
file.Close()
|
||||
|
||||
f := &Fragment{
|
||||
Fragment: pilosa.NewFragment(file.Name(), db, frame, slice),
|
||||
Fragment: pilosa.NewFragment(file.Name(), db, frame, slice, ioutil.Discard),
|
||||
BitmapAttrStore: MustOpenAttrStore(),
|
||||
}
|
||||
f.Fragment.BitmapAttrStore = f.BitmapAttrStore.AttrStore
|
||||
|
|
@ -597,7 +597,7 @@ func (f *Fragment) Reopen() error {
|
|||
return err
|
||||
}
|
||||
|
||||
f.Fragment = pilosa.NewFragment(path, f.DB(), f.Frame(), f.Slice())
|
||||
f.Fragment = pilosa.NewFragment(path, f.DB(), f.Frame(), f.Slice(), ioutil.Discard)
|
||||
f.Fragment.BitmapAttrStore = f.BitmapAttrStore.AttrStore
|
||||
if err := f.Open(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
9
frame.go
9
frame.go
|
|
@ -2,6 +2,7 @@ package pilosa
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -32,10 +33,12 @@ type Frame struct {
|
|||
bitmapAttrStore *AttrStore
|
||||
|
||||
stats StatsClient
|
||||
|
||||
LogOutput io.Writer
|
||||
}
|
||||
|
||||
// NewFrame returns a new instance of frame.
|
||||
func NewFrame(path, db, name string) *Frame {
|
||||
func NewFrame(path, db, name string, logOutput io.Writer) *Frame {
|
||||
return &Frame{
|
||||
path: path,
|
||||
db: db,
|
||||
|
|
@ -45,6 +48,8 @@ func NewFrame(path, db, name string) *Frame {
|
|||
bitmapAttrStore: NewAttrStore(filepath.Join(path, "data")),
|
||||
|
||||
stats: NopStatsClient,
|
||||
|
||||
LogOutput: logOutput,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -281,7 +286,7 @@ func (f *Frame) createFragmentIfNotExists(slice uint64) (*Fragment, error) {
|
|||
}
|
||||
|
||||
func (f *Frame) newFragment(path string, slice uint64) *Fragment {
|
||||
frag := NewFragment(path, f.db, f.name, slice)
|
||||
frag := NewFragment(path, f.db, f.name, slice, f.LogOutput)
|
||||
frag.stats = f.stats.WithTags(fmt.Sprintf("slice:%d", slice))
|
||||
return frag
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func NewFrame() *Frame {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
return &Frame{Frame: pilosa.NewFrame(path, "d", "f")}
|
||||
return &Frame{Frame: pilosa.NewFrame(path, "d", "f", ioutil.Discard)}
|
||||
}
|
||||
|
||||
// MustOpenFrame returns a new, opened frame at a temporary path. Panic on error.
|
||||
|
|
@ -91,7 +91,7 @@ func (f *Frame) Reopen() error {
|
|||
}
|
||||
|
||||
path, db, name := f.Path(), f.DB(), f.Name()
|
||||
f.Frame = pilosa.NewFrame(path, db, name)
|
||||
f.Frame = pilosa.NewFrame(path, db, name, ioutil.Discard)
|
||||
|
||||
if err := f.Open(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -730,6 +730,7 @@ func NewHandler() *Handler {
|
|||
Handler: pilosa.NewHandler(),
|
||||
}
|
||||
h.Handler.Executor = &h.Executor
|
||||
h.Handler.LogOutput = ioutil.Discard
|
||||
return h
|
||||
}
|
||||
|
||||
|
|
|
|||
2
index.go
2
index.go
|
|
@ -187,7 +187,7 @@ func (i *Index) createDBIfNotExists(name string) (*DB, error) {
|
|||
}
|
||||
|
||||
func (i *Index) newDB(path, name string) *DB {
|
||||
db := NewDB(path, name)
|
||||
db := NewDB(path, name, i.LogOutput)
|
||||
db.stats = i.Stats.WithTags(fmt.Sprintf("db:%s", db.Name()))
|
||||
return db
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue