mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 00:25:55 +00:00
Merge pull request #263 from jaffee/more-log-work
thread logoutput index -> db -> frame -> fragment
This commit is contained in:
commit
3266a0ff56
6 changed files with 16 additions and 4 deletions
7
db.go
7
db.go
|
|
@ -3,6 +3,7 @@ package pilosa
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -34,6 +35,8 @@ type DB struct {
|
|||
profileAttrStore *AttrStore
|
||||
|
||||
stats StatsClient
|
||||
|
||||
LogOutput io.Writer
|
||||
}
|
||||
|
||||
// NewDB returns a new instance of DB.
|
||||
|
|
@ -46,7 +49,8 @@ func NewDB(path, name string) *DB {
|
|||
|
||||
profileAttrStore: NewAttrStore(filepath.Join(path, "data")),
|
||||
|
||||
stats: NopStatsClient,
|
||||
stats: NopStatsClient,
|
||||
LogOutput: ioutil.Discard,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -271,6 +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.LogOutput = db.LogOutput
|
||||
f.stats = db.stats.WithTags(fmt.Sprintf("frame:%s", name))
|
||||
return f
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ func NewDB() *DB {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return &DB{DB: pilosa.NewDB(path, "d")}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ func NewFragment(path, db, frame string, slice uint64) *Fragment {
|
|||
frame: frame,
|
||||
slice: slice,
|
||||
|
||||
LogOutput: os.Stderr,
|
||||
LogOutput: ioutil.Discard,
|
||||
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
|
||||
|
|
|
|||
6
frame.go
6
frame.go
|
|
@ -2,6 +2,7 @@ package pilosa
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -32,6 +33,8 @@ type Frame struct {
|
|||
bitmapAttrStore *AttrStore
|
||||
|
||||
stats StatsClient
|
||||
|
||||
LogOutput io.Writer
|
||||
}
|
||||
|
||||
// NewFrame returns a new instance of frame.
|
||||
|
|
@ -45,6 +48,8 @@ func NewFrame(path, db, name string) *Frame {
|
|||
bitmapAttrStore: NewAttrStore(filepath.Join(path, "data")),
|
||||
|
||||
stats: NopStatsClient,
|
||||
|
||||
LogOutput: ioutil.Discard,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -282,6 +287,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.LogOutput = f.LogOutput
|
||||
frag.stats = f.stats.WithTags(fmt.Sprintf("slice:%d", slice))
|
||||
return frag
|
||||
}
|
||||
|
|
|
|||
|
|
@ -730,6 +730,7 @@ func NewHandler() *Handler {
|
|||
Handler: pilosa.NewHandler(),
|
||||
}
|
||||
h.Handler.Executor = &h.Executor
|
||||
h.Handler.LogOutput = ioutil.Discard
|
||||
return h
|
||||
}
|
||||
|
||||
|
|
|
|||
1
index.go
1
index.go
|
|
@ -188,6 +188,7 @@ func (i *Index) createDBIfNotExists(name string) (*DB, error) {
|
|||
|
||||
func (i *Index) newDB(path, name string) *DB {
|
||||
db := NewDB(path, name)
|
||||
db.LogOutput = i.LogOutput
|
||||
db.stats = i.Stats.WithTags(fmt.Sprintf("db:%s", db.Name()))
|
||||
return db
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue