mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-08 03:47:51 +00:00
Fix linter issues: unused
This commit is contained in:
parent
f01d850b17
commit
e9523063b5
9 changed files with 4 additions and 150 deletions
1
Makefile
1
Makefile
|
|
@ -125,6 +125,7 @@ gometalinter: require-gometalinter
|
|||
--enable=misspell \
|
||||
--enable=nakedret \
|
||||
--enable=unparam \
|
||||
--enable=unused \
|
||||
--enable=vet \
|
||||
--exclude "^internal/.*\.pb\.go" \
|
||||
--exclude "^pql/pql.peg.go" \
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ func (s *attrStore) SetBulkAttrs(m map[uint64]map[string]interface{}) error {
|
|||
for id := range m {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
sort.Sort(uint64Slice(ids))
|
||||
sort.Slice(ids, func(i, j int) bool { return ids[i] < ids[j] })
|
||||
|
||||
// Update attributes for each id.
|
||||
for _, id := range ids {
|
||||
|
|
@ -357,42 +357,6 @@ func mapContains(m, subset map[string]interface{}) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// uint64Slice represents a sortable slice of uint64 numbers.
|
||||
type uint64Slice []uint64
|
||||
|
||||
func (p uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
func (p uint64Slice) Len() int { return len(p) }
|
||||
func (p uint64Slice) Less(i, j int) bool { return p[i] < p[j] }
|
||||
|
||||
// merge combines p and other to a unique sorted set of values.
|
||||
// p and other must both have unique sets and be sorted.
|
||||
func (p uint64Slice) merge(other []uint64) []uint64 {
|
||||
ret := make([]uint64, 0, len(p))
|
||||
|
||||
i, j := 0, 0
|
||||
for i < len(p) && j < len(other) {
|
||||
a, b := p[i], other[j]
|
||||
if a == b {
|
||||
ret = append(ret, a)
|
||||
i, j = i+1, j+1
|
||||
} else if a < b {
|
||||
ret = append(ret, a)
|
||||
i++
|
||||
} else {
|
||||
ret = append(ret, b)
|
||||
j++
|
||||
}
|
||||
}
|
||||
|
||||
if i < len(p) {
|
||||
ret = append(ret, p[i:]...)
|
||||
} else if j < len(other) {
|
||||
ret = append(ret, other[j:]...)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
// blockCursor represents a cursor for iterating over blocks of a bolt bucket.
|
||||
type blockCursor struct {
|
||||
cur *bolt.Cursor
|
||||
|
|
|
|||
|
|
@ -569,13 +569,6 @@ func fragsDiff(a, b []frag) []frag {
|
|||
|
||||
type fragsByHost map[string][]frag
|
||||
|
||||
func (a fragsByHost) add(b fragsByHost) fragsByHost {
|
||||
for k, v := range b {
|
||||
a[k] = append(a[k], v...)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
type viewsByField map[string][]string
|
||||
|
||||
func (a viewsByField) addView(field, view string) {
|
||||
|
|
|
|||
72
field.go
72
field.go
|
|
@ -514,43 +514,6 @@ func (f *Field) addBSIGroup(bsig *bsiGroup) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// deleteBSIGroupAndView deletes an existing bsiGroup on the schema.
|
||||
func (f *Field) deleteBSIGroupAndView(name string) error {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
|
||||
// Remove bsiGroup.
|
||||
if err := f.deleteBSIGroup(name); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove views.
|
||||
viewName := viewBSIGroupPrefix + name
|
||||
if view := f.viewMap[viewName]; view != nil {
|
||||
delete(f.viewMap, viewName)
|
||||
|
||||
if err := view.close(); err != nil {
|
||||
return errors.Wrap(err, "closing view")
|
||||
} else if err := os.RemoveAll(view.path); err != nil {
|
||||
return errors.Wrap(err, "deleting directory")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// deleteBSIGroup removes a single bsiGroup from bsiGroups.
|
||||
func (f *Field) deleteBSIGroup(name string) error {
|
||||
for i, bsig := range f.bsiGroups {
|
||||
if bsig.Name == name {
|
||||
copy(f.bsiGroups[i:], f.bsiGroups[i+1:])
|
||||
f.bsiGroups, f.bsiGroups[len(f.bsiGroups)-1] = f.bsiGroups[:len(f.bsiGroups)-1], nil
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return ErrBSIGroupNotFound
|
||||
}
|
||||
|
||||
// TimeQuantum returns the time quantum for the field.
|
||||
func (f *Field) TimeQuantum() TimeQuantum {
|
||||
f.mu.Lock()
|
||||
|
|
@ -619,18 +582,6 @@ func (f *Field) views() []*view {
|
|||
return other
|
||||
}
|
||||
|
||||
// viewNames returns a list of all views (as a string) in the field.
|
||||
func (f *Field) viewNames() []string {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
|
||||
other := make([]string, 0, len(f.viewMap))
|
||||
for viewName := range f.viewMap {
|
||||
other = append(other, viewName)
|
||||
}
|
||||
return other
|
||||
}
|
||||
|
||||
// recalculateCaches recalculates caches on every view in the field.
|
||||
func (f *Field) recalculateCaches() {
|
||||
for _, view := range f.views() {
|
||||
|
|
@ -979,29 +930,6 @@ func (f *Field) Range(name string, op pql.Token, predicate int64) (*Row, error)
|
|||
return view.rangeOp(op, bsig.BitDepth(), baseValue)
|
||||
}
|
||||
|
||||
func (f *Field) rangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) {
|
||||
// Retrieve and validate bsiGroup.
|
||||
bsig := f.bsiGroup(name)
|
||||
if bsig == nil {
|
||||
return nil, ErrBSIGroupNotFound
|
||||
} else if predicateMin > predicateMax {
|
||||
return nil, ErrInvalidBetweenValue
|
||||
}
|
||||
|
||||
// Retrieve bsiGroup's view.
|
||||
view := f.view(viewBSIGroupPrefix + name)
|
||||
if view == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
baseValueMin, baseValueMax, outOfRange := bsig.baseValueBetween(predicateMin, predicateMax)
|
||||
if outOfRange {
|
||||
return NewRow(), nil
|
||||
}
|
||||
|
||||
return view.rangeBetween(bsig.BitDepth(), baseValueMin, baseValueMax)
|
||||
}
|
||||
|
||||
// Import bulk imports data.
|
||||
func (f *Field) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) error {
|
||||
// Determine quantum if timestamps are set.
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ type Handler struct {
|
|||
|
||||
api *pilosa.API
|
||||
|
||||
allowedOrigins []string
|
||||
|
||||
ln net.Listener
|
||||
|
||||
closeTimeout time.Duration
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ func (c *Cache) Get(key Key) (value interface{}, ok bool) {
|
|||
}
|
||||
|
||||
// remove removes the provided key from the cache.
|
||||
func (c *Cache) remove(key Key) {
|
||||
func (c *Cache) remove(key Key) { // nolint: unused
|
||||
if c.cache == nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -121,7 +121,7 @@ func (c *Cache) Len() int {
|
|||
}
|
||||
|
||||
// clear purges all stored items from the cache.
|
||||
func (c *Cache) clear() {
|
||||
func (c *Cache) clear() { // nolint: unused
|
||||
if c.OnEvicted != nil {
|
||||
for _, e := range c.cache {
|
||||
kv := e.Value.(*entry)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"sort"
|
||||
|
|
@ -253,15 +252,6 @@ func TestConfig_Parse_DataDir(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
// tempMkdir makes a temporary directory
|
||||
func tempMkdir(t *testing.T) string {
|
||||
dir, err := ioutil.TempDir("", "pilosatemp")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create test directory: %s", err)
|
||||
}
|
||||
return dir
|
||||
}
|
||||
|
||||
func TestMain_RecalculateHashes(t *testing.T) {
|
||||
const clusterSize = 5
|
||||
cluster := test.MustRunCluster(t, clusterSize)
|
||||
|
|
|
|||
|
|
@ -875,12 +875,6 @@ type elem struct {
|
|||
hash uint64
|
||||
}
|
||||
|
||||
func (e *elem) reset() {
|
||||
e.offset = 0
|
||||
e.id = 0
|
||||
e.hash = 0
|
||||
}
|
||||
|
||||
func hashKey(key []byte) uint64 {
|
||||
h := xxhash.Sum64(key)
|
||||
if h == 0 {
|
||||
|
|
|
|||
14
view.go
14
view.go
|
|
@ -413,20 +413,6 @@ func (v *view) rangeOp(op pql.Token, bitDepth uint, predicate uint64) (*Row, err
|
|||
return r, nil
|
||||
}
|
||||
|
||||
// rangeBetween returns bitmaps with a field value encoding matching any
|
||||
// value between predicateMin and predicateMax.
|
||||
func (v *view) rangeBetween(bitDepth uint, predicateMin, predicateMax uint64) (*Row, error) {
|
||||
r := NewRow()
|
||||
for _, frag := range v.allFragments() {
|
||||
other, err := frag.rangeBetween(bitDepth, predicateMin, predicateMax)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r = r.Union(other)
|
||||
}
|
||||
return r, nil
|
||||
}
|
||||
|
||||
// ViewInfo represents schema information for a view.
|
||||
type ViewInfo struct {
|
||||
Name string `json:"name"`
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue