diff --git a/client/csv/csv.go b/client/csv/csv.go index 54335a082..a9c193d39 100644 --- a/client/csv/csv.go +++ b/client/csv/csv.go @@ -56,7 +56,7 @@ func ColumnUnmarshallerWithTimestamp(format Format, timestampFormat string) Reco column := client.Column{} parts := strings.Split(text, ",") if len(parts) < 2 { - return nil, errors.New("Invalid CSV line") + return nil, errors.New("invalid CSV line") } hasRowKey := format == RowKeyColumnID || format == RowKeyColumnKey @@ -67,7 +67,7 @@ func ColumnUnmarshallerWithTimestamp(format Format, timestampFormat string) Reco } else { column.RowID, err = strconv.ParseUint(parts[0], 10, 64) if err != nil { - return nil, errors.New("Invalid row ID") + return nil, errors.New("invalid row ID") } } @@ -76,7 +76,7 @@ func ColumnUnmarshallerWithTimestamp(format Format, timestampFormat string) Reco } else { column.ColumnID, err = strconv.ParseUint(parts[1], 10, 64) if err != nil { - return nil, errors.New("Invalid column ID") + return nil, errors.New("invalid column ID") } } @@ -166,17 +166,17 @@ func FieldValueUnmarshaller(format Format) RecordUnmarshaller { return func(text string) (client.Record, error) { parts := strings.Split(text, ",") if len(parts) < 2 { - return nil, errors.New("Invalid CSV") + return nil, errors.New("invalid CSV") } value, err := strconv.ParseInt(parts[1], 10, 64) if err != nil { - return nil, errors.New("Invalid value") + return nil, errors.New("invalid value") } switch format { case ColumnID: columnID, err := strconv.ParseUint(parts[0], 10, 64) if err != nil { - return nil, errors.New("Invalid column ID at line: %d") + return nil, errors.New("invalid column ID at line: %d") } return client.FieldValue{ ColumnID: uint64(columnID), @@ -188,7 +188,7 @@ func FieldValueUnmarshaller(format Format) RecordUnmarshaller { Value: value, }, nil default: - return nil, fmt.Errorf("Invalid format: %d", format) + return nil, fmt.Errorf("invalid format: %d", format) } } } diff --git a/cmd/badloader/badloader.go b/cmd/badloader/badloader.go index fabb50216..d64d93cde 100644 --- a/cmd/badloader/badloader.go +++ b/cmd/badloader/badloader.go @@ -20,16 +20,15 @@ import ( "context" "time" - //"fmt" "fmt" "io" "io/ioutil" gohttp "net/http" - "github.com/molecula/featurebase/v2" + pilosa "github.com/molecula/featurebase/v2" "github.com/molecula/featurebase/v2/http" pnet "github.com/molecula/featurebase/v2/net" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" "os" "strconv" @@ -38,7 +37,6 @@ import ( func UploadTar(srcFile string, client *http.InternalClient) error { t0 := time.Now() - f, err := os.Open(srcFile) if err != nil { return (err) @@ -65,7 +63,7 @@ func UploadTar(srcFile string, client *http.InternalClient) error { header, err := tarReader.Next() if err == io.EOF { if header != nil { - PanicOn("header should not be nil on err io.EOF") + vprint.PanicOn("header should not be nil on err io.EOF") } //submit any stuff we have left if len(viewData) > 0 { @@ -75,13 +73,13 @@ func UploadTar(srcFile string, client *http.InternalClient) error { // Submit(lastIndex, lastField, lastShard, request) uri := GetImportRoaringURI(lastIndex, lastShard) err := client.ImportRoaring(context.Background(), uri, lastIndex, lastField, lastShard, false, request) - PanicOn(err) + vprint.PanicOn(err) } return nil } n++ if n%500 == 0 { - VV("n = %v, progress, elapsed '%v'", n, time.Since(t0)) + vprint.VV("n = %v, progress, elapsed '%v'", n, time.Since(t0)) } parts := strings.Split(header.Name, "/") //vv("parts = '%#v'", parts) @@ -100,7 +98,7 @@ func UploadTar(srcFile string, client *http.InternalClient) error { } //vv("about to submit lastIndex='%v' lastShard='%v'", lastIndex, lastShard) uri := GetImportRoaringURI(lastIndex, lastShard) - PanicOn(client.ImportRoaring(context.Background(), uri, lastIndex, lastField, lastShard, false, request)) + vprint.PanicOn(client.ImportRoaring(context.Background(), uri, lastIndex, lastField, lastShard, false, request)) viewData = make(map[string][]byte) //vv("done with submit lastIndex='%v' lastShard='%v'; took='%v'", lastIndex, lastShard, time.Since(t0)) @@ -111,7 +109,7 @@ func UploadTar(srcFile string, client *http.InternalClient) error { return err } if _, already := viewData[view]; already { - PanicOn(fmt.Sprintf("view '%v' already present!", view)) + vprint.PanicOn(fmt.Sprintf("view '%v' already present!", view)) } viewData[view] = roaringData lastIndex = index @@ -130,12 +128,12 @@ func main() { host := "127.0.0.1:10101" h := &gohttp.Client{} c, err := http.NewInternalClient(host, h) - PanicOn(err) + vprint.PanicOn(err) tarSrcPath := "q2.tar.gz" t0 := time.Now() - PanicOn(UploadTar(tarSrcPath, c)) - VV("total elapsed '%v'", time.Since(t0)) + vprint.PanicOn(UploadTar(tarSrcPath, c)) + vprint.VV("total elapsed '%v'", time.Since(t0)) } var globURI *pnet.URI @@ -143,7 +141,7 @@ var globURI *pnet.URI func init() { var err error globURI, err = pnet.NewURIFromHostPort("127.0.0.1", 10101) - PanicOn(err) + vprint.PanicOn(err) } // get correct node to go to. diff --git a/cmd/random-query/main.go b/cmd/random-query/main.go index 1faafad1e..32c0b6552 100644 --- a/cmd/random-query/main.go +++ b/cmd/random-query/main.go @@ -26,10 +26,10 @@ import ( "strings" "time" - "github.com/molecula/featurebase/v2" + pilosa "github.com/molecula/featurebase/v2" "github.com/molecula/featurebase/v2/http" "github.com/molecula/featurebase/v2/pql" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" ) // RandomQueryConfig @@ -168,9 +168,9 @@ func (cfg *RandomQueryConfig) Run() (err error) { dur := time.Since(t0) if dur > 0 { qps := 1e9 * float64(totalQ) / float64(dur) - AlwaysPrintf("totalQueries run: %v elapsed: %v qps: %0.02f", totalQ, dur, qps) + vprint.AlwaysPrintf("totalQueries run: %v elapsed: %v qps: %0.02f", totalQ, dur, qps) } else { - AlwaysPrintf("totalQueries run: %v elapsed: %v qps: N/A", totalQ, dur) + vprint.AlwaysPrintf("totalQueries run: %v elapsed: %v qps: N/A", totalQ, dur) } } defer report() @@ -211,7 +211,7 @@ NewSetup: index := indexes[cfg.Rnd.Intn(len(indexes))] pql, err := cfg.GenQuery(index) - PanicOn(err) + vprint.PanicOn(err) if cfg.Verbose { fmt.Printf("pql = '%v'\n", pql) @@ -220,7 +220,7 @@ NewSetup: // Query node0. res, err := cli.Query(ctx, index, &pilosa.QueryRequest{Index: index, Query: pql}) if err != nil { - AlwaysPrintf("QUERY FAILED! queries before this=%v; err = '%v', pql='%v'", loops, err, pql) + vprint.AlwaysPrintf("QUERY FAILED! queries before this=%v; err = '%v', pql='%v'", loops, err, pql) return err } if cfg.VeryVerbose { @@ -356,7 +356,7 @@ func (cfg *RandomQueryConfig) Setup(api API) (err error) { pql := fmt.Sprintf("Rows(%v)", fld.Name) res, err := api.Query(ctx, ii.Name, &pilosa.QueryRequest{Index: ii.Name, Query: pql}) - PanicOn(err) + vprint.PanicOn(err) if cfg.VeryVerbose { fmt.Printf("success on pql = '%v'; res='%v'\n", pql, res.Results[0]) } @@ -379,7 +379,7 @@ func (cfg *RandomQueryConfig) Setup(api API) (err error) { case "decimal": cfg.AddIntField(ii.Name, fld.Name, fld.Options.Min, fld.Options.Max, fld.Options.Scale, fld.Options.Type == "decimal") default: - AlwaysPrintf("ignoring field %q: unhandled type %q\n", fld.Name, fld.Options.Type) + vprint.AlwaysPrintf("ignoring field %q: unhandled type %q\n", fld.Name, fld.Options.Type) } } } @@ -412,7 +412,7 @@ func (cfg *RandomQueryConfig) AddIntField(index, field string, min, max pql.Deci cfg.IndexMap[index] = f } if min.Scale != scale || max.Scale != scale { - PanicOn(fmt.Sprintf("scale error; min scale %d, max scale %d, field scale %d, assumed they'd be equal", + vprint.PanicOn(fmt.Sprintf("scale error; min scale %d, max scale %d, field scale %d, assumed they'd be equal", min.Scale, max.Scale, scale)) } diff --git a/cmd/slurp/slurp.go b/cmd/slurp/slurp.go index cee15aa4c..e97768c4a 100644 --- a/cmd/slurp/slurp.go +++ b/cmd/slurp/slurp.go @@ -30,10 +30,10 @@ import ( "strings" "time" - "github.com/molecula/featurebase/v2" + pilosa "github.com/molecula/featurebase/v2" "github.com/molecula/featurebase/v2/http" pnet "github.com/molecula/featurebase/v2/net" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" ) // slurp: slurp is a load-tester for importing bulk data. @@ -60,7 +60,7 @@ func (r *stateMachine) NewHeader(h *tar.Header, tr *tar.Reader) error { field := parts[2] view := parts[4] shard, err := strconv.ParseUint(parts[6], 10, 64) - PanicOn(err) + vprint.PanicOn(err) if index != r.lastIndex || field != r.lastField || shard != r.lastShard { err := r.Upload() if err != nil { @@ -84,7 +84,7 @@ func (r *stateMachine) NewHeader(h *tar.Header, tr *tar.Reader) error { if err != nil { return err } - VV("Finished import %v", time.Since(r.start)) + vprint.VV("Finished import %v", time.Since(r.start)) if r.profile != "" { stopProfile(r.host, r.profile) @@ -104,21 +104,21 @@ func (r *stateMachine) NewHeader(h *tar.Header, tr *tar.Reader) error { } byteData, err := ioutil.ReadAll(tr) - PanicOn(err) + vprint.PanicOn(err) br := bytes.NewReader(byteData) err = r.client.ImportFieldKeys(context.Background(), uri, index, fieldName, false, br) if err != nil { return err } default: - VV("%v", h.Name) + vprint.VV("%v", h.Name) index := parts[1] partition, err := strconv.ParseUint(v, 10, 64) if err != nil { return err } byteData, err := ioutil.ReadAll(tr) - PanicOn(err) + vprint.PanicOn(err) br := bytes.NewReader(byteData) err = r.client.ImportIndexKeys(context.Background(), uri, index, int(partition), false, br) @@ -176,10 +176,10 @@ func UploadTar(srcFile string, client *http.InternalClient, profile, host string break } if err != nil { - PanicOn(err) + vprint.PanicOn(err) } err = runner.NewHeader(header, tarReader) - PanicOn(err) + vprint.PanicOn(err) } return nil } @@ -194,7 +194,7 @@ func main() { flag.Parse() uri, err := pnet.NewURIFromAddress(host) - PanicOn(err) + vprint.PanicOn(err) globURI = uri h := &gohttp.Client{} @@ -202,12 +202,12 @@ func main() { startProfile(host) } c, err := http.NewInternalClient(host, h) - PanicOn(err) + vprint.PanicOn(err) t0 := time.Now() println("uploading", tarSrcPath) - PanicOn(UploadTar(tarSrcPath, c, profile, host)) - VV("total elapsed '%v'", time.Since(t0)) + vprint.PanicOn(UploadTar(tarSrcPath, c, profile, host)) + vprint.VV("total elapsed '%v'", time.Since(t0)) } func startProfile(host string) { @@ -248,10 +248,10 @@ func stopProfile(host, outfile string) { } fd, err := os.Create(outfile) - PanicOn(err) + vprint.PanicOn(err) defer fd.Close() _, err = io.Copy(fd, resp.Body) - PanicOn(err) + vprint.PanicOn(err) } diff --git a/ctl/backup.go b/ctl/backup.go index cdcfb1427..3a50a223b 100644 --- a/ctl/backup.go +++ b/ctl/backup.go @@ -103,7 +103,7 @@ func (cmd *BackupCommand) Run(ctx context.Context) (err error) { } } if len(indexes) <= 0 { - return fmt.Errorf("Index not found to back up") + return fmt.Errorf("index not found to back up") } } diff --git a/ctl/restore.go b/ctl/restore.go index 87d4d3c87..7d763be01 100644 --- a/ctl/restore.go +++ b/ctl/restore.go @@ -153,7 +153,7 @@ func (cmd *RestoreCommand) restoreSchema(ctx context.Context, primary *topology. //NOTE SHOULD ONLY BE ONE for _, index := range schema.Indexes { if exists(index.Name) { - return fmt.Errorf("Index Exists %v", index.Name) + return fmt.Errorf("index Exists %v", index.Name) } logger.Printf("Create INDEX %v", index.Name) err = cmd.client.CreateIndex(ctx, index.Name, index.Options) diff --git a/dbshard.go b/dbshard.go index 15bd41915..e978609ff 100644 --- a/dbshard.go +++ b/dbshard.go @@ -28,7 +28,7 @@ import ( "github.com/molecula/featurebase/v2/storage" "github.com/pkg/errors" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" ) var _ = sort.Sort @@ -279,7 +279,7 @@ func (per *DBPerShard) LoadExistingDBs() (err error) { func (txf *TxFactory) NewDBPerShard(typ txtype, holderDir string, holder *Holder) (d *DBPerShard) { if holder.cfg == nil || holder.cfg.RBFConfig == nil || holder.cfg.StorageConfig == nil { - PanicOn("must have holder.cfg.RBFConfig and holder.cfg.StorageConfig set here") + vprint.PanicOn("must have holder.cfg.RBFConfig and holder.cfg.StorageConfig set here") } hasRoaring := false @@ -422,7 +422,7 @@ func (per *DBPerShard) unprotectedGetDBShard(index string, shard uint64, idx *In if dbs != nil && dbs.closed { // roaring txn are nil/fake anyway. Don't freak out. if per.typ != roaringTxn { - PanicOn(fmt.Sprintf("cannot retain closed dbs across holder ReOpen dbs='%p'; per.typ='%v'", dbs, per.typ)) + vprint.PanicOn(fmt.Sprintf("cannot retain closed dbs across holder ReOpen dbs='%p'; per.typ='%v'", dbs, per.typ)) } } if !ok { @@ -449,11 +449,11 @@ func (per *DBPerShard) unprotectedGetDBShard(index string, shard uint64, idx *In registry = globalRbfDBReg registry.(*rbfDBRegistrar).SetRBFConfig(per.RBFConfig) default: - PanicOn(fmt.Sprintf("unknown txtyp: '%v'", dbs.typ)) + vprint.PanicOn(fmt.Sprintf("unknown txtyp: '%v'", dbs.typ)) } path := dbs.pathForType(dbs.typ) w, err := registry.OpenDBWrapper(path, DetectMemAccessPastTx, per.StorageConfig) - PanicOn(err) + vprint.PanicOn(err) h := idx.Holder() w.SetHolder(h) dbs.Open = true @@ -470,7 +470,7 @@ func (per *DBPerShard) Close() (err error) { for _, dbi := range per.dbh.Index { for _, dbs := range dbi.Shard { err = dbs.Close() - PanicOn(err) + vprint.PanicOn(err) } } return @@ -546,7 +546,7 @@ func (per *DBPerShard) TypedDBPerShardGetShardsForIndex(ty txtype, idx *Index, r ignoreEmpty := false includeRoot := true dbf, err := listDirUnderDir(path, includeRoot, ignoreEmpty) - PanicOn(err) + vprint.PanicOn(err) for _, nm := range dbf { base := filepath.Base(nm) @@ -561,7 +561,7 @@ func (per *DBPerShard) TypedDBPerShardGetShardsForIndex(ty txtype, idx *Index, r // Parse filename into integer. shard, err := strconv.ParseUint(base[lenOfShardPrefix:], 10, 64) if err != nil { - PanicOn(err) + vprint.PanicOn(err) continue } diff --git a/etcd/embed.go b/etcd/embed.go index 7da2c9806..6a939fb4a 100644 --- a/etcd/embed.go +++ b/etcd/embed.go @@ -555,7 +555,7 @@ func (e *Etcd) deleteNodeData(key []byte, revision int64) error { e.knownNodes[peerID].resizeState = "" e.nodeStatesDirty = true default: - return fmt.Errorf("node watch: invalid prefix %q\n", prefix) + return fmt.Errorf("node watch: invalid prefix %q", prefix) } return nil } @@ -586,7 +586,7 @@ func (e *Etcd) putNodeData(key []byte, value []byte, revision int64) (err error) var newNode topology.Node err := json.Unmarshal(value, &newNode) if err != nil { - return fmt.Errorf("json unmarshal of node metadata: %v\n", err) + return fmt.Errorf("json unmarshal of node metadata: %v", err) } e.knownNodes[peerID].topologyNode = &newNode // This saves us one remake of the node later, probably. @@ -599,7 +599,7 @@ func (e *Etcd) putNodeData(key []byte, value []byte, revision int64) (err error) e.knownNodes[peerID].resizeState = string(value) e.nodeStatesDirty = true default: - return fmt.Errorf("node watch: invalid prefix %q\n", prefix) + return fmt.Errorf("node watch: invalid prefix %q", prefix) } return nil } diff --git a/fragment.go b/fragment.go index 674f2da65..613f4bc27 100644 --- a/fragment.go +++ b/fragment.go @@ -51,7 +51,7 @@ import ( "github.com/molecula/featurebase/v2/testhook" "github.com/molecula/featurebase/v2/topology" "github.com/molecula/featurebase/v2/tracing" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" "github.com/pkg/errors" ) @@ -204,7 +204,7 @@ func newFragment(holder *Holder, spec fragSpec, shard uint64, flags byte) *fragm idx := holder.Index(spec.index.name) if idx == nil { - PanicOn(fmt.Sprintf("got nil idx back for '%v' from holder!", spec.index)) + vprint.PanicOn(fmt.Sprintf("got nil idx back for '%v' from holder!", spec.index)) } f := &fragment{ @@ -615,7 +615,7 @@ func (f *fragment) row(tx Tx, rowID uint64) (*Row, error) { func (f *fragment) mustRow(tx Tx, rowID uint64) *Row { row, err := f.row(tx, rowID) if err != nil { - PanicOn(err) + vprint.PanicOn(err) } return row } @@ -1072,7 +1072,7 @@ func (f *fragment) setValueBase(txOrig Tx, columnID uint64, bitDepth uint64, val tx = f.idx.holder.txf.NewTx(Txo{Write: writable, Index: f.idx, Fragment: f, Shard: f.shard}) defer func() { if err == nil { - PanicOn(tx.Commit()) + vprint.PanicOn(tx.Commit()) } else { tx.Rollback() } @@ -1975,7 +1975,7 @@ func (f *fragment) Blocks() ([]FragmentBlock, error) { idx := f.holder.Index(f.index()) if idx == nil { err := fmt.Errorf("index() was nil in fragment.Blocks(): f.index()='%v'", f.index()) - PanicOn(err) + vprint.PanicOn(err) return nil, err } tx := idx.holder.txf.NewTx(Txo{Write: !writable, Index: idx, Fragment: f, Shard: f.shard}) @@ -2350,7 +2350,7 @@ func (p *parallelSlices) fullPrune() { return } if len(p.rows) != len(p.cols) { - PanicOn("parallelSlices must have same length for rows and columns") + vprint.PanicOn("parallelSlices must have same length for rows and columns") } unsorted := p.prune() if unsorted { diff --git a/holder.go b/holder.go index 909bd6ecd..a1770adaf 100644 --- a/holder.go +++ b/holder.go @@ -36,7 +36,7 @@ import ( "github.com/molecula/featurebase/v2/storage" "github.com/molecula/featurebase/v2/testhook" "github.com/molecula/featurebase/v2/topology" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) @@ -300,7 +300,7 @@ func NewHolder(path string, cfg *HolderConfig) *Holder { storage.SetRowCacheOn(cfg.RowcacheOn) txf, err := NewTxFactory(cfg.StorageConfig.Backend, h.IndexesPath(), h) - PanicOn(err) + vprint.PanicOn(err) h.txf = txf _ = testhook.Created(h.Auditor, h, nil) diff --git a/http/client.go b/http/client.go index 628c2a390..8f78dde4d 100644 --- a/http/client.go +++ b/http/client.go @@ -667,6 +667,9 @@ func (c *InternalClient) importHelper(ctx context.Context, req pilosa.Message, p // request over the wire, even though we still have to go through // the http interface. nodes, err = c.Nodes(ctx) + if err != nil { + return errors.Wrap(err, "getting nodes") + } } // "us" is a usable local node if any, "them" is every node that we need diff --git a/internal/clustertests/pause_node_test.go b/internal/clustertests/pause_node_test.go index 2de330a74..7558af214 100644 --- a/internal/clustertests/pause_node_test.go +++ b/internal/clustertests/pause_node_test.go @@ -31,7 +31,6 @@ import ( boltdb "github.com/molecula/featurebase/v2/boltdb" "github.com/molecula/featurebase/v2/disco" "github.com/molecula/featurebase/v2/http" - picli "github.com/molecula/featurebase/v2/http" "github.com/molecula/featurebase/v2/net" "github.com/molecula/featurebase/v2/topology" "github.com/pkg/errors" @@ -81,7 +80,7 @@ func getAddress(node string) string { func getClients(addrs []string) ([]*http.InternalClient, error) { clients := make([]*http.InternalClient, 0, len(addrs)) for _, addr := range addrs { - c, err := picli.NewInternalClient(addr, picli.GetHTTPClient(nil)) + c, err := http.NewInternalClient(addr, http.GetHTTPClient(nil)) if err != nil { return nil, err } @@ -102,7 +101,7 @@ func getURIsFromAddresses(addrs []string) ([]*net.URI, error) { return uris, nil } -func readIndexTranslateData(ctx context.Context, client *picli.InternalClient, dirPath, index string, partition int) error { +func readIndexTranslateData(ctx context.Context, client *http.InternalClient, dirPath, index string, partition int) error { // read translateStore contents from endpoint r, err := client.IndexTranslateDataReader(ctx, index, partition) if err != nil { @@ -186,7 +185,7 @@ var errOpRetriable = errors.New("If operation failed on this error, it can be re func verifyNodeHasGivenKeys(ctx context.Context, node, index, dirPath string, keys []string) error { // get client that's connected to node address := getAddress(node) - client, err := picli.NewInternalClient(address, picli.GetHTTPClient(nil)) + client, err := http.NewInternalClient(address, http.GetHTTPClient(nil)) if err != nil { return err } diff --git a/lru/lru.go b/lru/lru.go index 7f2e6dc22..59f71f69a 100644 --- a/lru/lru.go +++ b/lru/lru.go @@ -82,16 +82,6 @@ func (c *Cache) Get(key Key) (value interface{}, ok bool) { return nil, false } -// remove removes the provided key from the cache. -func (c *Cache) remove(key Key) { // nolint: staticcheck,unused - if c.cache == nil { - return - } - if ele, hit := c.cache[key]; hit { - c.removeElement(ele) - } -} - // removeOldest removes the oldest item from the cache. func (c *Cache) removeOldest() { if c.cache == nil { @@ -119,15 +109,3 @@ func (c *Cache) Len() int { } return c.ll.Len() } - -// clear purges all stored items from the cache. -func (c *Cache) clear() { // nolint: staticcheck,unused - if c.OnEvicted != nil { - for _, e := range c.cache { - kv := e.Value.(*entry) - c.OnEvicted(kv.key, kv.value) - } - } - c.ll = nil - c.cache = nil -} diff --git a/pprof.go b/pprof.go index 6e10c0bb5..ff34a7544 100644 --- a/pprof.go +++ b/pprof.go @@ -24,7 +24,7 @@ import ( _ "net/http/pprof" // Imported for its side-effect of registering pprof endpoints with the server. "github.com/molecula/featurebase/v2/storage" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" ) // CPUProfileForDur (where "Dur" is short for "Duration"), is used for @@ -38,18 +38,18 @@ func CPUProfileForDur(dur time.Duration, outpath string) { } path := outpath + "." + backend f, err := os.Create(path) - PanicOn(err) + vprint.PanicOn(err) if dur == 0 { dur = time.Minute } - AlwaysPrintf("starting cpu profile for dur '%v', output to '%v'", dur, path) + vprint.AlwaysPrintf("starting cpu profile for dur '%v', output to '%v'", dur, path) _ = pprof.StartCPUProfile(f) go func() { <-time.After(dur) pprof.StopCPUProfile() f.Close() - AlwaysPrintf("stopping cpu profile after dur '%v', output: '%v'", dur, path) + vprint.AlwaysPrintf("stopping cpu profile after dur '%v', output: '%v'", dur, path) }() } @@ -64,20 +64,20 @@ func MemProfileForDur(dur time.Duration, outpath string) { } path := outpath + "." + backend f, err := os.Create(path) - PanicOn(err) + vprint.PanicOn(err) if dur == 0 { dur = time.Minute } - AlwaysPrintf("will write memory profile after dur '%v', output to '%v'", dur, path) + vprint.AlwaysPrintf("will write memory profile after dur '%v', output to '%v'", dur, path) go func() { <-time.After(dur) runtime.GC() // get up-to-date statistics if err := pprof.WriteHeapProfile(f); err != nil { - PanicOn(fmt.Sprintf("could not write memory profile: %v", err)) + vprint.PanicOn(fmt.Sprintf("could not write memory profile: %v", err)) } f.Close() - AlwaysPrintf("wrote memory profile after dur '%v', output: '%v'", dur, path) + vprint.AlwaysPrintf("wrote memory profile after dur '%v', output: '%v'", dur, path) }() } @@ -92,7 +92,7 @@ var _ = pprofProfile{} func newPprof() (pp *pprofProfile) { pp = &pprofProfile{} f, err := os.Create("cpu.manual.pprof") - PanicOn(err) + vprint.PanicOn(err) pp.fdCpu = f _ = pprof.StartCPUProfile(pp.fdCpu) @@ -105,11 +105,11 @@ func (pp *pprofProfile) Close() { pp.fdCpu.Close() f, err := os.Create("mem.manual.pprof") - PanicOn(err) + vprint.PanicOn(err) runtime.GC() // get up-to-date statistics if err := pprof.WriteHeapProfile(f); err != nil { - PanicOn(fmt.Sprintf("could not write memory profile: %v", err)) + vprint.PanicOn(fmt.Sprintf("could not write memory profile: %v", err)) } f.Close() } diff --git a/pql/ast.go b/pql/ast.go index dddf72812..4e9dc1f2a 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -586,7 +586,7 @@ func (c *Call) CheckCallInfo() error { case string, int64: continue default: - return fmt.Errorf("'%s': arg '%s' needed a string or integer value, got %T.", + return fmt.Errorf("'%s': arg '%s' needed a string or integer value, got %T", c.String(), k, v) } } diff --git a/rbf.go b/rbf.go index 910ecce78..b75efa331 100644 --- a/rbf.go +++ b/rbf.go @@ -28,7 +28,7 @@ import ( txkey "github.com/molecula/featurebase/v2/short_txkey" "github.com/molecula/featurebase/v2/storage" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v2/vprint" "github.com/pkg/errors" ) @@ -411,7 +411,7 @@ func (tx *RBFTx) ImportRoaringBits(index, field, view string, shard uint64, rit func (tx *RBFTx) NewTxIterator(index, field, view string, shard uint64) *roaring.Iterator { b, err := tx.RoaringBitmap(index, field, view, shard) - PanicOn(err) + vprint.PanicOn(err) return b.Iterator() } diff --git a/rbf/rbf.go b/rbf/rbf.go index 2245cf189..8cba59f4d 100644 --- a/rbf/rbf.go +++ b/rbf/rbf.go @@ -30,7 +30,7 @@ import ( "github.com/benbjohnson/immutable" "github.com/molecula/featurebase/v2/roaring" "github.com/molecula/featurebase/v2/shardwidth" - . "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v2/vprint" ) const ( @@ -356,7 +356,7 @@ func (c *leafCell) Bitmap(tx *Tx) []uint64 { _, bm, _ := tx.leafCellBitmap(toPgno(c.Data)) return bm default: - PanicOn(fmt.Errorf("invalid container type: %d", c.Type)) + vprint.PanicOn(fmt.Errorf("invalid container type: %d", c.Type)) } return nil } @@ -383,7 +383,7 @@ func (c *leafCell) Values(tx *Tx) []uint16 { case ContainerTypeNone: return []uint16{} default: - PanicOn(fmt.Errorf("invalid container type: %d", c.Type)) + vprint.PanicOn(fmt.Errorf("invalid container type: %d", c.Type)) } return nil } @@ -411,7 +411,7 @@ func (c *leafCell) firstValue(tx *Tx) uint16 { return r[0].Start case ContainerTypeBitmapPtr: _, slc, err := tx.leafCellBitmap(toPgno(c.Data)) - PanicOn(err) + vprint.PanicOn(err) for i, v := range slc { for j := uint(0); j < 64; j++ { if v&(1<