From b4011778dd03aaf91c43e057928d4531368cc987 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:27:59 -0500 Subject: [PATCH 001/138] Unexport APIOption, b.BTCIterator, API.Holder, API.Serializer, APIOption, http.Handler.API --- api.go | 8 ++-- enterprise/b/containers_btree.go | 8 ++-- http/handler.go | 76 ++++++++++++++++---------------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/api.go b/api.go index 679ab46de..2a20c6234 100644 --- a/api.go +++ b/api.go @@ -40,10 +40,10 @@ type API struct { Serializer Serializer } -// APIOption is a functional option type for pilosa.API -type APIOption func(*API) error +// apiOption is a functional option type for pilosa.API +type apiOption func(*API) error -func OptAPIServer(s *Server) APIOption { +func OptAPIServer(s *Server) apiOption { return func(a *API) error { a.server = s a.holder = s.holder @@ -54,7 +54,7 @@ func OptAPIServer(s *Server) APIOption { } // NewAPI returns a new API instance. -func NewAPI(opts ...APIOption) (*API, error) { +func NewAPI(opts ...apiOption) (*API, error) { api := &API{} for _, opt := range opts { diff --git a/enterprise/b/containers_btree.go b/enterprise/b/containers_btree.go index 7c208b1db..71727700f 100644 --- a/enterprise/b/containers_btree.go +++ b/enterprise/b/containers_btree.go @@ -172,18 +172,18 @@ func (btc *BTreeContainers) Iterator(key uint64) (citer roaring.ContainerIterato found = true } - return &BTCIterator{ + return &btcIterator{ e: e, }, found } -type BTCIterator struct { +type btcIterator struct { e *Enumerator key uint64 val *roaring.Container } -func (i *BTCIterator) Next() bool { +func (i *btcIterator) Next() bool { k, v, err := i.e.Next() if err == io.EOF { @@ -194,7 +194,7 @@ func (i *BTCIterator) Next() bool { return true } -func (i *BTCIterator) Value() (uint64, *roaring.Container) { +func (i *btcIterator) Value() (uint64, *roaring.Container) { if i.val == nil { return 0, nil } diff --git a/http/handler.go b/http/handler.go index a221b1445..0693a4d17 100644 --- a/http/handler.go +++ b/http/handler.go @@ -49,7 +49,7 @@ type Handler struct { // Keeps the query argument validators for each handler validators map[string]*queryValidationSpec - API *pilosa.API + api *pilosa.API AllowedOrigins []string @@ -90,7 +90,7 @@ func OptHandlerAllowedOrigins(origins []string) HandlerOption { func OptHandlerAPI(api *pilosa.API) HandlerOption { return func(h *Handler) error { - h.API = api + h.api = api return nil } } @@ -124,7 +124,7 @@ func NewHandler(opts ...HandlerOption) (*Handler, error) { } } - if handler.API == nil { + if handler.api == nil { return nil, errors.New("must pass OptHandlerAPI") } @@ -252,7 +252,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Calculate per request StatsD metrics when the handler is fully configured. statsTags := make([]string, 0, 3) - longQueryTime := h.API.LongQueryTime() + longQueryTime := h.api.LongQueryTime() if longQueryTime > 0 && dif > longQueryTime { h.Logger.Printf("%s %s %v", r.Method, r.URL.String(), dif) statsTags = append(statsTags, "slow_query") @@ -267,7 +267,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // useragent tag identifies internal/external endpoints statsTags = append(statsTags, "useragent:"+r.UserAgent()) - stats := h.API.StatsWithTags(statsTags) + stats := h.api.StatsWithTags(statsTags) if stats != nil { stats.Histogram("http."+endpointName, float64(dif), 0.1) } @@ -355,7 +355,7 @@ func (h *Handler) handleGetSchema(w http.ResponseWriter, r *http.Request) { return } - schema := h.API.Schema(r.Context()) + schema := h.api.Schema(r.Context()) if err := json.NewEncoder(w).Encode(map[string]interface{}{"indexes": schema}); err != nil { h.Logger.Printf("write schema response error: %s", err) } @@ -368,9 +368,9 @@ func (h *Handler) handleGetStatus(w http.ResponseWriter, r *http.Request) { return } status := getStatusResponse{ - State: h.API.State(), - Nodes: h.API.Hosts(r.Context()), - LocalID: h.API.Node().ID, + State: h.api.State(), + Nodes: h.api.Hosts(r.Context()), + LocalID: h.api.Node().ID, } if err := json.NewEncoder(w).Encode(status); err != nil { h.Logger.Printf("write status response error: %s", err) @@ -382,7 +382,7 @@ func (h *Handler) handleGetInfo(w http.ResponseWriter, r *http.Request) { http.Error(w, "JSON only acceptable response", http.StatusNotAcceptable) return } - info := h.API.Info() + info := h.api.Info() if err := json.NewEncoder(w).Encode(info); err != nil { h.Logger.Printf("write info response error: %s", err) } @@ -410,7 +410,7 @@ func (h *Handler) handlePostQuery(w http.ResponseWriter, r *http.Request) { // TODO: Remove req.Index = mux.Vars(r)["index"] - resp, err := h.API.Query(r.Context(), req) + resp, err := h.api.Query(r.Context(), req) if err != nil { switch errors.Cause(resp.Err) { case pilosa.ErrTooManyWrites: @@ -447,7 +447,7 @@ func (h *Handler) handleGetShardsMax(w http.ResponseWriter, r *http.Request) { return } if err := json.NewEncoder(w).Encode(getShardsMaxResponse{ - Standard: h.API.MaxShards(r.Context()), + Standard: h.api.MaxShards(r.Context()), }); err != nil { h.Logger.Printf("write shards-max response error: %s", err) } @@ -469,7 +469,7 @@ func (h *Handler) handleGetIndex(w http.ResponseWriter, r *http.Request) { return } indexName := mux.Vars(r)["index"] - for _, idx := range h.API.Schema(r.Context()) { + for _, idx := range h.api.Schema(r.Context()) { if idx.Name == indexName { if err := json.NewEncoder(w).Encode(idx); err != nil { h.Logger.Printf("write response error: %s", err) @@ -563,7 +563,7 @@ func (h *Handler) handleDeleteIndex(w http.ResponseWriter, r *http.Request) { indexName := mux.Vars(r)["index"] resp := successResponse{} - err := h.API.DeleteIndex(r.Context(), indexName) + err := h.api.DeleteIndex(r.Context(), indexName) resp.write(w, err) } @@ -584,7 +584,7 @@ func (h *Handler) handlePostIndex(w http.ResponseWriter, r *http.Request) { resp.write(w, err) return } - _, err = h.API.CreateIndex(r.Context(), indexName, req.Options) + _, err = h.api.CreateIndex(r.Context(), indexName, req.Options) resp.write(w, err) } @@ -604,7 +604,7 @@ func (h *Handler) handlePostIndexAttrDiff(w http.ResponseWriter, r *http.Request return } - attrs, err := h.API.IndexAttrDiff(r.Context(), indexName, req.Blocks) + attrs, err := h.api.IndexAttrDiff(r.Context(), indexName, req.Blocks) if err != nil { if errors.Cause(err) == pilosa.ErrIndexNotFound { http.Error(w, err.Error(), http.StatusNotFound) @@ -673,7 +673,7 @@ func (h *Handler) handlePostField(w http.ResponseWriter, r *http.Request) { } } - _, err = h.API.CreateField(r.Context(), indexName, fieldName, fos...) + _, err = h.api.CreateField(r.Context(), indexName, fieldName, fos...) resp.write(w, err) } @@ -760,7 +760,7 @@ func (h *Handler) handleDeleteField(w http.ResponseWriter, r *http.Request) { fieldName := mux.Vars(r)["field"] resp := successResponse{} - err := h.API.DeleteField(r.Context(), indexName, fieldName) + err := h.api.DeleteField(r.Context(), indexName, fieldName) resp.write(w, err) } @@ -780,7 +780,7 @@ func (h *Handler) handlePostFieldAttrDiff(w http.ResponseWriter, r *http.Request return } - attrs, err := h.API.FieldAttrDiff(r.Context(), indexName, fieldName, req.Blocks) + attrs, err := h.api.FieldAttrDiff(r.Context(), indexName, fieldName, req.Blocks) if err != nil { switch errors.Cause(err) { case pilosa.ErrFragmentNotFound: @@ -826,7 +826,7 @@ func (h *Handler) readProtobufQueryRequest(r *http.Request) (*pilosa.QueryReques } qreq := &pilosa.QueryRequest{} - err = h.API.Serializer.Unmarshal(body, qreq) + err = h.api.Serializer.Unmarshal(body, qreq) if err != nil { return nil, errors.Wrap(err, "unmarshalling query request") } @@ -869,7 +869,7 @@ func (h *Handler) writeQueryResponse(w http.ResponseWriter, r *http.Request, res // writeProtobufQueryResponse writes the response from the executor to w as protobuf. func (h *Handler) writeProtobufQueryResponse(w http.ResponseWriter, resp *pilosa.QueryResponse) error { - if buf, err := h.API.Serializer.Marshal(resp); err != nil { + if buf, err := h.api.Serializer.Marshal(resp); err != nil { return errors.Wrap(err, "marshalling") } else if _, err := w.Write(buf); err != nil { return errors.Wrap(err, "writing") @@ -897,7 +897,7 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) { // Get index and field type to determine how to handle the // import data. - field, err := h.API.Field(r.Context(), indexName, fieldName) + field, err := h.api.Field(r.Context(), indexName, fieldName) if err != nil { switch errors.Cause(err) { case pilosa.ErrIndexNotFound: @@ -922,12 +922,12 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) { // Field type: Int // Marshal into request object. req := &pilosa.ImportValueRequest{} - if err := h.API.Serializer.Unmarshal(body, req); err != nil { + if err := h.api.Serializer.Unmarshal(body, req); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } - if err := h.API.ImportValue(r.Context(), req); err != nil { + if err := h.api.ImportValue(r.Context(), req); err != nil { switch errors.Cause(err) { case pilosa.ErrClusterDoesNotOwnShard: http.Error(w, err.Error(), http.StatusPreconditionFailed) @@ -940,12 +940,12 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) { // Field type: Set, Time // Marshal into request object. req := &pilosa.ImportRequest{} - if err := h.API.Serializer.Unmarshal(body, req); err != nil { + if err := h.api.Serializer.Unmarshal(body, req); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } - if err := h.API.Import(r.Context(), req); err != nil { + if err := h.api.Import(r.Context(), req); err != nil { switch errors.Cause(err) { case pilosa.ErrClusterDoesNotOwnShard: http.Error(w, err.Error(), http.StatusPreconditionFailed) @@ -957,7 +957,7 @@ func (h *Handler) handlePostImport(w http.ResponseWriter, r *http.Request) { } // Marshal response object. - buf, e := h.API.Serializer.Marshal(&pilosa.ImportResponse{Err: ""}) + buf, e := h.api.Serializer.Marshal(&pilosa.ImportResponse{Err: ""}) if e != nil { http.Error(w, fmt.Sprintf("marshal import response"), http.StatusInternalServerError) return @@ -988,7 +988,7 @@ func (h *Handler) handleGetExportCSV(w http.ResponseWriter, r *http.Request) { return } - if err = h.API.ExportCSV(r.Context(), index, field, shard, w); err != nil { + if err = h.api.ExportCSV(r.Context(), index, field, shard, w); err != nil { switch errors.Cause(err) { case pilosa.ErrFragmentNotFound: break @@ -1018,7 +1018,7 @@ func (h *Handler) handleGetFragmentNodes(w http.ResponseWriter, r *http.Request) } // Retrieve fragment owner nodes. - nodes, err := h.API.ShardNodes(r.Context(), index, shard) + nodes, err := h.api.ShardNodes(r.Context(), index, shard) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -1032,7 +1032,7 @@ func (h *Handler) handleGetFragmentNodes(w http.ResponseWriter, r *http.Request) // handleGetFragmentBlockData handles GET /internal/fragment/block/data requests. func (h *Handler) handleGetFragmentBlockData(w http.ResponseWriter, r *http.Request) { - buf, err := h.API.FragmentBlockData(r.Context(), r.Body) + buf, err := h.api.FragmentBlockData(r.Context(), r.Body) if err != nil { if _, ok := err.(pilosa.BadRequestError); ok { http.Error(w, err.Error(), http.StatusBadRequest) @@ -1064,7 +1064,7 @@ func (h *Handler) handleGetFragmentBlocks(w http.ResponseWriter, r *http.Request return } - blocks, err := h.API.FragmentBlocks(r.Context(), q.Get("index"), q.Get("field"), shard) + blocks, err := h.api.FragmentBlocks(r.Context(), q.Get("index"), q.Get("field"), shard) if err != nil { if errors.Cause(err) == pilosa.ErrFragmentNotFound { http.Error(w, err.Error(), http.StatusNotFound) @@ -1095,7 +1095,7 @@ func (h *Handler) handleGetVersion(w http.ResponseWriter, r *http.Request) { err := json.NewEncoder(w).Encode(struct { Version string `json:"version"` }{ - Version: h.API.Version(), + Version: h.api.Version(), }) if err != nil { h.Logger.Printf("write version response error: %s", err) @@ -1152,7 +1152,7 @@ func (h *Handler) handlePostClusterResizeSetCoordinator(w http.ResponseWriter, r return } - oldNode, newNode, err := h.API.SetCoordinator(r.Context(), req.ID) + oldNode, newNode, err := h.api.SetCoordinator(r.Context(), req.ID) if err != nil { if errors.Cause(err) == pilosa.ErrNodeIDNotExists { http.Error(w, "setting new coordinator: "+err.Error(), http.StatusNotFound) @@ -1193,7 +1193,7 @@ func (h *Handler) handlePostClusterResizeRemoveNode(w http.ResponseWriter, r *ht return } - removeNode, err := h.API.RemoveNode(req.ID) + removeNode, err := h.api.RemoveNode(req.ID) if err != nil { if errors.Cause(err) == pilosa.ErrNodeIDNotExists { http.Error(w, "removing node: "+err.Error(), http.StatusNotFound) @@ -1225,7 +1225,7 @@ func (h *Handler) handlePostClusterResizeAbort(w http.ResponseWriter, r *http.Re http.Error(w, "JSON only acceptable response", http.StatusNotAcceptable) return } - err := h.API.ResizeAbort() + err := h.api.ResizeAbort() var msg string if err != nil { switch errors.Cause(err) { @@ -1252,7 +1252,7 @@ type clusterResizeAbortResponse struct { } func (h *Handler) handleRecalculateCaches(w http.ResponseWriter, r *http.Request) { - err := h.API.RecalculateCaches(r.Context()) + err := h.api.RecalculateCaches(r.Context()) if err != nil { http.Error(w, "recalculating caches: "+err.Error(), http.StatusInternalServerError) return @@ -1272,7 +1272,7 @@ func (h *Handler) handlePostClusterMessage(w http.ResponseWriter, r *http.Reques return } - err := h.API.ClusterMessage(r.Context(), r.Body) + err := h.api.ClusterMessage(r.Context(), r.Body) if err != nil { // TODO this was the previous behavior, but perhaps not everything is a bad request http.Error(w, err.Error(), http.StatusBadRequest) @@ -1291,7 +1291,7 @@ func (h *Handler) handleGetTranslateData(w http.ResponseWriter, r *http.Request) pipeR, pipeW := io.Pipe() - err := h.API.GetTranslateData(r.Context(), pipeW, offset) + err := h.api.GetTranslateData(r.Context(), pipeW, offset) if err != nil { if errors.Cause(err) == pilosa.ErrNotImplemented { From 71000ee6d0b5c090c6da26052a799b2c4b3f8114 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:38:55 -0500 Subject: [PATCH 002/138] Unexport ApiMethodNotAllowedError --- pilosa.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pilosa.go b/pilosa.go index 9615e88b8..9b5918ee2 100644 --- a/pilosa.go +++ b/pilosa.go @@ -63,15 +63,15 @@ var ( ErrNotImplemented = errors.New("not implemented") ) -// ApiMethodNotAllowedError wraps an error value indicating that a particular +// apiMethodNotAllowedError wraps an error value indicating that a particular // API method is not allowed in the current cluster state. -type ApiMethodNotAllowedError struct { +type apiMethodNotAllowedError struct { error } // NewApiMethodNotAllowedError returns err wrapped in an ApiMethodNotAllowedError. -func NewApiMethodNotAllowedError(err error) ApiMethodNotAllowedError { - return ApiMethodNotAllowedError{err} +func NewApiMethodNotAllowedError(err error) apiMethodNotAllowedError { + return apiMethodNotAllowedError{err} } // BadRequestError wraps an error value to signify that a request could not be From 7559382115899c1338e78530790de704a32549b4 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:39:01 -0500 Subject: [PATCH 003/138] Unexport AttrBlocks --- api.go | 4 ++-- attr.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api.go b/api.go index 2a20c6234..0b70397e7 100644 --- a/api.go +++ b/api.go @@ -554,7 +554,7 @@ func (api *API) IndexAttrDiff(ctx context.Context, indexName string, blocks []At // Read all attributes from all mismatched blocks. attrs := make(map[uint64]map[string]interface{}) - for _, blockID := range AttrBlocks(localBlocks).Diff(blocks) { + for _, blockID := range attrBlocks(localBlocks).Diff(blocks) { // Retrieve block data. m, err := index.ColumnAttrStore().BlockData(blockID) if err != nil { @@ -588,7 +588,7 @@ func (api *API) FieldAttrDiff(ctx context.Context, indexName string, fieldName s // Read all attributes from all mismatched blocks. attrs := make(map[uint64]map[string]interface{}) - for _, blockID := range AttrBlocks(localBlocks).Diff(blocks) { + for _, blockID := range attrBlocks(localBlocks).Diff(blocks) { // Retrieve block data. m, err := f.RowAttrStore().BlockData(blockID) if err != nil { diff --git a/attr.go b/attr.go index 628613172..0f553be95 100644 --- a/attr.go +++ b/attr.go @@ -82,12 +82,12 @@ type AttrBlock struct { Checksum []byte `json:"checksum"` } -// AttrBlocks represents a list of blocks. -type AttrBlocks []AttrBlock +// attrBlocks represents a list of blocks. +type attrBlocks []AttrBlock // Diff returns a list of block ids that are different or are new in other. // Block lists must be in sorted order. -func (a AttrBlocks) Diff(other []AttrBlock) []uint64 { +func (a attrBlocks) Diff(other []AttrBlock) []uint64 { var ids []uint64 for { // Read next block from each list. From 9fd8cdb00719397a598f04da15a995e7e095b941 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:42:06 -0500 Subject: [PATCH 004/138] Unexport DefaultMapSize --- translate.go | 2 +- translate_mapsize_all64bitsystems.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/translate.go b/translate.go index 660269ea0..d58586fc6 100644 --- a/translate.go +++ b/translate.go @@ -84,7 +84,7 @@ func NewTranslateFile() *TranslateFile { cols: make(map[string]*index), rows: make(map[frameKey]*index), - MapSize: DefaultMapSize, + MapSize: defaultMapSize, ReplicationRetryInterval: defaultReplicationRetryInterval, } diff --git a/translate_mapsize_all64bitsystems.go b/translate_mapsize_all64bitsystems.go index 5275c6ec5..605d6270a 100644 --- a/translate_mapsize_all64bitsystems.go +++ b/translate_mapsize_all64bitsystems.go @@ -2,7 +2,7 @@ package pilosa -// DefaultMapSize is the default size of mapped memory for the translate store. +// defaultMapSize is the default size of mapped memory for the translate store. // It is passed as an int to syscall.Mmap and so can only be larger than 2^31 on // 64bit systems. -const DefaultMapSize = 10 * (1 << 30) // 10GB +const defaultMapSize = 10 * (1 << 30) // 10GB From c102143b501fefa19e5cc8be58c12ff1cc653445 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:42:12 -0500 Subject: [PATCH 005/138] Unexport DefaultPartitionN --- cluster.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cluster.go b/cluster.go index f61173c3b..45bbb835d 100644 --- a/cluster.go +++ b/cluster.go @@ -36,8 +36,8 @@ import ( ) const ( - // DefaultPartitionN is the default number of partitions in a cluster. - DefaultPartitionN = 256 + // defaultPartitionN is the default number of partitions in a cluster. + defaultPartitionN = 256 // ClusterState represents the state returned in the /status endpoint. ClusterStateStarting = "STARTING" @@ -219,7 +219,7 @@ type cluster struct { func newCluster() *cluster { return &cluster{ Hasher: &jmphasher{}, - partitionN: DefaultPartitionN, + partitionN: defaultPartitionN, ReplicaN: 1, joiningLeavingNodes: make(chan nodeAction, 10), // buffered channel From 761f6878fb950091b5803093fe192a6c0b69c5fd Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:42:18 -0500 Subject: [PATCH 006/138] Unexport DefaultURI --- pilosa.go | 2 +- uri.go | 6 +++--- uri_internal_test.go | 12 ++++++------ utils_internal_test.go | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pilosa.go b/pilosa.go index 9b5918ee2..a63e64f76 100644 --- a/pilosa.go +++ b/pilosa.go @@ -159,7 +159,7 @@ func stringSlicesAreEqual(a, b []string) bool { // using defaults when necessary. func AddressWithDefaults(addr string) (*URI, error) { if addr == "" { - return DefaultURI(), nil + return defaultURI(), nil } else { return NewURIFromAddress(addr) } diff --git a/uri.go b/uri.go index 8577c8238..332166b4e 100644 --- a/uri.go +++ b/uri.go @@ -47,8 +47,8 @@ type URI struct { Port uint16 `json:"port"` } -// DefaultURI creates and returns the default URI. -func DefaultURI() *URI { +// defaultURI creates and returns the default URI. +func defaultURI() *URI { return &URI{ Scheme: "http", Host: "localhost", @@ -68,7 +68,7 @@ func (u URIs) HostPortStrings() []string { // NewURIFromHostPort returns a URI with specified host and port. func NewURIFromHostPort(host string, port uint16) (*URI, error) { - uri := DefaultURI() + uri := defaultURI() err := uri.SetHost(host) if err != nil { return nil, errors.Wrap(err, "setting uri host") diff --git a/uri_internal_test.go b/uri_internal_test.go index 3c9631661..64db3fd8e 100644 --- a/uri_internal_test.go +++ b/uri_internal_test.go @@ -17,7 +17,7 @@ package pilosa import "testing" func TestDefaultURI(t *testing.T) { - uri := DefaultURI() + uri := defaultURI() compare(t, uri, "http", "localhost", 10101) } @@ -77,7 +77,7 @@ func TestURIPath(t *testing.T) { } func TestSetScheme(t *testing.T) { - uri := DefaultURI() + uri := defaultURI() target := "fun" err := uri.SetScheme(target) if err != nil { @@ -89,7 +89,7 @@ func TestSetScheme(t *testing.T) { } func TestSetHost(t *testing.T) { - uri := DefaultURI() + uri := defaultURI() target := "10.20.30.40" err := uri.SetHost(target) if err != nil { @@ -101,7 +101,7 @@ func TestSetHost(t *testing.T) { } func TestSetPort(t *testing.T) { - uri := DefaultURI() + uri := defaultURI() target := uint16(9999) uri.SetPort(target) if uri.Port != target { @@ -110,7 +110,7 @@ func TestSetPort(t *testing.T) { } func TestSetInvalidScheme(t *testing.T) { - uri := DefaultURI() + uri := defaultURI() err := uri.SetScheme("?invalid") if err == nil { t.Fatalf("Should have failed") @@ -118,7 +118,7 @@ func TestSetInvalidScheme(t *testing.T) { } func TestSetInvalidHost(t *testing.T) { - uri := DefaultURI() + uri := defaultURI() err := uri.SetHost("index?.pilosa.com") if err == nil { t.Fatalf("Should have failed") diff --git a/utils_internal_test.go b/utils_internal_test.go index df1b7d2e0..7adb110e8 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -55,7 +55,7 @@ func NewTestCluster(n int) *cluster { // NewTestURI is a test URI creator that intentionally swallows errors. func NewTestURI(scheme, host string, port uint16) URI { - uri := DefaultURI() + uri := defaultURI() uri.SetScheme(scheme) uri.SetHost(host) uri.SetPort(port) @@ -63,7 +63,7 @@ func NewTestURI(scheme, host string, port uint16) URI { } func NewTestURIFromHostPort(host string, port uint16) URI { - uri := DefaultURI() + uri := defaultURI() uri.SetHost(host) uri.SetPort(port) return *uri From 7245a936768c99f8607f0b91145b717005d341fb Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:43:21 -0500 Subject: [PATCH 007/138] Unexport DiagnosticsCollector --- diagnostics.go | 28 ++++++++++++++-------------- server.go | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/diagnostics.go b/diagnostics.go index 6ad6e16b1..8bdcdef3c 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -37,8 +37,8 @@ type versionResponse struct { Message string `json:"message"` } -// DiagnosticsCollector represents a collector/sender of diagnostics data. -type DiagnosticsCollector struct { +// diagnosticsCollector represents a collector/sender of diagnostics data. +type diagnosticsCollector struct { mu sync.Mutex host string VersionURL string @@ -57,8 +57,8 @@ type DiagnosticsCollector struct { } // NewDiagnosticsCollector returns a new DiagnosticsCollector given an addr in the format "hostname:port". -func NewDiagnosticsCollector(host string) *DiagnosticsCollector { - return &DiagnosticsCollector{ +func NewDiagnosticsCollector(host string) *diagnosticsCollector { + return &diagnosticsCollector{ host: host, VersionURL: defaultVersionCheckURL, startTime: time.Now().Unix(), @@ -70,13 +70,13 @@ func NewDiagnosticsCollector(host string) *DiagnosticsCollector { } // SetVersion of locally running Pilosa Cluster to check against master. -func (d *DiagnosticsCollector) SetVersion(v string) { +func (d *diagnosticsCollector) SetVersion(v string) { d.version = v d.Set("Version", v) } // Flush sends the current metrics. -func (d *DiagnosticsCollector) Flush() error { +func (d *diagnosticsCollector) Flush() error { d.mu.Lock() defer d.mu.Unlock() d.metrics["Uptime"] = (time.Now().Unix() - d.startTime) @@ -99,7 +99,7 @@ func (d *DiagnosticsCollector) Flush() error { } // CheckVersion of the local build against Pilosa master. -func (d *DiagnosticsCollector) CheckVersion() error { +func (d *diagnosticsCollector) CheckVersion() error { var rsp versionResponse req, err := http.NewRequest("GET", d.VersionURL, nil) if err != nil { @@ -131,7 +131,7 @@ func (d *DiagnosticsCollector) CheckVersion() error { } // compareVersion check version strings. -func (d *DiagnosticsCollector) compareVersion(value string) error { +func (d *diagnosticsCollector) compareVersion(value string) error { currentVersion := versionSegments(value) localVersion := versionSegments(d.version) @@ -147,12 +147,12 @@ func (d *DiagnosticsCollector) compareVersion(value string) error { } // Encode metrics maps into the json message format. -func (d *DiagnosticsCollector) encode() ([]byte, error) { +func (d *diagnosticsCollector) encode() ([]byte, error) { return json.Marshal(d.metrics) } // Set adds a key value metric. -func (d *DiagnosticsCollector) Set(name string, value interface{}) { +func (d *diagnosticsCollector) Set(name string, value interface{}) { switch v := value.(type) { case string: if v == "" { @@ -166,7 +166,7 @@ func (d *DiagnosticsCollector) Set(name string, value interface{}) { } // logErr logs the error and returns true if an error exists -func (d *DiagnosticsCollector) logErr(err error) bool { +func (d *diagnosticsCollector) logErr(err error) bool { if err != nil { d.Logger.Printf("%v", err) return true @@ -175,7 +175,7 @@ func (d *DiagnosticsCollector) logErr(err error) bool { } // EnrichWithOSInfo adds OS information to the diagnostics payload. -func (d *DiagnosticsCollector) EnrichWithOSInfo() { +func (d *diagnosticsCollector) EnrichWithOSInfo() { uptime, err := d.server.systemInfo.Uptime() if !d.logErr(err) { d.Set("HostUptime", uptime) @@ -199,7 +199,7 @@ func (d *DiagnosticsCollector) EnrichWithOSInfo() { } // EnrichWithMemoryInfo adds memory information to the diagnostics payload. -func (d *DiagnosticsCollector) EnrichWithMemoryInfo() { +func (d *diagnosticsCollector) EnrichWithMemoryInfo() { memFree, err := d.server.systemInfo.MemFree() if !d.logErr(err) { d.Set("MemFree", memFree) @@ -215,7 +215,7 @@ func (d *DiagnosticsCollector) EnrichWithMemoryInfo() { } // EnrichWithSchemaProperties adds schema info to the diagnostics payload. -func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { +func (d *diagnosticsCollector) EnrichWithSchemaProperties() { var numShards uint64 numFields := 0 numIndexes := 0 diff --git a/server.go b/server.go index 3adf3bb50..38c8d9426 100644 --- a/server.go +++ b/server.go @@ -50,7 +50,7 @@ type Server struct { holder *Holder cluster *cluster translateFile *TranslateFile - diagnostics *DiagnosticsCollector + diagnostics *diagnosticsCollector executor *executor hosts []string clusterDisabled bool From a8c9c30eef16285d925978974c7ae4d2b8d9cc03 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:43:28 -0500 Subject: [PATCH 008/138] Unexport ExpvarStatsClient --- stats.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/stats.go b/stats.go index 23c3e0bc8..130a91a64 100644 --- a/stats.go +++ b/stats.go @@ -82,8 +82,8 @@ func (c *nopStatsClient) SetLogger(logger Logger) func (c *nopStatsClient) Open() {} func (c *nopStatsClient) Close() error { return nil } -// ExpvarStatsClient writes stats out to expvars. -type ExpvarStatsClient struct { +// expvarStatsClient writes stats out to expvars. +type expvarStatsClient struct { mu sync.Mutex m *expvar.Map tags []string @@ -91,41 +91,41 @@ type ExpvarStatsClient struct { // NewExpvarStatsClient returns a new instance of ExpvarStatsClient. // This client points at the root of the expvar index map. -func NewExpvarStatsClient() *ExpvarStatsClient { - return &ExpvarStatsClient{ +func NewExpvarStatsClient() *expvarStatsClient { + return &expvarStatsClient{ m: Expvar, } } // Tags returns a sorted list of tags on the client. -func (c *ExpvarStatsClient) Tags() []string { +func (c *expvarStatsClient) Tags() []string { return nil } // WithTags returns a new client with additional tags appended. -func (c *ExpvarStatsClient) WithTags(tags ...string) StatsClient { +func (c *expvarStatsClient) WithTags(tags ...string) StatsClient { m := &expvar.Map{} m.Init() c.m.Set(strings.Join(tags, ","), m) - return &ExpvarStatsClient{ + return &expvarStatsClient{ m: m, tags: unionStringSlice(c.tags, tags), } } // Count tracks the number of times something occurs. -func (c *ExpvarStatsClient) Count(name string, value int64, rate float64) { +func (c *expvarStatsClient) Count(name string, value int64, rate float64) { c.m.Add(name, value) } // CountWithCustomTags Tracks the number of times something occurs per second with custom tags -func (c *ExpvarStatsClient) CountWithCustomTags(name string, value int64, rate float64, tags []string) { +func (c *expvarStatsClient) CountWithCustomTags(name string, value int64, rate float64, tags []string) { c.m.Add(name, value) } // Gauge sets the value of a metric. -func (c *ExpvarStatsClient) Gauge(name string, value float64, rate float64) { +func (c *expvarStatsClient) Gauge(name string, value float64, rate float64) { var f expvar.Float f.Set(value) c.m.Set(name, &f) @@ -133,19 +133,19 @@ func (c *ExpvarStatsClient) Gauge(name string, value float64, rate float64) { // Histogram tracks statistical distribution of a metric. // This works the same as gauge for this client. -func (c *ExpvarStatsClient) Histogram(name string, value float64, rate float64) { +func (c *expvarStatsClient) Histogram(name string, value float64, rate float64) { c.Gauge(name, value, rate) } // Set tracks number of unique elements. -func (c *ExpvarStatsClient) Set(name string, value string, rate float64) { +func (c *expvarStatsClient) Set(name string, value string, rate float64) { var s expvar.String s.Set(value) c.m.Set(name, &s) } // Timing tracks timing information for a metric. -func (c *ExpvarStatsClient) Timing(name string, value time.Duration, rate float64) { +func (c *expvarStatsClient) Timing(name string, value time.Duration, rate float64) { c.mu.Lock() d, _ := c.m.Get(name).(time.Duration) c.m.Set(name, d+value) @@ -153,14 +153,14 @@ func (c *ExpvarStatsClient) Timing(name string, value time.Duration, rate float6 } // SetLogger has no logger. -func (c *ExpvarStatsClient) SetLogger(logger Logger) { +func (c *expvarStatsClient) SetLogger(logger Logger) { } // Open no-op. -func (c *ExpvarStatsClient) Open() {} +func (c *expvarStatsClient) Open() {} // Close no-op. -func (c *ExpvarStatsClient) Close() error { return nil } +func (c *expvarStatsClient) Close() error { return nil } // MultiStatsClient joins multiple stats clients together. type MultiStatsClient []StatsClient From ba9c5193b559f607ebd2d18b581ad939eff68fce Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:43:34 -0500 Subject: [PATCH 009/138] Unexport Field.ImportValue --- api.go | 2 +- field.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index 0b70397e7..5230c8677 100644 --- a/api.go +++ b/api.go @@ -643,7 +643,7 @@ func (api *API) ImportValue(ctx context.Context, req *ImportValueRequest) error return errors.Wrap(err, "getting field") } // Import into fragment. - err = field.ImportValue(req.ColumnIDs, req.Values) + err = field.importValue(req.ColumnIDs, req.Values) if err != nil { api.server.logger.Printf("import error: index=%s, field=%s, shard=%d, columns=%d, err=%s", req.Index, req.Field, req.Shard, len(req.ColumnIDs), err) } diff --git a/field.go b/field.go index bcdb800f8..b9d84cc83 100644 --- a/field.go +++ b/field.go @@ -1035,8 +1035,8 @@ func (f *Field) Import(rowIDs, columnIDs []uint64, timestamps []*time.Time) erro return nil } -// ImportValue bulk imports range-encoded value data. -func (f *Field) ImportValue(columnIDs []uint64, values []int64) error { +// importValue bulk imports range-encoded value data. +func (f *Field) importValue(columnIDs []uint64, values []int64) error { viewName := viewBSIGroupPrefix + f.name // Get the bsiGroup so we know bitDepth. bsig := f.bsiGroup(f.name) From 16461345f63b009a6fd008d048189ce2b270ca29 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:43:41 -0500 Subject: [PATCH 010/138] Unexport Field.Keys --- executor.go | 4 ++-- field.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/executor.go b/executor.go index b39e26f58..9b7f5d4bb 100644 --- a/executor.go +++ b/executor.go @@ -1577,7 +1577,7 @@ func (e *executor) translateCall(index string, idx *Index, c *pql.Call) error { if field == nil { return ErrFieldNotFound } - if field.Keys() { + if field.keys() { if c.Args[rowKey] != nil && !isString(c.Args[rowKey]) { return errors.New("row value must be a string when field 'keys' option enabled") } @@ -1628,7 +1628,7 @@ func (e *executor) translateResult(index string, idx *Index, call *pql.Call, res if field == nil { return nil, ErrFieldNotFound } - if field.Keys() { + if field.keys() { other := make([]Pair, len(result)) for i := range result { key, err := e.TranslateStore.TranslateRowToString(index, fieldName, result[i].ID) diff --git a/field.go b/field.go index b9d84cc83..69d08d504 100644 --- a/field.go +++ b/field.go @@ -428,8 +428,8 @@ func (f *Field) Close() error { return nil } -// Keys returns true if the field uses string keys. -func (f *Field) Keys() bool { +// keys returns true if the field uses string keys. +func (f *Field) keys() bool { f.mu.RLock() defer f.mu.RUnlock() return f.options.Keys From cbf821123ecf243d7c4abdf8694b80eccdd3c184 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:43:48 -0500 Subject: [PATCH 011/138] Unexport Field.MaxShard --- field.go | 4 ++-- index.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/field.go b/field.go index 69d08d504..02d7d9ce5 100644 --- a/field.go +++ b/field.go @@ -183,8 +183,8 @@ func (f *Field) Path() string { return f.path } // RowAttrStore returns the attribute storage. func (f *Field) RowAttrStore() AttrStore { return f.rowAttrStore } -// MaxShard returns the max shard in the field. -func (f *Field) MaxShard() uint64 { +// maxShard returns the max shard in the field. +func (f *Field) maxShard() uint64 { f.mu.RLock() defer f.mu.RUnlock() diff --git a/index.go b/index.go index 7217bb659..4b8b84ca8 100644 --- a/index.go +++ b/index.go @@ -220,7 +220,7 @@ func (i *Index) maxShard() uint64 { max := i.remoteMaxShard for _, f := range i.fields { - if shard := f.MaxShard(); shard > max { + if shard := f.maxShard(); shard > max { max = shard } } From 55c0dcee23e3011d68216558d3407d3c072320bd Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:43:54 -0500 Subject: [PATCH 012/138] Unexport Field.RangeBetween --- field.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/field.go b/field.go index 02d7d9ce5..69c820b43 100644 --- a/field.go +++ b/field.go @@ -955,7 +955,7 @@ 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) { +func (f *Field) rangeBetween(name string, predicateMin, predicateMax int64) (*Row, error) { // Retrieve and validate bsiGroup. bsig := f.bsiGroup(name) if bsig == nil { From fc49d67c0bb4cc00fa43e1a7cc005425a0ccdc4a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:44:01 -0500 Subject: [PATCH 013/138] Unexport Field.RecalculateCaches --- field.go | 4 ++-- index.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/field.go b/field.go index 69c820b43..e57ca0f79 100644 --- a/field.go +++ b/field.go @@ -606,8 +606,8 @@ func (f *Field) viewNames() []string { return other } -// RecalculateCaches recalculates caches on every view in the field. -func (f *Field) RecalculateCaches() { +// recalculateCaches recalculates caches on every view in the field. +func (f *Field) recalculateCaches() { for _, view := range f.views() { view.recalculateCaches() } diff --git a/index.go b/index.go index 4b8b84ca8..fb97ded2f 100644 --- a/index.go +++ b/index.go @@ -265,7 +265,7 @@ func (i *Index) Fields() []*Field { // RecalculateCaches recalculates caches on every field in the index. func (i *Index) RecalculateCaches() { for _, field := range i.Fields() { - field.RecalculateCaches() + field.recalculateCaches() } } From 3faa51544afdcfcf9438cc744644ab8d34e6e50d Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:44:07 -0500 Subject: [PATCH 014/138] Unexport Field.SetTimeQuantum --- field.go | 6 +++--- field_internal_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/field.go b/field.go index e57ca0f79..7906750b5 100644 --- a/field.go +++ b/field.go @@ -396,7 +396,7 @@ func (f *Field) applyOptions(opt FieldOptions) error { f.options.Max = 0 f.options.Keys = opt.Keys // Set the time quantum. - if err := f.SetTimeQuantum(opt.TimeQuantum); err != nil { + if err := f.setTimeQuantum(opt.TimeQuantum); err != nil { f.Close() return errors.Wrap(err, "setting time quantum") } @@ -533,8 +533,8 @@ func (f *Field) TimeQuantum() TimeQuantum { return f.options.TimeQuantum } -// SetTimeQuantum sets the time quantum for the field. -func (f *Field) SetTimeQuantum(q TimeQuantum) error { +// setTimeQuantum sets the time quantum for the field. +func (f *Field) setTimeQuantum(q TimeQuantum) error { f.mu.Lock() defer f.mu.Unlock() diff --git a/field_internal_test.go b/field_internal_test.go index 4ded2bebe..2d37ea25c 100644 --- a/field_internal_test.go +++ b/field_internal_test.go @@ -282,7 +282,7 @@ func TestField_SetTimeQuantum(t *testing.T) { defer f.Close() // Set & retrieve time quantum. - if err := f.SetTimeQuantum(TimeQuantum("YMDH")); err != nil { + if err := f.setTimeQuantum(TimeQuantum("YMDH")); err != nil { t.Fatal(err) } else if q := f.TimeQuantum(); q != TimeQuantum("YMDH") { t.Fatalf("unexpected quantum: %s", q) @@ -300,7 +300,7 @@ func TestField_RowTime(t *testing.T) { f := MustOpenField(OptFieldTypeTime(TimeQuantum(""))) defer f.Close() - if err := f.SetTimeQuantum(TimeQuantum("YMDH")); err != nil { + if err := f.setTimeQuantum(TimeQuantum("YMDH")); err != nil { t.Fatal(err) } From 5d7cb333226a89736f52b658eef64aa6165f2ba8 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:44:13 -0500 Subject: [PATCH 015/138] Unexport Field.Logger --- field.go | 6 +++--- index.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/field.go b/field.go index 7906750b5..54e82091d 100644 --- a/field.go +++ b/field.go @@ -72,7 +72,7 @@ type Field struct { bsiGroups []*bsiGroup - Logger Logger + logger Logger } // FieldOption is a functional option type for pilosa.fieldOptions. @@ -166,7 +166,7 @@ func NewField(path, index, name string, opts FieldOption) (*Field, error) { options: applyDefaultOptions(fo), - Logger: NopLogger, + logger: NopLogger, } return f, nil } @@ -660,7 +660,7 @@ func (f *Field) createViewIfNotExistsBase(name string) (*view, bool, error) { func (f *Field) newView(path, name string) *view { view := newView(path, f.index, f.name, name, f.options.CacheSize) view.cacheType = f.options.CacheType - view.logger = f.Logger + view.logger = f.logger view.rowAttrStore = f.rowAttrStore view.stats = f.Stats.WithTags(fmt.Sprintf("view:%s", name)) view.broadcaster = f.broadcaster diff --git a/index.go b/index.go index fb97ded2f..c0490601b 100644 --- a/index.go +++ b/index.go @@ -363,7 +363,7 @@ func (i *Index) newField(path, name string) (*Field, error) { if err != nil { return nil, err } - f.Logger = i.logger + f.logger = i.logger f.Stats = i.Stats.WithTags(fmt.Sprintf("field:%s", name)) f.broadcaster = i.broadcaster f.rowAttrStore = i.newAttrStore(filepath.Join(f.path, ".data")) From 3ff6851881ddcb26a30e78e449afd5ad00921eaf Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:44:33 -0500 Subject: [PATCH 016/138] Unexport FieldOptions.Encode --- field.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/field.go b/field.go index 54e82091d..a435148d3 100644 --- a/field.go +++ b/field.go @@ -337,7 +337,7 @@ func (f *Field) loadMeta() error { func (f *Field) saveMeta() error { // Marshal metadata. fo := f.options - buf, err := proto.Marshal(fo.Encode()) + buf, err := proto.Marshal(fo.encode()) if err != nil { return errors.Wrap(err, "marshaling") } @@ -1135,8 +1135,8 @@ func applyDefaultOptions(o FieldOptions) FieldOptions { return o } -// Encode converts o into its internal representation. -func (o *FieldOptions) Encode() *internal.FieldOptions { +// encode converts o into its internal representation. +func (o *FieldOptions) encode() *internal.FieldOptions { return encodeFieldOptions(o) } From 0648d0fc7546c50cd8acaae797d0764566ab783a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:45:26 -0500 Subject: [PATCH 017/138] Unexport Holder.RecalculateCaches --- api.go | 2 +- holder.go | 4 ++-- server.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api.go b/api.go index 5230c8677..6ea2c79b5 100644 --- a/api.go +++ b/api.go @@ -446,7 +446,7 @@ func (api *API) RecalculateCaches(ctx context.Context) error { if err != nil { return errors.Wrap(err, "broacasting message") } - api.holder.RecalculateCaches() + api.holder.recalculateCaches() return nil } diff --git a/holder.go b/holder.go index 192c83a46..323f985b2 100644 --- a/holder.go +++ b/holder.go @@ -456,11 +456,11 @@ func (h *Holder) flushCaches() { } } -// RecalculateCaches recalculates caches on every index in the holder. This is +// recalculateCaches recalculates caches on every index in the holder. This is // probably not practical to call in real-world workloads, but makes writing // integration tests much eaiser, since one doesn't have to wait 10 seconds // after setting bits to get expected response. -func (h *Holder) RecalculateCaches() { +func (h *Holder) recalculateCaches() { for _, index := range h.Indexes() { index.RecalculateCaches() } diff --git a/server.go b/server.go index 38c8d9426..3cf40ee19 100644 --- a/server.go +++ b/server.go @@ -513,7 +513,7 @@ func (s *Server) receiveMessage(m Message) error { return err } case *RecalculateCaches: - s.holder.RecalculateCaches() + s.holder.recalculateCaches() case *NodeEvent: s.cluster.ReceiveEvent(obj) case *NodeStatus: From 1b6846d6e6d196b6afde12445acddf265315b27d Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:47:39 -0500 Subject: [PATCH 018/138] Unexport Index.FieldPath --- index.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.go b/index.go index c0490601b..67b0274a4 100644 --- a/index.go +++ b/index.go @@ -139,7 +139,7 @@ func (i *Index) openFields() error { continue } - fld, err := i.newField(i.FieldPath(filepath.Base(fi.Name())), filepath.Base(fi.Name())) + fld, err := i.newField(i.fieldPath(filepath.Base(fi.Name())), filepath.Base(fi.Name())) if err != nil { return ErrName } @@ -236,8 +236,8 @@ func (i *Index) setRemoteMaxShard(newmax uint64) { i.remoteMaxShard = newmax } -// FieldPath returns the path to a field in the index. -func (i *Index) FieldPath(name string) string { return filepath.Join(i.path, name) } +// fieldPath returns the path to a field in the index. +func (i *Index) fieldPath(name string) string { return filepath.Join(i.path, name) } // Field returns a field in the index by name. func (i *Index) Field(name string) *Field { @@ -331,7 +331,7 @@ func (i *Index) createField(name string, opt FieldOptions) (*Field, error) { } // Initialize field. - f, err := i.newField(i.FieldPath(name), name) + f, err := i.newField(i.fieldPath(name), name) if err != nil { return nil, errors.Wrap(err, "initializing") } @@ -387,7 +387,7 @@ func (i *Index) DeleteField(name string) error { } // Delete field directory. - if err := os.RemoveAll(i.FieldPath(name)); err != nil { + if err := os.RemoveAll(i.fieldPath(name)); err != nil { return errors.Wrap(err, "removing directory") } From 13a6542a15f5a82dba724afe2737cabab00402e8 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:47:45 -0500 Subject: [PATCH 019/138] Unexport Index.RecalculateCaches --- holder.go | 2 +- index.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/holder.go b/holder.go index 323f985b2..b2ce1e67b 100644 --- a/holder.go +++ b/holder.go @@ -462,7 +462,7 @@ func (h *Holder) flushCaches() { // after setting bits to get expected response. func (h *Holder) recalculateCaches() { for _, index := range h.Indexes() { - index.RecalculateCaches() + index.recalculateCaches() } } diff --git a/index.go b/index.go index 67b0274a4..d83b20111 100644 --- a/index.go +++ b/index.go @@ -262,8 +262,8 @@ func (i *Index) Fields() []*Field { return a } -// RecalculateCaches recalculates caches on every field in the index. -func (i *Index) RecalculateCaches() { +// recalculateCaches recalculates caches on every field in the index. +func (i *Index) recalculateCaches() { for _, field := range i.Fields() { field.recalculateCaches() } From 51619e81a69d3b00fc2270076b3b1c6e5ef9cc61 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:47:51 -0500 Subject: [PATCH 020/138] Unexport IndexInfo.Options --- index.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.go b/index.go index d83b20111..d8a1bb1bd 100644 --- a/index.go +++ b/index.go @@ -406,7 +406,7 @@ func (p indexSlice) Less(i, j int) bool { return p[i].Name() < p[j].Name() } // IndexInfo represents schema information for an index. type IndexInfo struct { Name string `json:"name"` - Options IndexOptions `json:"options"` + options IndexOptions `json:"options"` Fields []*FieldInfo `json:"fields"` } From b4b0fd2e64a5cb0a5b55201e722907d7a05c0903 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:47:58 -0500 Subject: [PATCH 021/138] Unexport LogEntry.HeaderSize --- translate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translate.go b/translate.go index d58586fc6..a4a4bfcdd 100644 --- a/translate.go +++ b/translate.go @@ -193,7 +193,7 @@ func (s *TranslateFile) appendEntry(entry *LogEntry) error { func (s *TranslateFile) applyEntry(entry *LogEntry, offset int64) error { // Move offset to the start of the id/key pairs. - offset += entry.HeaderSize() + offset += entry.headerSize() var idx *index switch entry.Type { @@ -558,8 +558,8 @@ type LogEntry struct { Length uint64 } -// HeaderSize returns the number of bytes required for size, type, index, frame, & pair count. -func (e *LogEntry) HeaderSize() int64 { +// headerSize returns the number of bytes required for size, type, index, frame, & pair count. +func (e *LogEntry) headerSize() int64 { sz := uVarintSize(e.Length) + // total entry length 1 + // type uVarintSize(uint64(len(e.Index))) + len(e.Index) + // Index length and data From a1fc587577823dc8c1dfd6d34b01febbe9992b3b Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:11 -0500 Subject: [PATCH 022/138] Unexport NewApiMethodNotAllowedError --- api.go | 2 +- pilosa.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api.go b/api.go index 6ea2c79b5..86a739d5f 100644 --- a/api.go +++ b/api.go @@ -90,7 +90,7 @@ func (api *API) validate(f apiMethod) error { if _, ok := validAPIMethods[state][f]; ok { return nil } - return NewApiMethodNotAllowedError(errors.Errorf("api method %s not allowed in state %s", f, state)) + return newApiMethodNotAllowedError(errors.Errorf("api method %s not allowed in state %s", f, state)) } // Query parses a PQL query out of the request and executes it. diff --git a/pilosa.go b/pilosa.go index a63e64f76..7c313d29b 100644 --- a/pilosa.go +++ b/pilosa.go @@ -69,8 +69,8 @@ type apiMethodNotAllowedError struct { error } -// NewApiMethodNotAllowedError returns err wrapped in an ApiMethodNotAllowedError. -func NewApiMethodNotAllowedError(err error) apiMethodNotAllowedError { +// newApiMethodNotAllowedError returns err wrapped in an ApiMethodNotAllowedError. +func newApiMethodNotAllowedError(err error) apiMethodNotAllowedError { return apiMethodNotAllowedError{err} } From 59bbbfc1fbd2408346815943069519c98437eb62 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:19 -0500 Subject: [PATCH 023/138] Unexport NewConflictError --- holder.go | 2 +- index.go | 2 +- pilosa.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/holder.go b/holder.go index b2ce1e67b..430253ba9 100644 --- a/holder.go +++ b/holder.go @@ -304,7 +304,7 @@ func (h *Holder) CreateIndex(name string, opt IndexOptions) (*Index, error) { // Ensure index doesn't already exist. if h.indexes[name] != nil { - return nil, NewConflictError(ErrIndexExists) + return nil, newConflictError(ErrIndexExists) } return h.createIndex(name, opt) } diff --git a/index.go b/index.go index d8a1bb1bd..2d66a42c1 100644 --- a/index.go +++ b/index.go @@ -276,7 +276,7 @@ func (i *Index) CreateField(name string, opts ...FieldOption) (*Field, error) { // Ensure field doesn't already exist. if i.fields[name] != nil { - return nil, NewConflictError(ErrFieldExists) + return nil, newConflictError(ErrFieldExists) } // Apply functional options. diff --git a/pilosa.go b/pilosa.go index 7c313d29b..8474fae89 100644 --- a/pilosa.go +++ b/pilosa.go @@ -93,8 +93,8 @@ type ConflictError struct { error } -// NewConflictError returns err wrapped in a ConflictError. -func NewConflictError(err error) ConflictError { +// newConflictError returns err wrapped in a ConflictError. +func newConflictError(err error) ConflictError { return ConflictError{err} } From 5f74927d03ab573301929de95725566ead295a81 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:25 -0500 Subject: [PATCH 024/138] Unexport NewDiagnosticsCollector --- diagnostics.go | 4 ++-- diagnostics_internal_test.go | 8 ++++---- server.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/diagnostics.go b/diagnostics.go index 8bdcdef3c..16ef71ad8 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -56,8 +56,8 @@ type diagnosticsCollector struct { server *Server } -// NewDiagnosticsCollector returns a new DiagnosticsCollector given an addr in the format "hostname:port". -func NewDiagnosticsCollector(host string) *diagnosticsCollector { +// newDiagnosticsCollector returns a new DiagnosticsCollector given an addr in the format "hostname:port". +func newDiagnosticsCollector(host string) *diagnosticsCollector { return &diagnosticsCollector{ host: host, VersionURL: defaultVersionCheckURL, diff --git a/diagnostics_internal_test.go b/diagnostics_internal_test.go index 517dbed3d..f1536e1d1 100644 --- a/diagnostics_internal_test.go +++ b/diagnostics_internal_test.go @@ -29,7 +29,7 @@ func TestDiagnosticsClient(t *testing.T) { server := httptest.NewServer(nil) // Create a new client. - d := NewDiagnosticsCollector(server.URL) + d := newDiagnosticsCollector(server.URL) d.Set("gg", 10) d.Set("ss", "ss") @@ -76,7 +76,7 @@ func TestDiagnosticsVersion_Parse(t *testing.T) { } func TestDiagnosticsVersion_Compare(t *testing.T) { - d := NewDiagnosticsCollector("localhost:10101") + d := newDiagnosticsCollector("localhost:10101") version := "v0.1.1" d.SetVersion(version) @@ -118,7 +118,7 @@ func TestDiagnosticsVersion_Check(t *testing.T) { })) // Create a new client. - d := NewDiagnosticsCollector("localhost:10101") + d := newDiagnosticsCollector("localhost:10101") version := "0.1.1" d.SetVersion(version) @@ -143,7 +143,7 @@ func BenchmarkDiagnostics(b *testing.B) { server := httptest.NewServer(nil) // Create a new client. - d := NewDiagnosticsCollector(server.URL) + d := newDiagnosticsCollector(server.URL) prev := runtime.GOMAXPROCS(4) defer runtime.GOMAXPROCS(prev) diff --git a/server.go b/server.go index 3cf40ee19..2a7d7d783 100644 --- a/server.go +++ b/server.go @@ -235,7 +235,7 @@ func NewServer(opts ...ServerOption) (*Server, error) { closing: make(chan struct{}), cluster: newCluster(), holder: NewHolder(), - diagnostics: NewDiagnosticsCollector(defaultDiagnosticServer), + diagnostics: newDiagnosticsCollector(defaultDiagnosticServer), systemInfo: NewNopSystemInfo(), gcNotifier: NopGCNotifier, From 0907ee585426a3da133f10fed2c3d79cda5929ea Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:32 -0500 Subject: [PATCH 025/138] Unexport NewNopInternalClient --- client.go | 4 ++-- cluster.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 5c51ae63f..671bd2a76 100644 --- a/client.go +++ b/client.go @@ -72,11 +72,11 @@ var _ InternalQueryClient = NewNopInternalQueryClient() type NopInternalClient struct{} -func NewNopInternalClient() NopInternalClient { +func newNopInternalClient() NopInternalClient { return NopInternalClient{} } -var _ InternalClient = NewNopInternalClient() +var _ InternalClient = newNopInternalClient() func (n NopInternalClient) MaxShardByIndex(context.Context) (map[string]uint64, error) { return nil, nil diff --git a/cluster.go b/cluster.go index 45bbb835d..226221b99 100644 --- a/cluster.go +++ b/cluster.go @@ -227,7 +227,7 @@ func newCluster() *cluster { closing: make(chan struct{}), joining: make(chan struct{}), - InternalClient: NewNopInternalClient(), + InternalClient: newNopInternalClient(), logger: NopLogger, } From 631ee915df0d3991b91835db6c888e660330382e Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:38 -0500 Subject: [PATCH 026/138] Unexport NewNopInternalQueryClient --- client.go | 4 ++-- executor.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 671bd2a76..5a1ed97c1 100644 --- a/client.go +++ b/client.go @@ -62,11 +62,11 @@ func (n *NopInternalQueryClient) QueryNode(ctx context.Context, uri *URI, index return nil, nil } -func NewNopInternalQueryClient() *NopInternalQueryClient { +func newNopInternalQueryClient() *NopInternalQueryClient { return &NopInternalQueryClient{} } -var _ InternalQueryClient = NewNopInternalQueryClient() +var _ InternalQueryClient = newNopInternalQueryClient() //=============== diff --git a/executor.go b/executor.go index 9b7f5d4bb..579a9aa9d 100644 --- a/executor.go +++ b/executor.go @@ -67,7 +67,7 @@ func optExecutorInternalQueryClient(c InternalQueryClient) executorOption { // newExecutor returns a new instance of Executor. func newExecutor(opts ...executorOption) *executor { e := &executor{ - client: NewNopInternalQueryClient(), + client: newNopInternalQueryClient(), } for _, opt := range opts { err := opt(e) From 92d521912e01d0eee2791873ff80931d312873e9 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:44 -0500 Subject: [PATCH 027/138] Unexport NewNopSystemInfo --- diagnostics.go | 4 ++-- server.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/diagnostics.go b/diagnostics.go index 16ef71ad8..11d3f5b9c 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -267,8 +267,8 @@ type SystemInfo interface { MemUsed() (uint64, error) } -// NewNopSystemInfo creates a no-op implementation of SystemInfo. -func NewNopSystemInfo() *NopSystemInfo { +// newNopSystemInfo creates a no-op implementation of SystemInfo. +func newNopSystemInfo() *NopSystemInfo { return &NopSystemInfo{} } diff --git a/server.go b/server.go index 2a7d7d783..6ee4c6c60 100644 --- a/server.go +++ b/server.go @@ -236,7 +236,7 @@ func NewServer(opts ...ServerOption) (*Server, error) { cluster: newCluster(), holder: NewHolder(), diagnostics: newDiagnosticsCollector(defaultDiagnosticServer), - systemInfo: NewNopSystemInfo(), + systemInfo: newNopSystemInfo(), gcNotifier: NopGCNotifier, From 4aa8a41fa097e433ef048a3bb183296ea149d8d2 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:52 -0500 Subject: [PATCH 028/138] Unexport NewNotFoundError --- api.go | 12 ++++++------ holder.go | 2 +- index.go | 2 +- pilosa.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/api.go b/api.go index 86a739d5f..f646112b9 100644 --- a/api.go +++ b/api.go @@ -205,7 +205,7 @@ func (api *API) Index(ctx context.Context, indexName string) (*Index, error) { index := api.holder.Index(indexName) if index == nil { - return nil, NewNotFoundError(ErrIndexNotFound) + return nil, newNotFoundError(ErrIndexNotFound) } return index, nil } @@ -255,7 +255,7 @@ func (api *API) CreateField(ctx context.Context, indexName string, fieldName str // Find index. index := api.holder.Index(indexName) if index == nil { - return nil, NewNotFoundError(ErrIndexNotFound) + return nil, newNotFoundError(ErrIndexNotFound) } // Create field. @@ -287,7 +287,7 @@ func (api *API) Field(ctx context.Context, indexName, fieldName string) (*Field, field := api.holder.Field(indexName, fieldName) if field == nil { - return nil, NewNotFoundError(ErrFieldNotFound) + return nil, newNotFoundError(ErrFieldNotFound) } return field, nil } @@ -303,7 +303,7 @@ func (api *API) DeleteField(ctx context.Context, indexName string, fieldName str // Find index. index := api.holder.Index(indexName) if index == nil { - return NewNotFoundError(ErrIndexNotFound) + return newNotFoundError(ErrIndexNotFound) } // Delete field from the index. @@ -543,7 +543,7 @@ func (api *API) IndexAttrDiff(ctx context.Context, indexName string, blocks []At // Retrieve index from holder. index := api.holder.Index(indexName) if index == nil { - return nil, NewNotFoundError(ErrIndexNotFound) + return nil, newNotFoundError(ErrIndexNotFound) } // Retrieve local blocks. @@ -685,7 +685,7 @@ func (api *API) indexField(indexName string, fieldName string, shard uint64) (*I index := api.holder.Index(indexName) if index == nil { api.server.logger.Printf("fragment error: index=%s, field=%s, shard=%d, err=%s", indexName, fieldName, shard, ErrIndexNotFound.Error()) - return nil, nil, NewNotFoundError(ErrIndexNotFound) + return nil, nil, newNotFoundError(ErrIndexNotFound) } // Retrieve field. diff --git a/holder.go b/holder.go index 430253ba9..a8caf8664 100644 --- a/holder.go +++ b/holder.go @@ -374,7 +374,7 @@ func (h *Holder) DeleteIndex(name string) error { // Confirm index exists. index := h.index(name) if index == nil { - return NewNotFoundError(ErrIndexNotFound) + return newNotFoundError(ErrIndexNotFound) } // Close index. diff --git a/index.go b/index.go index 2d66a42c1..1cda5e7c9 100644 --- a/index.go +++ b/index.go @@ -378,7 +378,7 @@ func (i *Index) DeleteField(name string) error { // Confirm field exists. f := i.field(name) if f == nil { - return NewNotFoundError(ErrFieldNotFound) + return newNotFoundError(ErrFieldNotFound) } // Close field. diff --git a/pilosa.go b/pilosa.go index 8474fae89..45d77a9f3 100644 --- a/pilosa.go +++ b/pilosa.go @@ -104,8 +104,8 @@ type NotFoundError struct { error } -// NewNotFoundError returns err wrapped in a NotFoundError. -func NewNotFoundError(err error) NotFoundError { +// newNotFoundError returns err wrapped in a NotFoundError. +func newNotFoundError(err error) NotFoundError { return NotFoundError{err} } From 2031345c86cf1457650e0842e77a5401215f7484 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:48:59 -0500 Subject: [PATCH 029/138] Unexport NewTopology --- cluster.go | 6 +++--- utils_internal_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cluster.go b/cluster.go index 226221b99..647db4f24 100644 --- a/cluster.go +++ b/cluster.go @@ -1403,7 +1403,7 @@ type Topology struct { nodeStates map[string]string } -func NewTopology() *Topology { +func newTopology() *Topology { return &Topology{ nodeStates: make(map[string]string), } @@ -1472,7 +1472,7 @@ func (t *Topology) Encode() *internal.Topology { func (c *cluster) loadTopology() error { buf, err := ioutil.ReadFile(filepath.Join(c.Path, ".topology")) if os.IsNotExist(err) { - c.Topology = NewTopology() + c.Topology = newTopology() return nil } else if err != nil { return errors.Wrap(err, "reading file") @@ -1784,7 +1784,7 @@ func decodeTopology(topology *internal.Topology) (*Topology, error) { return nil, nil } - t := NewTopology() + t := newTopology() t.ClusterID = topology.ClusterID t.NodeIDs = topology.NodeIDs sort.Slice(t.NodeIDs, diff --git a/utils_internal_test.go b/utils_internal_test.go index 7adb110e8..baaac04e3 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -37,7 +37,7 @@ func NewTestCluster(n int) *cluster { c.ReplicaN = 1 c.Hasher = NewTestModHasher() c.Path = path - c.Topology = NewTopology() + c.Topology = newTopology() for i := 0; i < n; i++ { c.Nodes = append(c.Nodes, &Node{ @@ -225,7 +225,7 @@ func (t *ClusterCluster) addCluster(i int, saveTopology bool) (*cluster, error) c.ReplicaN = 1 c.Hasher = NewTestModHasher() c.Path = path - c.Topology = NewTopology() + c.Topology = newTopology() c.holder = h c.Node = node c.Coordinator = t.common.Nodes[0].ID // the first node is the coordinator From 9d882469da9399e128d1768eb86107e02852c225 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:49:05 -0500 Subject: [PATCH 030/138] Unexport NewTranslateFileReader --- translate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translate.go b/translate.go index a4a4bfcdd..04922b7a6 100644 --- a/translate.go +++ b/translate.go @@ -538,7 +538,7 @@ func (s *TranslateFile) TranslateRowToString(index, frame string, id uint64) (st // Reader returns a reader that streams the underlying data file. func (s *TranslateFile) Reader(ctx context.Context, offset int64) (io.ReadCloser, error) { - rc := NewTranslateFileReader(ctx, s, offset) + rc := newTranslateFileReader(ctx, s, offset) if err := rc.Open(); err != nil { return nil, err } @@ -910,8 +910,8 @@ type TranslateFileReader struct { closing chan struct{} } -// NewTranslateFileReader returns a new instance of TranslateFileReader. -func NewTranslateFileReader(ctx context.Context, store *TranslateFile, offset int64) *TranslateFileReader { +// newTranslateFileReader returns a new instance of TranslateFileReader. +func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset int64) *TranslateFileReader { return &TranslateFileReader{ ctx: ctx, store: store, From 9222ef0df78d79cbe76ccb227a9add07e5fb9628 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:49:33 -0500 Subject: [PATCH 031/138] Unexport NodeIDs --- cluster.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cluster.go b/cluster.go index 647db4f24..aa48ba57c 100644 --- a/cluster.go +++ b/cluster.go @@ -1375,14 +1375,14 @@ func (j *resizeJob) distributeResizeInstructions() error { return nil } -type NodeIDs []string +type nodeIDs []string -func (n NodeIDs) Len() int { return len(n) } -func (n NodeIDs) Swap(i, j int) { n[i], n[j] = n[j], n[i] } -func (n NodeIDs) Less(i, j int) bool { return n[i] < n[j] } +func (n nodeIDs) Len() int { return len(n) } +func (n nodeIDs) Swap(i, j int) { n[i], n[j] = n[j], n[i] } +func (n nodeIDs) Less(i, j int) bool { return n[i] < n[j] } // ContainsID returns true if idi matches one of the nodesets's IDs. -func (n NodeIDs) ContainsID(id string) bool { +func (n nodeIDs) ContainsID(id string) bool { for _, nid := range n { if nid == id { return true @@ -1417,7 +1417,7 @@ func (t *Topology) ContainsID(id string) bool { } func (t *Topology) containsID(id string) bool { - return NodeIDs(t.NodeIDs).ContainsID(id) + return nodeIDs(t.NodeIDs).ContainsID(id) } func (t *Topology) positionByID(nodeID string) int { From 3e91a0d32cdfdda1fbce1521141b00a9715c5fdf Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:49:56 -0500 Subject: [PATCH 032/138] Unexport NodeStateReady --- cluster.go | 4 ++-- server.go | 2 +- utils_internal_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cluster.go b/cluster.go index aa48ba57c..6f0a88904 100644 --- a/cluster.go +++ b/cluster.go @@ -45,7 +45,7 @@ const ( ClusterStateResizing = "RESIZING" // NodeState represents the state of a node during startup. - NodeStateReady = "READY" + nodeStateReady = "READY" // resizeJob states. resizeJobStateRunning = "RUNNING" @@ -903,7 +903,7 @@ func (c *cluster) allNodesReady() bool { return true } for _, uri := range c.Topology.NodeIDs { - if c.Topology.nodeStates[uri] != NodeStateReady { + if c.Topology.nodeStates[uri] != nodeStateReady { return false } } diff --git a/server.go b/server.go index 6ee4c6c60..91c2d813a 100644 --- a/server.go +++ b/server.go @@ -337,7 +337,7 @@ func (s *Server) Open() error { if err := s.holder.Open(); err != nil { return fmt.Errorf("opening Holder: %v", err) } - if err := s.cluster.setNodeState(NodeStateReady); err != nil { + if err := s.cluster.setNodeState(nodeStateReady); err != nil { return fmt.Errorf("setting nodeState: %v", err) } diff --git a/utils_internal_test.go b/utils_internal_test.go index baaac04e3..816c477ce 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -277,7 +277,7 @@ func (t *ClusterCluster) Open() error { if err := c.holder.Open(); err != nil { return err } - if err := c.setNodeState(NodeStateReady); err != nil { + if err := c.setNodeState(nodeStateReady); err != nil { return err } } From e50ec6dc9d673ad5bdc911d3fc2e9ca06e726f3a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:50:27 -0500 Subject: [PATCH 033/138] Unexport NopInternalClient --- client.go | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/client.go b/client.go index 5a1ed97c1..271c8d170 100644 --- a/client.go +++ b/client.go @@ -70,64 +70,64 @@ var _ InternalQueryClient = newNopInternalQueryClient() //=============== -type NopInternalClient struct{} +type nopInternalClient struct{} -func newNopInternalClient() NopInternalClient { - return NopInternalClient{} +func newNopInternalClient() nopInternalClient { + return nopInternalClient{} } var _ InternalClient = newNopInternalClient() -func (n NopInternalClient) MaxShardByIndex(context.Context) (map[string]uint64, error) { +func (n nopInternalClient) MaxShardByIndex(context.Context) (map[string]uint64, error) { return nil, nil } -func (n NopInternalClient) Schema(ctx context.Context) ([]*IndexInfo, error) { return nil, nil } -func (n NopInternalClient) CreateIndex(ctx context.Context, index string, opt IndexOptions) error { +func (n nopInternalClient) Schema(ctx context.Context) ([]*IndexInfo, error) { return nil, nil } +func (n nopInternalClient) CreateIndex(ctx context.Context, index string, opt IndexOptions) error { return nil } -func (n NopInternalClient) FragmentNodes(ctx context.Context, index string, shard uint64) ([]*Node, error) { +func (n nopInternalClient) FragmentNodes(ctx context.Context, index string, shard uint64) ([]*Node, error) { return nil, nil } -func (n NopInternalClient) Query(ctx context.Context, index string, queryRequest *QueryRequest) (*QueryResponse, error) { +func (n nopInternalClient) Query(ctx context.Context, index string, queryRequest *QueryRequest) (*QueryResponse, error) { return nil, nil } -func (n NopInternalClient) QueryNode(ctx context.Context, uri *URI, index string, queryRequest *QueryRequest) (*QueryResponse, error) { +func (n nopInternalClient) QueryNode(ctx context.Context, uri *URI, index string, queryRequest *QueryRequest) (*QueryResponse, error) { return nil, nil } -func (n NopInternalClient) Import(ctx context.Context, index, field string, shard uint64, bits []Bit) error { +func (n nopInternalClient) Import(ctx context.Context, index, field string, shard uint64, bits []Bit) error { return nil } -func (n NopInternalClient) ImportK(ctx context.Context, index, field string, bits []Bit) error { +func (n nopInternalClient) ImportK(ctx context.Context, index, field string, bits []Bit) error { return nil } -func (n NopInternalClient) EnsureIndex(ctx context.Context, name string, options IndexOptions) error { +func (n nopInternalClient) EnsureIndex(ctx context.Context, name string, options IndexOptions) error { return nil } -func (n NopInternalClient) EnsureField(ctx context.Context, indexName string, fieldName string) error { +func (n nopInternalClient) EnsureField(ctx context.Context, indexName string, fieldName string) error { return nil } -func (n NopInternalClient) ImportValue(ctx context.Context, index, field string, shard uint64, vals []FieldValue) error { +func (n nopInternalClient) ImportValue(ctx context.Context, index, field string, shard uint64, vals []FieldValue) error { return nil } -func (n NopInternalClient) ExportCSV(ctx context.Context, index, field string, shard uint64, w io.Writer) error { +func (n nopInternalClient) ExportCSV(ctx context.Context, index, field string, shard uint64, w io.Writer) error { return nil } -func (n NopInternalClient) CreateField(ctx context.Context, index, field string) error { return nil } -func (n NopInternalClient) FragmentBlocks(ctx context.Context, uri *URI, index, field string, shard uint64) ([]FragmentBlock, error) { +func (n nopInternalClient) CreateField(ctx context.Context, index, field string) error { return nil } +func (n nopInternalClient) FragmentBlocks(ctx context.Context, uri *URI, index, field string, shard uint64) ([]FragmentBlock, error) { return nil, nil } -func (n NopInternalClient) BlockData(ctx context.Context, uri *URI, index, field string, shard uint64, block int) ([]uint64, []uint64, error) { +func (n nopInternalClient) BlockData(ctx context.Context, uri *URI, index, field string, shard uint64, block int) ([]uint64, []uint64, error) { return nil, nil, nil } -func (n NopInternalClient) ColumnAttrDiff(ctx context.Context, uri *URI, index string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) { +func (n nopInternalClient) ColumnAttrDiff(ctx context.Context, uri *URI, index string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) { return nil, nil } -func (n NopInternalClient) RowAttrDiff(ctx context.Context, uri *URI, index, field string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) { +func (n nopInternalClient) RowAttrDiff(ctx context.Context, uri *URI, index, field string, blks []AttrBlock) (map[uint64]map[string]interface{}, error) { return nil, nil } -func (n NopInternalClient) SendMessage(ctx context.Context, uri *URI, msg []byte) error { +func (n nopInternalClient) SendMessage(ctx context.Context, uri *URI, msg []byte) error { return nil } -func (n NopInternalClient) RetrieveShardFromURI(ctx context.Context, index, field string, shard uint64, uri URI) (io.ReadCloser, error) { +func (n nopInternalClient) RetrieveShardFromURI(ctx context.Context, index, field string, shard uint64, uri URI) (io.ReadCloser, error) { return nil, nil } From ae5f9210d5826837cf9344f97d6646a61106d3a0 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:50:35 -0500 Subject: [PATCH 034/138] Unexport NopInternalQueryClient --- client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 271c8d170..6c912bd99 100644 --- a/client.go +++ b/client.go @@ -56,14 +56,14 @@ type InternalQueryClient interface { QueryNode(ctx context.Context, uri *URI, index string, queryRequest *QueryRequest) (*QueryResponse, error) } -type NopInternalQueryClient struct{} +type nopInternalQueryClient struct{} -func (n *NopInternalQueryClient) QueryNode(ctx context.Context, uri *URI, index string, queryRequest *QueryRequest) (*QueryResponse, error) { +func (n *nopInternalQueryClient) QueryNode(ctx context.Context, uri *URI, index string, queryRequest *QueryRequest) (*QueryResponse, error) { return nil, nil } -func newNopInternalQueryClient() *NopInternalQueryClient { - return &NopInternalQueryClient{} +func newNopInternalQueryClient() *nopInternalQueryClient { + return &nopInternalQueryClient{} } var _ InternalQueryClient = newNopInternalQueryClient() From 6b5595d48c2a2b4bc913a8b21a5089210a8c0947 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:50:41 -0500 Subject: [PATCH 035/138] Unexport NopSystemInfo --- diagnostics.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/diagnostics.go b/diagnostics.go index 11d3f5b9c..9649a6505 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -268,50 +268,50 @@ type SystemInfo interface { } // newNopSystemInfo creates a no-op implementation of SystemInfo. -func newNopSystemInfo() *NopSystemInfo { - return &NopSystemInfo{} +func newNopSystemInfo() *nopSystemInfo { + return &nopSystemInfo{} } -// NopSystemInfo is a no-op implementation of SystemInfo. -type NopSystemInfo struct { +// nopSystemInfo is a no-op implementation of SystemInfo. +type nopSystemInfo struct { } // Uptime is a no-op implementation of SystemInfo.Uptime. -func (n *NopSystemInfo) Uptime() (uint64, error) { +func (n *nopSystemInfo) Uptime() (uint64, error) { return 0, nil } // Platform is a no-op implementation of SystemInfo.Platform. -func (n *NopSystemInfo) Platform() (string, error) { +func (n *nopSystemInfo) Platform() (string, error) { return "", nil } // Family is a no-op implementation of SystemInfo.Family. -func (n *NopSystemInfo) Family() (string, error) { +func (n *nopSystemInfo) Family() (string, error) { return "", nil } // OSVersion is a no-op implementation of SystemInfo.OSVersion. -func (n *NopSystemInfo) OSVersion() (string, error) { +func (n *nopSystemInfo) OSVersion() (string, error) { return "", nil } // KernelVersion is a no-op implementation of SystemInfo.KernelVersion. -func (n *NopSystemInfo) KernelVersion() (string, error) { +func (n *nopSystemInfo) KernelVersion() (string, error) { return "", nil } // MemFree is a no-op implementation of SystemInfo.MemFree. -func (n *NopSystemInfo) MemFree() (uint64, error) { +func (n *nopSystemInfo) MemFree() (uint64, error) { return 0, nil } // MemTotal is a no-op implementation of SystemInfo.MemTotal. -func (n *NopSystemInfo) MemTotal() (uint64, error) { +func (n *nopSystemInfo) MemTotal() (uint64, error) { return 0, nil } // MemUsed is a no-op implementation of SystemInfo.MemUsed. -func (n *NopSystemInfo) MemUsed() (uint64, error) { +func (n *nopSystemInfo) MemUsed() (uint64, error) { return 0, nil } From edf87473ee40262d7f28f4d30c7cf34849f3baac Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:53:07 -0500 Subject: [PATCH 036/138] Unexport Row.ClearBit --- fragment.go | 2 +- row.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fragment.go b/fragment.go index 1ae3c5bb3..99b107a91 100644 --- a/fragment.go +++ b/fragment.go @@ -446,7 +446,7 @@ func (f *fragment) unprotectedClearBit(rowID, columnID uint64) (changed bool, er // Get the row from cache or fragment.storage. row := f.unprotectedRow(rowID, true, true) - row.ClearBit(columnID) + row.clearBit(columnID) // Update the cache. f.cache.Add(rowID, row.Count()) diff --git a/row.go b/row.go index d6a0037cc..06b116fb0 100644 --- a/row.go +++ b/row.go @@ -159,8 +159,8 @@ func (r *Row) SetBit(i uint64) (changed bool) { return r.createSegmentIfNotExists(i / ShardWidth).SetBit(i) } -// ClearBit clears the i-th column of the row. -func (r *Row) ClearBit(i uint64) (changed bool) { +// clearBit clears the i-th column of the row. +func (r *Row) clearBit(i uint64) (changed bool) { s := r.segment(i / ShardWidth) if s == nil { return false From 3025586378881f651187ed83a77ab789c0703d67 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:53:15 -0500 Subject: [PATCH 037/138] Unexport Row.Intersect --- executor.go | 2 +- fragment.go | 12 ++++++------ row.go | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/executor.go b/executor.go index 579a9aa9d..c0513b6ae 100644 --- a/executor.go +++ b/executor.go @@ -712,7 +712,7 @@ func (e *executor) executeIntersectShard(ctx context.Context, index string, c *p if i == 0 { other = row } else { - other = other.Intersect(row) + other = other.intersect(row) } } other.InvalidateCount() diff --git a/fragment.go b/fragment.go index 99b107a91..ac1c14061 100644 --- a/fragment.go +++ b/fragment.go @@ -598,7 +598,7 @@ func (f *fragment) min(filter *Row, bitDepth uint) (min, count uint64, err error consider := f.row(uint64(bitDepth)) if filter != nil { - consider = consider.Intersect(filter) + consider = consider.intersect(filter) } // If there are no columns to consider, return early. @@ -631,7 +631,7 @@ func (f *fragment) max(filter *Row, bitDepth uint) (max, count uint64, err error consider := f.row(uint64(bitDepth)) if filter != nil { - consider = consider.Intersect(filter) + consider = consider.intersect(filter) } // If there are no columns to consider, return early. @@ -643,7 +643,7 @@ func (f *fragment) max(filter *Row, bitDepth uint) (max, count uint64, err error ii := i - 1 // allow for uint range: (bitDepth-1) to 0 row := f.row(uint64(ii)) - x := row.Intersect(consider) + x := row.intersect(consider) count = x.Count() if count > 0 { max += (1 << ii) @@ -682,7 +682,7 @@ func (f *fragment) rangeEQ(bitDepth uint, predicate uint64) (*Row, error) { bit := (predicate >> uint(i)) & 1 if bit == 1 { - b = b.Intersect(row) + b = b.intersect(row) } else { b = b.Difference(row) } @@ -783,7 +783,7 @@ func (f *fragment) rangeGT(bitDepth uint, predicate uint64, allowEquality bool) // If bit is unset then add columns with set bit to keep. // Don't bother to compute this on the final iteration. if i > 0 { - keep = keep.Union(b.Intersect(row)) + keep = keep.Union(b.intersect(row)) } } @@ -815,7 +815,7 @@ func (f *fragment) rangeBetween(bitDepth uint, predicateMin, predicateMax uint64 // If bit is unset then add columns with set bit to keep. // Don't bother to compute this on the final iteration. if i > 0 { - keep1 = keep1.Union(b.Intersect(row)) + keep1 = keep1.Union(b.intersect(row)) } } diff --git a/row.go b/row.go index 06b116fb0..a78002034 100644 --- a/row.go +++ b/row.go @@ -82,8 +82,8 @@ func (r *Row) IntersectionCount(other *Row) uint64 { return n } -// Intersect returns the itersection of r and other. -func (r *Row) Intersect(other *Row) *Row { +// intersect returns the itersection of r and other. +func (r *Row) intersect(other *Row) *Row { var segments []RowSegment itr := newMergeSegmentIterator(r.segments, other.segments) From 018905fcd9755fa3ba32b6df8d65a14cb399c731 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:53:23 -0500 Subject: [PATCH 038/138] Unexport Row.IntersectionCount --- fragment.go | 8 ++++---- fragment_internal_test.go | 2 +- row.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fragment.go b/fragment.go index ac1c14061..1614c2163 100644 --- a/fragment.go +++ b/fragment.go @@ -566,7 +566,7 @@ func (f *fragment) sum(filter *Row, bitDepth uint) (sum, count uint64, err error // Compute count based on the existence row. row := f.row(uint64(bitDepth)) if filter != nil { - count = row.IntersectionCount(filter) + count = row.intersectionCount(filter) } else { count = row.Count() } @@ -582,7 +582,7 @@ func (f *fragment) sum(filter *Row, bitDepth uint) (sum, count uint64, err error row := f.row(uint64(i)) cnt := uint64(0) if filter != nil { - cnt = row.IntersectionCount(filter) + cnt = row.intersectionCount(filter) } else { cnt = row.Count() } @@ -938,7 +938,7 @@ func (f *fragment) top(opt topOptions) ([]Pair, error) { // Calculate count and append. count := cnt if opt.Src != nil { - count = opt.Src.IntersectionCount(f.row(rowID)) + count = opt.Src.intersectionCount(f.row(rowID)) } if count == 0 { continue @@ -982,7 +982,7 @@ func (f *fragment) top(opt topOptions) ([]Pair, error) { // Calculate the intersecting column count and skip if it's below our // last row in our current result set. - count := opt.Src.IntersectionCount(f.row(rowID)) + count := opt.Src.intersectionCount(f.row(rowID)) if count < threshold { continue } diff --git a/fragment_internal_test.go b/fragment_internal_test.go index 4ceb33819..e665a10ba 100644 --- a/fragment_internal_test.go +++ b/fragment_internal_test.go @@ -1063,7 +1063,7 @@ func BenchmarkFragment_IntersectionCount(b *testing.B) { // Start benchmark b.ResetTimer() for i := 0; i < b.N; i++ { - if n := f.row(1).IntersectionCount(f.row(2)); n == 0 { + if n := f.row(1).intersectionCount(f.row(2)); n == 0 { b.Fatalf("unexpected count: %d", n) } } diff --git a/row.go b/row.go index a78002034..125fec08c 100644 --- a/row.go +++ b/row.go @@ -66,8 +66,8 @@ func (r *Row) Merge(other *Row) { r.InvalidateCount() } -// IntersectionCount returns the number of intersections between r and other. -func (r *Row) IntersectionCount(other *Row) uint64 { +// intersectionCount returns the number of intersections between r and other. +func (r *Row) intersectionCount(other *Row) uint64 { var n uint64 itr := newMergeSegmentIterator(r.segments, other.segments) From 259f5ac3b9c96fbf77c5fbb2b6d96db9986546ee Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:53:29 -0500 Subject: [PATCH 039/138] Unexport Row.InvalidateCount --- executor.go | 8 ++++---- fragment.go | 2 +- row.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/executor.go b/executor.go index c0513b6ae..34eca4026 100644 --- a/executor.go +++ b/executor.go @@ -661,7 +661,7 @@ func (e *executor) executeDifferenceShard(ctx context.Context, index string, c * other = other.Difference(row) } } - other.InvalidateCount() + other.invalidateCount() return other, nil } @@ -715,7 +715,7 @@ func (e *executor) executeIntersectShard(ctx context.Context, index string, c *p other = other.intersect(row) } } - other.InvalidateCount() + other.invalidateCount() return other, nil } @@ -937,7 +937,7 @@ func (e *executor) executeUnionShard(ctx context.Context, index string, c *pql.C other = other.Union(row) } } - other.InvalidateCount() + other.invalidateCount() return other, nil } @@ -956,7 +956,7 @@ func (e *executor) executeXorShard(ctx context.Context, index string, c *pql.Cal other = other.Xor(row) } } - other.InvalidateCount() + other.invalidateCount() return other, nil } diff --git a/fragment.go b/fragment.go index 1614c2163..dc7ded5b8 100644 --- a/fragment.go +++ b/fragment.go @@ -349,7 +349,7 @@ func (f *fragment) unprotectedRow(rowID uint64, checkRowCache bool, updateRowCac writable: false, }}, } - row.InvalidateCount() + row.invalidateCount() if updateRowCache { f.rowCache.Add(rowID, row) diff --git a/row.go b/row.go index 125fec08c..109dbc296 100644 --- a/row.go +++ b/row.go @@ -63,7 +63,7 @@ func (r *Row) Merge(other *Row) { } r.segments = segments - r.InvalidateCount() + r.invalidateCount() } // intersectionCount returns the number of intersections between r and other. @@ -208,8 +208,8 @@ func (r *Row) createSegmentIfNotExists(shard uint64) *RowSegment { return &r.segments[i] } -// InvalidateCount updates the cached count in the row. -func (r *Row) InvalidateCount() { +// invalidateCount updates the cached count in the row. +func (r *Row) invalidateCount() { for i := range r.segments { r.segments[i].InvalidateCount() } From 45f3439a7f317e2ff6240c214de7fa37a0d8a938 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:53:41 -0500 Subject: [PATCH 040/138] Unexport RowSegment --- executor.go | 2 +- fragment.go | 2 +- row.go | 64 ++++++++++++++++++++++++++--------------------------- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/executor.go b/executor.go index 34eca4026..03d18f936 100644 --- a/executor.go +++ b/executor.go @@ -375,7 +375,7 @@ func (e *executor) executeBitmapCall(ctx context.Context, index string, c *pql.C } if opt.ExcludeColumns { - row.segments = []RowSegment{} + row.segments = []rowSegment{} } return row, nil diff --git a/fragment.go b/fragment.go index dc7ded5b8..8c5fbf787 100644 --- a/fragment.go +++ b/fragment.go @@ -343,7 +343,7 @@ func (f *fragment) unprotectedRow(rowID uint64, checkRowCache bool, updateRowCac // We Clone() data because otherwise row will contains pointers to containers in storage. // This causes unexpected results when we cache the row and try to use it later. row := &Row{ - segments: []RowSegment{{ + segments: []rowSegment{{ data: *data.Clone(), shard: f.shard, writable: false, diff --git a/row.go b/row.go index 109dbc296..38ba24f9b 100644 --- a/row.go +++ b/row.go @@ -24,7 +24,7 @@ import ( // Row is a set of integers (the associated columns), and attributes which are // arbitrary key/value pairs storing metadata about what the row represents. type Row struct { - segments []RowSegment + segments []rowSegment // String keys translated to/from segment columns. Keys []string @@ -44,7 +44,7 @@ func NewRow(columns ...uint64) *Row { // Merge merges data from other into r. func (r *Row) Merge(other *Row) { - var segments []RowSegment + var segments []rowSegment itr := newMergeSegmentIterator(r.segments, other.segments) for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() { @@ -84,7 +84,7 @@ func (r *Row) intersectionCount(other *Row) uint64 { // intersect returns the itersection of r and other. func (r *Row) intersect(other *Row) *Row { - var segments []RowSegment + var segments []rowSegment itr := newMergeSegmentIterator(r.segments, other.segments) for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() { @@ -100,7 +100,7 @@ func (r *Row) intersect(other *Row) *Row { // Xor returns the xor of r and other. func (r *Row) Xor(other *Row) *Row { - var segments []RowSegment + var segments []rowSegment itr := newMergeSegmentIterator(r.segments, other.segments) for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() { @@ -120,7 +120,7 @@ func (r *Row) Xor(other *Row) *Row { // Union returns the bitwise union of r and other. func (r *Row) Union(other *Row) *Row { - var segments []RowSegment + var segments []rowSegment itr := newMergeSegmentIterator(r.segments, other.segments) for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() { if s1 == nil { @@ -138,7 +138,7 @@ func (r *Row) Union(other *Row) *Row { // Difference returns the diff of r and other. func (r *Row) Difference(other *Row) *Row { - var segments []RowSegment + var segments []rowSegment itr := newMergeSegmentIterator(r.segments, other.segments) for s0, s1 := itr.next(); s0 != nil || s1 != nil; s0, s1 = itr.next() { @@ -169,13 +169,13 @@ func (r *Row) clearBit(i uint64) (changed bool) { } // Segments returns a list of all segments in the row. -func (r *Row) Segments() []RowSegment { +func (r *Row) Segments() []rowSegment { return r.segments } // segment returns a segment for a given shard. // Returns nil if segment does not exist. -func (r *Row) segment(shard uint64) *RowSegment { +func (r *Row) segment(shard uint64) *rowSegment { if i := sort.Search(len(r.segments), func(i int) bool { return r.segments[i].shard >= shard }); i < len(r.segments) && r.segments[i].shard == shard { @@ -184,7 +184,7 @@ func (r *Row) segment(shard uint64) *RowSegment { return nil } -func (r *Row) createSegmentIfNotExists(shard uint64) *RowSegment { +func (r *Row) createSegmentIfNotExists(shard uint64) *rowSegment { i := sort.Search(len(r.segments), func(i int) bool { return r.segments[i].shard >= shard }) @@ -195,11 +195,11 @@ func (r *Row) createSegmentIfNotExists(shard uint64) *RowSegment { } // Insert new segment. - r.segments = append(r.segments, RowSegment{data: *roaring.NewBitmap()}) + r.segments = append(r.segments, rowSegment{data: *roaring.NewBitmap()}) if i < len(r.segments) { copy(r.segments[i+1:], r.segments[i:]) } - r.segments[i] = RowSegment{ + r.segments[i] = rowSegment{ data: *roaring.NewBitmap(), shard: shard, writable: true, @@ -251,10 +251,10 @@ func (r *Row) Columns() []uint64 { return a } -// RowSegment holds a subset of a row. +// rowSegment holds a subset of a row. // This could point to a mmapped roaring bitmap or an in-memory bitmap. The // width of the segment will always match the shard width. -type RowSegment struct { +type rowSegment struct { // Shard this segment belongs to shard uint64 @@ -270,7 +270,7 @@ type RowSegment struct { // Merge adds chunks from other to s. // Chunks in s are overwritten if they exist in other. -func (s *RowSegment) Merge(other *RowSegment) { +func (s *rowSegment) Merge(other *rowSegment) { s.ensureWritable() itr := other.data.Iterator() @@ -280,15 +280,15 @@ func (s *RowSegment) Merge(other *RowSegment) { } // IntersectionCount returns the number of intersections between s and other. -func (s *RowSegment) IntersectionCount(other *RowSegment) uint64 { +func (s *rowSegment) IntersectionCount(other *rowSegment) uint64 { return s.data.IntersectionCount(&other.data) } // Intersect returns the itersection of s and other. -func (s *RowSegment) Intersect(other *RowSegment) *RowSegment { +func (s *rowSegment) Intersect(other *rowSegment) *rowSegment { data := s.data.Intersect(&other.data) - return &RowSegment{ + return &rowSegment{ data: *data, shard: s.shard, n: data.Count(), @@ -296,10 +296,10 @@ func (s *RowSegment) Intersect(other *RowSegment) *RowSegment { } // Union returns the bitwise union of s and other. -func (s *RowSegment) Union(other *RowSegment) *RowSegment { +func (s *rowSegment) Union(other *rowSegment) *rowSegment { data := s.data.Union(&other.data) - return &RowSegment{ + return &rowSegment{ data: *data, shard: s.shard, n: data.Count(), @@ -307,10 +307,10 @@ func (s *RowSegment) Union(other *RowSegment) *RowSegment { } // Difference returns the diff of s and other. -func (s *RowSegment) Difference(other *RowSegment) *RowSegment { +func (s *rowSegment) Difference(other *rowSegment) *rowSegment { data := s.data.Difference(&other.data) - return &RowSegment{ + return &rowSegment{ data: *data, shard: s.shard, n: data.Count(), @@ -318,10 +318,10 @@ func (s *RowSegment) Difference(other *RowSegment) *RowSegment { } // Xor returns the xor of s and other. -func (s *RowSegment) Xor(other *RowSegment) *RowSegment { +func (s *rowSegment) Xor(other *rowSegment) *rowSegment { data := s.data.Xor(&other.data) - return &RowSegment{ + return &rowSegment{ data: *data, shard: s.shard, n: data.Count(), @@ -329,7 +329,7 @@ func (s *RowSegment) Xor(other *RowSegment) *RowSegment { } // SetBit sets the i-th column of the row. -func (s *RowSegment) SetBit(i uint64) (changed bool) { +func (s *rowSegment) SetBit(i uint64) (changed bool) { s.ensureWritable() changed, _ = s.data.Add(i) if changed { @@ -339,7 +339,7 @@ func (s *RowSegment) SetBit(i uint64) (changed bool) { } // ClearBit clears the i-th column of the row. -func (s *RowSegment) ClearBit(i uint64) (changed bool) { +func (s *rowSegment) ClearBit(i uint64) (changed bool) { s.ensureWritable() changed, _ = s.data.Remove(i) @@ -350,12 +350,12 @@ func (s *RowSegment) ClearBit(i uint64) (changed bool) { } // InvalidateCount updates the cached count in the row. -func (s *RowSegment) InvalidateCount() { +func (s *rowSegment) InvalidateCount() { s.n = s.data.Count() } // Columns returns a list of all columns set in the segment. -func (s *RowSegment) Columns() []uint64 { +func (s *rowSegment) Columns() []uint64 { a := make([]uint64, 0, s.Count()) itr := s.data.Iterator() for v, eof := itr.Next(); !eof; v, eof = itr.Next() { @@ -365,10 +365,10 @@ func (s *RowSegment) Columns() []uint64 { } // Count returns the number of set columns in the row. -func (s *RowSegment) Count() uint64 { return s.n } +func (s *rowSegment) Count() uint64 { return s.n } // ensureWritable clones the segment if it is pointing to non-writable data. -func (s *RowSegment) ensureWritable() { +func (s *rowSegment) ensureWritable() { if s.writable { return } @@ -379,16 +379,16 @@ func (s *RowSegment) ensureWritable() { // mergeSegmentIterator produces an iterator that loops through two sets of segments. type mergeSegmentIterator struct { - a0, a1 []RowSegment + a0, a1 []rowSegment } // newMergeSegmentIterator returns a new instance of mergeSegmentIterator. -func newMergeSegmentIterator(a0, a1 []RowSegment) mergeSegmentIterator { +func newMergeSegmentIterator(a0, a1 []rowSegment) mergeSegmentIterator { return mergeSegmentIterator{a0: a0, a1: a1} } // next returns the next set of segments. -func (itr *mergeSegmentIterator) next() (s0, s1 *RowSegment) { +func (itr *mergeSegmentIterator) next() (s0, s1 *rowSegment) { // Find current segments. if len(itr.a0) > 0 { s0 = &itr.a0[0] From 5709d329d5373363c8e48e12a109e32d8b8be474 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:54:16 -0500 Subject: [PATCH 041/138] Unexport StandardLogger --- logger.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/logger.go b/logger.go index 93b12c3f8..6afa24c96 100644 --- a/logger.go +++ b/logger.go @@ -43,24 +43,24 @@ func (n *nopLogger) Printf(format string, v ...interface{}) {} // Debugf is a no-op implementation of the Logger Debugf method. func (n *nopLogger) Debugf(format string, v ...interface{}) {} -// StandardLogger is a basic implementation of pilosa.Logger based on log.Logger. -type StandardLogger struct { +// standardLogger is a basic implementation of pilosa.Logger based on log.Logger. +type standardLogger struct { logger *log.Logger } -func NewStandardLogger(w io.Writer) *StandardLogger { - return &StandardLogger{ +func NewStandardLogger(w io.Writer) *standardLogger { + return &standardLogger{ logger: log.New(w, "", log.LstdFlags), } } -func (s *StandardLogger) Printf(format string, v ...interface{}) { +func (s *standardLogger) Printf(format string, v ...interface{}) { s.logger.Printf(format, v...) } -func (s *StandardLogger) Debugf(format string, v ...interface{}) {} +func (s *standardLogger) Debugf(format string, v ...interface{}) {} -func (s *StandardLogger) Logger() *log.Logger { +func (s *standardLogger) Logger() *log.Logger { return s.logger } From 3f7f82bf058a2fbbe91cac2d9839423831032d96 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:54:23 -0500 Subject: [PATCH 042/138] Unexport Topology.AddID --- cluster.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cluster.go b/cluster.go index 6f0a88904..e49e07111 100644 --- a/cluster.go +++ b/cluster.go @@ -323,7 +323,7 @@ func (c *cluster) addNode(node *Node) error { if c.Topology == nil { return fmt.Errorf("Cluster.Topology is nil") } - if !c.Topology.AddID(node.ID) { + if !c.Topology.addID(node.ID) { return nil } @@ -1429,8 +1429,8 @@ func (t *Topology) positionByID(nodeID string) int { return -1 } -// AddID adds the node ID to the topology and returns true if added. -func (t *Topology) AddID(nodeID string) bool { +// addID adds the node ID to the topology and returns true if added. +func (t *Topology) addID(nodeID string) bool { t.mu.Lock() defer t.mu.Unlock() if t.containsID(nodeID) { From 65472609a5e0c13bbdbf1c7ffd94d72376641d89 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:54:30 -0500 Subject: [PATCH 043/138] Unexport Topology.Encode --- cluster.go | 4 ++-- utils_internal_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cluster.go b/cluster.go index e49e07111..4919e4e10 100644 --- a/cluster.go +++ b/cluster.go @@ -1463,8 +1463,8 @@ func (t *Topology) RemoveID(nodeID string) bool { return true } -// Encode converts t into its internal representation. -func (t *Topology) Encode() *internal.Topology { +// encode converts t into its internal representation. +func (t *Topology) encode() *internal.Topology { return encodeTopology(t) } diff --git a/utils_internal_test.go b/utils_internal_test.go index 816c477ce..1f58c464c 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -185,7 +185,7 @@ func (t *ClusterCluster) addNode() error { // WriteTopology writes the given topology to disk. func (t *ClusterCluster) WriteTopology(path string, top *Topology) error { - if buf, err := proto.Marshal(top.Encode()); err != nil { + if buf, err := proto.Marshal(top.encode()); err != nil { return err } else if err := ioutil.WriteFile(filepath.Join(path, ".topology"), buf, 0666); err != nil { return err From e52f71340680a8747c91b355594c22c2006cad37 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:54:37 -0500 Subject: [PATCH 044/138] Unexport Topology.RemoveID --- cluster.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cluster.go b/cluster.go index 4919e4e10..de707674b 100644 --- a/cluster.go +++ b/cluster.go @@ -343,7 +343,7 @@ func (c *cluster) removeNode(node *Node) error { if c.Topology == nil { return fmt.Errorf("Cluster.Topology is nil") } - if !c.Topology.RemoveID(node.ID) { + if !c.Topology.removeID(node.ID) { return nil } @@ -1446,8 +1446,8 @@ func (t *Topology) addID(nodeID string) bool { return true } -// RemoveID removes the node ID from the topology and returns true if removed. -func (t *Topology) RemoveID(nodeID string) bool { +// removeID removes the node ID from the topology and returns true if removed. +func (t *Topology) removeID(nodeID string) bool { t.mu.Lock() defer t.mu.Unlock() From 9c160ee65e66892ce83919a862d3d850c65d8e51 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:57:00 -0500 Subject: [PATCH 045/138] Unexport Topology.NodeIDs --- cluster.go | 36 ++++++++++++++++++------------------ cluster_internal_test.go | 32 ++++++++++++++++---------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cluster.go b/cluster.go index de707674b..dd61d0a9f 100644 --- a/cluster.go +++ b/cluster.go @@ -888,21 +888,21 @@ func (c *cluster) markAsJoined() { } func (c *cluster) needTopologyAgreement() bool { - return c.State() == ClusterStateStarting && !stringSlicesAreEqual(c.Topology.NodeIDs, c.nodeIDs()) + return c.State() == ClusterStateStarting && !stringSlicesAreEqual(c.Topology.nodeIDs, c.nodeIDs()) } func (c *cluster) haveTopologyAgreement() bool { if c.Static { return true } - return stringSlicesAreEqual(c.Topology.NodeIDs, c.nodeIDs()) + return stringSlicesAreEqual(c.Topology.nodeIDs, c.nodeIDs()) } func (c *cluster) allNodesReady() bool { if c.Static { return true } - for _, uri := range c.Topology.NodeIDs { + for _, uri := range c.Topology.nodeIDs { if c.Topology.nodeStates[uri] != nodeStateReady { return false } @@ -1394,7 +1394,7 @@ func (n nodeIDs) ContainsID(id string) bool { // Topology represents the list of hosts in the cluster. type Topology struct { mu sync.RWMutex - NodeIDs []string + nodeIDs []string ClusterID string @@ -1417,11 +1417,11 @@ func (t *Topology) ContainsID(id string) bool { } func (t *Topology) containsID(id string) bool { - return nodeIDs(t.NodeIDs).ContainsID(id) + return nodeIDs(t.nodeIDs).ContainsID(id) } func (t *Topology) positionByID(nodeID string) int { - for i, tid := range t.NodeIDs { + for i, tid := range t.nodeIDs { if tid == nodeID { return i } @@ -1436,11 +1436,11 @@ func (t *Topology) addID(nodeID string) bool { if t.containsID(nodeID) { return false } - t.NodeIDs = append(t.NodeIDs, nodeID) + t.nodeIDs = append(t.nodeIDs, nodeID) - sort.Slice(t.NodeIDs, + sort.Slice(t.nodeIDs, func(i, j int) bool { - return t.NodeIDs[i] < t.NodeIDs[j] + return t.nodeIDs[i] < t.nodeIDs[j] }) return true @@ -1456,9 +1456,9 @@ func (t *Topology) removeID(nodeID string) bool { return false } - copy(t.NodeIDs[i:], t.NodeIDs[i+1:]) - t.NodeIDs[len(t.NodeIDs)-1] = "" - t.NodeIDs = t.NodeIDs[:len(t.NodeIDs)-1] + copy(t.nodeIDs[i:], t.nodeIDs[i+1:]) + t.nodeIDs[len(t.nodeIDs)-1] = "" + t.nodeIDs = t.nodeIDs[:len(t.nodeIDs)-1] return true } @@ -1519,13 +1519,13 @@ func (c *cluster) considerTopology() error { } // If there is no .topology file, it's safe to proceed. - if len(c.Topology.NodeIDs) == 0 { + if len(c.Topology.nodeIDs) == 0 { return nil } // The local node (coordinator) must be in the .topology. if !c.Topology.ContainsID(c.Node.ID) { - return fmt.Errorf("coordinator %s is not in topology: %v", c.Node.ID, c.Topology.NodeIDs) + return fmt.Errorf("coordinator %s is not in topology: %v", c.Node.ID, c.Topology.nodeIDs) } // If local node is the only thing in .topology, continue. @@ -1775,7 +1775,7 @@ func encodeTopology(topology *Topology) *internal.Topology { } return &internal.Topology{ ClusterID: topology.ClusterID, - NodeIDs: topology.NodeIDs, + NodeIDs: topology.nodeIDs, } } @@ -1786,10 +1786,10 @@ func decodeTopology(topology *internal.Topology) (*Topology, error) { t := newTopology() t.ClusterID = topology.ClusterID - t.NodeIDs = topology.NodeIDs - sort.Slice(t.NodeIDs, + t.nodeIDs = topology.NodeIDs + sort.Slice(t.nodeIDs, func(i, j int) bool { - return t.NodeIDs[i] < t.NodeIDs[j] + return t.nodeIDs[i] < t.nodeIDs[j] }) return t, nil diff --git a/cluster_internal_test.go b/cluster_internal_test.go index 06e7dd3d7..5b514e517 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -536,12 +536,12 @@ func TestCluster_ResizeStates(t *testing.T) { } expectedTop := &Topology{ - NodeIDs: []string{node.Node.ID}, + nodeIDs: []string{node.Node.ID}, } // Verify topology file. - if !reflect.DeepEqual(node.Topology.NodeIDs, expectedTop.NodeIDs) { - t.Errorf("expected topology: %v, but got: %v", expectedTop.NodeIDs, node.Topology.NodeIDs) + if !reflect.DeepEqual(node.Topology.nodeIDs, expectedTop.nodeIDs) { + t.Errorf("expected topology: %v, but got: %v", expectedTop.nodeIDs, node.Topology.nodeIDs) } // Close TestCluster. @@ -558,7 +558,7 @@ func TestCluster_ResizeStates(t *testing.T) { // write topology to data file top := &Topology{ - NodeIDs: []string{node.Node.ID}, + nodeIDs: []string{node.Node.ID}, } tc.WriteTopology(node.Path, top) @@ -586,7 +586,7 @@ func TestCluster_ResizeStates(t *testing.T) { // write topology to data file top := &Topology{ - NodeIDs: []string{"some-other-host"}, + nodeIDs: []string{"some-other-host"}, } tc.WriteTopology(node.Path, top) @@ -625,14 +625,14 @@ func TestCluster_ResizeStates(t *testing.T) { } expectedTop := &Topology{ - NodeIDs: []string{node0.Node.ID, node1.Node.ID}, + nodeIDs: []string{node0.Node.ID, node1.Node.ID}, } // Verify topology file. - if !reflect.DeepEqual(node0.Topology.NodeIDs, expectedTop.NodeIDs) { - t.Errorf("expected node0 topology: %v, but got: %v", expectedTop.NodeIDs, node0.Topology.NodeIDs) - } else if !reflect.DeepEqual(node1.Topology.NodeIDs, expectedTop.NodeIDs) { - t.Errorf("expected node1 topology: %v, but got: %v", expectedTop.NodeIDs, node1.Topology.NodeIDs) + if !reflect.DeepEqual(node0.Topology.nodeIDs, expectedTop.nodeIDs) { + t.Errorf("expected node0 topology: %v, but got: %v", expectedTop.nodeIDs, node0.Topology.nodeIDs) + } else if !reflect.DeepEqual(node1.Topology.nodeIDs, expectedTop.nodeIDs) { + t.Errorf("expected node1 topology: %v, but got: %v", expectedTop.nodeIDs, node1.Topology.nodeIDs) } // Close TestCluster. @@ -648,7 +648,7 @@ func TestCluster_ResizeStates(t *testing.T) { // write topology to data file top := &Topology{ - NodeIDs: []string{"node0", "node2"}, + nodeIDs: []string{"node0", "node2"}, } tc.WriteTopology(node0.Path, top) @@ -721,14 +721,14 @@ func TestCluster_ResizeStates(t *testing.T) { } expectedTop := &Topology{ - NodeIDs: []string{node0.Node.ID, node1.Node.ID}, + nodeIDs: []string{node0.Node.ID, node1.Node.ID}, } // Verify topology file. - if !reflect.DeepEqual(node0.Topology.NodeIDs, expectedTop.NodeIDs) { - t.Errorf("expected node0 topology: %v, but got: %v", expectedTop.NodeIDs, node0.Topology.NodeIDs) - } else if !reflect.DeepEqual(node1.Topology.NodeIDs, expectedTop.NodeIDs) { - t.Errorf("expected node1 topology: %v, but got: %v", expectedTop.NodeIDs, node1.Topology.NodeIDs) + if !reflect.DeepEqual(node0.Topology.nodeIDs, expectedTop.nodeIDs) { + t.Errorf("expected node0 topology: %v, but got: %v", expectedTop.nodeIDs, node0.Topology.nodeIDs) + } else if !reflect.DeepEqual(node1.Topology.nodeIDs, expectedTop.nodeIDs) { + t.Errorf("expected node1 topology: %v, but got: %v", expectedTop.nodeIDs, node1.Topology.nodeIDs) } // Bits From 1af66417e14ef3b8a1946edbbe06a01d55eeb8f8 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:54:49 -0500 Subject: [PATCH 046/138] Unexport Topology.ClusterID --- cluster.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cluster.go b/cluster.go index dd61d0a9f..a36b2c92e 100644 --- a/cluster.go +++ b/cluster.go @@ -364,7 +364,7 @@ func (c *cluster) setID(id string) { c.id = id // Make sure the Topology is updated. - c.Topology.ClusterID = c.id + c.Topology.clusterID = c.id } func (c *cluster) State() string { @@ -818,7 +818,7 @@ func (c *cluster) setup() error { return errors.Wrap(err, "loading topology") } - c.id = c.Topology.ClusterID + c.id = c.Topology.clusterID // Only the coordinator needs to consider the .topology file. if c.isCoordinator() { @@ -1396,7 +1396,7 @@ type Topology struct { mu sync.RWMutex nodeIDs []string - ClusterID string + clusterID string // nodeStates holds the state of each node according to // the coordinator. Used during startup and data load. @@ -1511,7 +1511,7 @@ func (c *cluster) considerTopology() error { if c.id == "" { u := uuid.NewV4() c.id = u.String() - c.Topology.ClusterID = c.id + c.Topology.clusterID = c.id } if c.Static { @@ -1774,7 +1774,7 @@ func encodeTopology(topology *Topology) *internal.Topology { return nil } return &internal.Topology{ - ClusterID: topology.ClusterID, + ClusterID: topology.clusterID, NodeIDs: topology.nodeIDs, } } @@ -1785,7 +1785,7 @@ func decodeTopology(topology *internal.Topology) (*Topology, error) { } t := newTopology() - t.ClusterID = topology.ClusterID + t.clusterID = topology.ClusterID t.nodeIDs = topology.NodeIDs sort.Slice(t.nodeIDs, func(i, j int) bool { From ed0372b1d002555c6afbcc9704e1cc23f35d53d4 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:54:55 -0500 Subject: [PATCH 047/138] Unexport TranslateFile.IsReadOnly --- translate.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/translate.go b/translate.go index 04922b7a6..4b56f83c3 100644 --- a/translate.go +++ b/translate.go @@ -150,8 +150,8 @@ func (s *TranslateFile) Size() int64 { return n } -// IsReadOnly returns true if this store is being replicated from a primary store. -func (s *TranslateFile) IsReadOnly() bool { +// isReadOnly returns true if this store is being replicated from a primary store. +func (s *TranslateFile) isReadOnly() bool { return s.PrimaryTranslateStore != nil } @@ -351,7 +351,7 @@ func (s *TranslateFile) TranslateColumnsToUint64(index string, values []string) s.mu.RUnlock() // Return error if not all values could be translated and this store is read-only. - if s.IsReadOnly() { + if s.isReadOnly() { return ret, ErrTranslateStoreReadOnly } @@ -457,7 +457,7 @@ func (s *TranslateFile) TranslateRowsToUint64(index, frame string, values []stri s.mu.RUnlock() // Return error if not all values could be translated and this store is read-only. - if s.IsReadOnly() { + if s.isReadOnly() { return ret, ErrTranslateStoreReadOnly } From 4c2ba7b7d3723f8cee318e50bfca96ccc5606f4b Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:55:03 -0500 Subject: [PATCH 048/138] Unexport TranslateFile.Size --- translate.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/translate.go b/translate.go index 4b56f83c3..559e90bcb 100644 --- a/translate.go +++ b/translate.go @@ -142,8 +142,8 @@ func (s *TranslateFile) Closing() <-chan struct{} { return s.closing } -// Size returns the number of bytes in use in the data file. -func (s *TranslateFile) Size() int64 { +// size returns the number of bytes in use in the data file. +func (s *TranslateFile) size() int64 { s.mu.RLock() n := s.n s.mu.RUnlock() @@ -277,7 +277,7 @@ func (s *TranslateFile) monitorReplication() { } func (s *TranslateFile) replicate(ctx context.Context) error { - off := s.Size() + off := s.size() // Connect to remote primary. log.Printf("pilosa: replicating from offset %d", off) @@ -967,7 +967,7 @@ func (r *TranslateFileReader) Read(p []byte) (n int, err error) { // read writes the bytes for zero or more valid entries to p. func (r *TranslateFileReader) read(p []byte) (n int, err error) { - sz := r.store.Size() + sz := r.store.size() // Exit if there is no new data. if sz < r.offset { From 7a1d2c69804b46621cd1da62c485419f180df28e Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:55:09 -0500 Subject: [PATCH 049/138] Unexport TranslateFile.MapSize --- translate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translate.go b/translate.go index 559e90bcb..20c886cdf 100644 --- a/translate.go +++ b/translate.go @@ -67,7 +67,7 @@ type TranslateFile struct { rows map[frameKey]*index Path string - MapSize int + mapSize int // If non-nil, data is streamed from a primary and this is a read-only store. PrimaryTranslateStore TranslateStore @@ -84,7 +84,7 @@ func NewTranslateFile() *TranslateFile { cols: make(map[string]*index), rows: make(map[frameKey]*index), - MapSize: defaultMapSize, + mapSize: defaultMapSize, ReplicationRetryInterval: defaultReplicationRetryInterval, } @@ -100,7 +100,7 @@ func (s *TranslateFile) Open() (err error) { s.w = bufio.NewWriter(s.file) // Memory map data file. - if s.data, err = syscall.Mmap(int(s.file.Fd()), 0, s.MapSize, syscall.PROT_READ, syscall.MAP_SHARED); err != nil { + if s.data, err = syscall.Mmap(int(s.file.Fd()), 0, s.mapSize, syscall.PROT_READ, syscall.MAP_SHARED); err != nil { return err } From e4847c498a136d8df62913944eca5bc013c4341a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:55:17 -0500 Subject: [PATCH 050/138] Unexport TranslateFile.ReplicationRetryInterval --- translate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translate.go b/translate.go index 20c886cdf..b75b9767a 100644 --- a/translate.go +++ b/translate.go @@ -73,7 +73,7 @@ type TranslateFile struct { PrimaryTranslateStore TranslateStore // Delay after attempting to connect to a primary that the store will retry. - ReplicationRetryInterval time.Duration + replicationRetryInterval time.Duration } // NewTranslateFile returns a new instance of TranslateFile. @@ -86,7 +86,7 @@ func NewTranslateFile() *TranslateFile { mapSize: defaultMapSize, - ReplicationRetryInterval: defaultReplicationRetryInterval, + replicationRetryInterval: defaultReplicationRetryInterval, } } @@ -270,7 +270,7 @@ func (s *TranslateFile) monitorReplication() { select { case <-s.closing: return - case <-time.After(s.ReplicationRetryInterval): + case <-time.After(s.replicationRetryInterval): log.Printf("pilosa: reconnecting to primary replica") } } From a7c1795cf7b9f8eb697c4ef9d0833abcdbdfdbae Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:55:25 -0500 Subject: [PATCH 051/138] Unexport TranslateFileReader --- translate.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/translate.go b/translate.go index b75b9767a..2341efe51 100644 --- a/translate.go +++ b/translate.go @@ -898,8 +898,8 @@ func pow2(v uint64) uint64 { panic("unreachable") } -// TranslateFileReader implements a reader that continuously streams data from a store. -type TranslateFileReader struct { +// translateFileReader implements a reader that continuously streams data from a store. +type translateFileReader struct { ctx context.Context store *TranslateFile file *os.File @@ -911,8 +911,8 @@ type TranslateFileReader struct { } // newTranslateFileReader returns a new instance of TranslateFileReader. -func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset int64) *TranslateFileReader { - return &TranslateFileReader{ +func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset int64) *translateFileReader { + return &translateFileReader{ ctx: ctx, store: store, offset: offset, @@ -922,7 +922,7 @@ func newTranslateFileReader(ctx context.Context, store *TranslateFile, offset in } // Open initializes the reader. -func (r *TranslateFileReader) Open() (err error) { +func (r *translateFileReader) Open() (err error) { if r.file, err = os.Open(r.store.Path); err != nil { return err } @@ -930,7 +930,7 @@ func (r *TranslateFileReader) Open() (err error) { } // Close closes the underlying file reader. -func (r *TranslateFileReader) Close() error { +func (r *translateFileReader) Close() error { r.once.Do(func() { close(r.closing) }) if r.file != nil { @@ -941,7 +941,7 @@ func (r *TranslateFileReader) Close() error { // Read reads the next section of the available data to p. This should always // read from the start of an entry and read n bytes to the end of another entry. -func (r *TranslateFileReader) Read(p []byte) (n int, err error) { +func (r *translateFileReader) Read(p []byte) (n int, err error) { for { // Obtain notification channel before we check for new data. notify := r.store.WriteNotify() @@ -966,7 +966,7 @@ func (r *TranslateFileReader) Read(p []byte) (n int, err error) { } // read writes the bytes for zero or more valid entries to p. -func (r *TranslateFileReader) read(p []byte) (n int, err error) { +func (r *translateFileReader) read(p []byte) (n int, err error) { sz := r.store.size() // Exit if there is no new data. From 6f256e0edbcf4613190dbad66eae1db7591fb78d Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:55:31 -0500 Subject: [PATCH 052/138] Unexport URI.Normalize --- uri.go | 6 +++--- uri_internal_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/uri.go b/uri.go index 332166b4e..605e5cb82 100644 --- a/uri.go +++ b/uri.go @@ -117,8 +117,8 @@ func (u *URI) HostPort() string { return s } -// Normalize returns the address in a form usable by a HTTP client. -func (u *URI) Normalize() string { +// normalize returns the address in a form usable by a HTTP client. +func (u *URI) normalize() string { scheme := u.Scheme index := strings.Index(scheme, "+") if index >= 0 { @@ -134,7 +134,7 @@ func (u URI) String() string { // Path returns URI with path func (u *URI) Path(path string) string { - return fmt.Sprintf("%s%s", u.Normalize(), path) + return fmt.Sprintf("%s%s", u.normalize(), path) } // The following methods are required to implement pflag Value interface. diff --git a/uri_internal_test.go b/uri_internal_test.go index 64db3fd8e..4d2500010 100644 --- a/uri_internal_test.go +++ b/uri_internal_test.go @@ -60,7 +60,7 @@ func TestNormalizedAddress(t *testing.T) { if err != nil { t.Fatalf("Can't parse address") } - if uri.Normalize() != "http://big-data.pilosa.com:6888" { + if uri.normalize() != "http://big-data.pilosa.com:6888" { t.Fatalf("Normalized address is not normal") } } From ac83bf44225e649fd89b0795b06908e5bee55fbe Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:55:38 -0500 Subject: [PATCH 053/138] Unexport URI.SetHost --- uri.go | 6 +++--- uri_internal_test.go | 4 ++-- utils_internal_test.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/uri.go b/uri.go index 605e5cb82..401ec1ad7 100644 --- a/uri.go +++ b/uri.go @@ -69,7 +69,7 @@ func (u URIs) HostPortStrings() []string { // NewURIFromHostPort returns a URI with specified host and port. func NewURIFromHostPort(host string, port uint16) (*URI, error) { uri := defaultURI() - err := uri.SetHost(host) + err := uri.setHost(host) if err != nil { return nil, errors.Wrap(err, "setting uri host") } @@ -92,8 +92,8 @@ func (u *URI) SetScheme(scheme string) error { return nil } -// SetHost sets the host of this URI. -func (u *URI) SetHost(host string) error { +// setHost sets the host of this URI. +func (u *URI) setHost(host string) error { m := hostRegexp.FindStringSubmatch(host) if m == nil { return errors.New("invalid host") diff --git a/uri_internal_test.go b/uri_internal_test.go index 4d2500010..07da55226 100644 --- a/uri_internal_test.go +++ b/uri_internal_test.go @@ -91,7 +91,7 @@ func TestSetScheme(t *testing.T) { func TestSetHost(t *testing.T) { uri := defaultURI() target := "10.20.30.40" - err := uri.SetHost(target) + err := uri.setHost(target) if err != nil { t.Fatal(err) } @@ -119,7 +119,7 @@ func TestSetInvalidScheme(t *testing.T) { func TestSetInvalidHost(t *testing.T) { uri := defaultURI() - err := uri.SetHost("index?.pilosa.com") + err := uri.setHost("index?.pilosa.com") if err == nil { t.Fatalf("Should have failed") } diff --git a/utils_internal_test.go b/utils_internal_test.go index 1f58c464c..88b1473c0 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -57,14 +57,14 @@ func NewTestCluster(n int) *cluster { func NewTestURI(scheme, host string, port uint16) URI { uri := defaultURI() uri.SetScheme(scheme) - uri.SetHost(host) + uri.setHost(host) uri.SetPort(port) return *uri } func NewTestURIFromHostPort(host string, port uint16) URI { uri := defaultURI() - uri.SetHost(host) + uri.setHost(host) uri.SetPort(port) return *uri } From 7807b92b133d61830563972f3bba4eabba9df8c5 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:55:45 -0500 Subject: [PATCH 054/138] Unexport URI.SetScheme --- uri.go | 4 ++-- uri_internal_test.go | 4 ++-- utils_internal_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/uri.go b/uri.go index 401ec1ad7..8f9df2b72 100644 --- a/uri.go +++ b/uri.go @@ -82,8 +82,8 @@ func NewURIFromAddress(address string) (*URI, error) { return parseAddress(address) } -// SetScheme sets the scheme of this URI. -func (u *URI) SetScheme(scheme string) error { +// setScheme sets the scheme of this URI. +func (u *URI) setScheme(scheme string) error { m := schemeRegexp.FindStringSubmatch(scheme) if m == nil { return errors.New("invalid scheme") diff --git a/uri_internal_test.go b/uri_internal_test.go index 07da55226..9bc6403d7 100644 --- a/uri_internal_test.go +++ b/uri_internal_test.go @@ -79,7 +79,7 @@ func TestURIPath(t *testing.T) { func TestSetScheme(t *testing.T) { uri := defaultURI() target := "fun" - err := uri.SetScheme(target) + err := uri.setScheme(target) if err != nil { t.Fatal(err) } @@ -111,7 +111,7 @@ func TestSetPort(t *testing.T) { func TestSetInvalidScheme(t *testing.T) { uri := defaultURI() - err := uri.SetScheme("?invalid") + err := uri.setScheme("?invalid") if err == nil { t.Fatalf("Should have failed") } diff --git a/utils_internal_test.go b/utils_internal_test.go index 88b1473c0..bf2c4f01f 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -56,7 +56,7 @@ func NewTestCluster(n int) *cluster { // NewTestURI is a test URI creator that intentionally swallows errors. func NewTestURI(scheme, host string, port uint16) URI { uri := defaultURI() - uri.SetScheme(scheme) + uri.setScheme(scheme) uri.setHost(host) uri.SetPort(port) return *uri From cd3eac00d2c85dcdc130e77c16623fcd74072bc5 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:04 -0500 Subject: [PATCH 055/138] Unexport ValCount.Add --- executor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executor.go b/executor.go index 03d18f936..4ca0c7e36 100644 --- a/executor.go +++ b/executor.go @@ -234,7 +234,7 @@ func (e *executor) executeSum(ctx context.Context, index string, c *pql.Call, sh // Merge returned results at coordinating node. reduceFn := func(prev, v interface{}) interface{} { other, _ := prev.(ValCount) - return other.Add(v.(ValCount)) + return other.add(v.(ValCount)) } result, err := e.mapReduce(ctx, index, shards, c, opt, mapFn, reduceFn) @@ -1713,7 +1713,7 @@ type ValCount struct { Count int64 `json:"count"` } -func (vc *ValCount) Add(other ValCount) ValCount { +func (vc *ValCount) add(other ValCount) ValCount { return ValCount{ Val: vc.Val + other.Val, Count: vc.Count + other.Count, From d7cebfa7c4a0c9914c84e9bf3ba3aceed8cee73a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:10 -0500 Subject: [PATCH 056/138] Unexport ValCount.Larger --- executor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/executor.go b/executor.go index 4ca0c7e36..5d8386e4c 100644 --- a/executor.go +++ b/executor.go @@ -300,7 +300,7 @@ func (e *executor) executeMax(ctx context.Context, index string, c *pql.Call, sh // Merge returned results at coordinating node. reduceFn := func(prev, v interface{}) interface{} { other, _ := prev.(ValCount) - return other.Larger(v.(ValCount)) + return other.larger(v.(ValCount)) } result, err := e.mapReduce(ctx, index, shards, c, opt, mapFn, reduceFn) @@ -1731,8 +1731,8 @@ func (vc *ValCount) Smaller(other ValCount) ValCount { } } -// Larger returns the larger of the two ValCounts. -func (vc *ValCount) Larger(other ValCount) ValCount { +// larger returns the larger of the two ValCounts. +func (vc *ValCount) larger(other ValCount) ValCount { if vc.Count == 0 || (other.Val > vc.Val && other.Count > 0) { return other } From ffde862679f7f07181a47aecfe2bb1e787a50861 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:16 -0500 Subject: [PATCH 057/138] Unexport ValCount.Smaller --- executor.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/executor.go b/executor.go index 5d8386e4c..afea60112 100644 --- a/executor.go +++ b/executor.go @@ -267,7 +267,7 @@ func (e *executor) executeMin(ctx context.Context, index string, c *pql.Call, sh // Merge returned results at coordinating node. reduceFn := func(prev, v interface{}) interface{} { other, _ := prev.(ValCount) - return other.Smaller(v.(ValCount)) + return other.smaller(v.(ValCount)) } result, err := e.mapReduce(ctx, index, shards, c, opt, mapFn, reduceFn) @@ -1720,8 +1720,8 @@ func (vc *ValCount) add(other ValCount) ValCount { } } -// Smaller returns the smaller of the two ValCounts. -func (vc *ValCount) Smaller(other ValCount) ValCount { +// smaller returns the smaller of the two ValCounts. +func (vc *ValCount) smaller(other ValCount) ValCount { if vc.Count == 0 || (other.Val < vc.Val && other.Count > 0) { return other } From d88f27552363ab9fb1a35346f5b0d165aedc1089 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:22 -0500 Subject: [PATCH 058/138] Unexport VerboseLogger --- logger.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/logger.go b/logger.go index 6afa24c96..28b35b999 100644 --- a/logger.go +++ b/logger.go @@ -64,25 +64,25 @@ func (s *standardLogger) Logger() *log.Logger { return s.logger } -// VerboseLogger is an implementation of pilosa.Logger which includes debug messages. -type VerboseLogger struct { +// verboseLogger is an implementation of pilosa.Logger which includes debug messages. +type verboseLogger struct { logger *log.Logger } -func NewVerboseLogger(w io.Writer) *VerboseLogger { - return &VerboseLogger{ +func NewVerboseLogger(w io.Writer) *verboseLogger { + return &verboseLogger{ logger: log.New(w, "", log.LstdFlags), } } -func (vb *VerboseLogger) Printf(format string, v ...interface{}) { +func (vb *verboseLogger) Printf(format string, v ...interface{}) { vb.logger.Printf(format, v...) } -func (vb *VerboseLogger) Debugf(format string, v ...interface{}) { +func (vb *verboseLogger) Debugf(format string, v ...interface{}) { vb.logger.Printf(format, v...) } -func (vb *VerboseLogger) Logger() *log.Logger { +func (vb *verboseLogger) Logger() *log.Logger { return vb.logger } From 817ede49e6421c92f3499f86690d04bfa3f0bec6 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:41 -0500 Subject: [PATCH 059/138] Unexport boltdb.AttrBlockSize --- boltdb/attrstore.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/boltdb/attrstore.go b/boltdb/attrstore.go index 3604de5b6..347fc74e4 100644 --- a/boltdb/attrstore.go +++ b/boltdb/attrstore.go @@ -30,8 +30,8 @@ import ( "github.com/pkg/errors" ) -// AttrBlockSize is the size of attribute blocks for anti-entropy. -const AttrBlockSize = 100 +// attrBlockSize is the size of attribute blocks for anti-entropy. +const attrBlockSize = 100 // AttrCache represents a cache for attributes. type AttrCache struct { @@ -228,7 +228,7 @@ func (s *AttrStore) Blocks() ([]pilosa.AttrBlock, error) { defer tx.Rollback() // Wrap cursor to segment by block. - cur := newBlockCursor(tx.Bucket([]byte("attrs")).Cursor(), AttrBlockSize) + cur := newBlockCursor(tx.Bucket([]byte("attrs")).Cursor(), attrBlockSize) // Iterate over each block. var blocks []pilosa.AttrBlock @@ -262,8 +262,8 @@ func (s *AttrStore) BlockData(i uint64) (map[uint64]map[string]interface{}, erro defer tx.Rollback() // Move to the start of the block. - min := u64tob(uint64(i) * AttrBlockSize) - max := u64tob(uint64(i+1) * AttrBlockSize) + min := u64tob(uint64(i) * attrBlockSize) + max := u64tob(uint64(i+1) * attrBlockSize) cur := tx.Bucket([]byte("attrs")).Cursor() for k, v := cur.Seek(min); k != nil; k, v = cur.Next() { // Exit if we're past the end of the block. From 43cac45d406410c01f9fd8409b6dd7eeccb19af0 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:46 -0500 Subject: [PATCH 060/138] Unexport boltdb.AttrCache --- boltdb/attrstore.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/boltdb/attrstore.go b/boltdb/attrstore.go index 347fc74e4..40d478f3a 100644 --- a/boltdb/attrstore.go +++ b/boltdb/attrstore.go @@ -33,14 +33,14 @@ import ( // attrBlockSize is the size of attribute blocks for anti-entropy. const attrBlockSize = 100 -// AttrCache represents a cache for attributes. -type AttrCache struct { +// attrCache represents a cache for attributes. +type attrCache struct { mu sync.RWMutex attrs map[uint64]map[string]interface{} } // Get returns the cached attributes for a given id. -func (c *AttrCache) Get(id uint64) map[string]interface{} { +func (c *attrCache) Get(id uint64) map[string]interface{} { c.mu.RLock() defer c.mu.RUnlock() attrs := c.attrs[id] @@ -57,7 +57,7 @@ func (c *AttrCache) Get(id uint64) map[string]interface{} { } // Set updates the cached attributes for a given id. -func (c *AttrCache) Set(id uint64, attrs map[string]interface{}) { +func (c *attrCache) Set(id uint64, attrs map[string]interface{}) { c.mu.Lock() defer c.mu.Unlock() c.attrs[id] = attrs @@ -68,12 +68,12 @@ type AttrStore struct { mu sync.RWMutex path string db *bolt.DB - attrCache *AttrCache + attrCache *attrCache } // NewAttrCache returns a new instance of AttrCache. -func NewAttrCache() *AttrCache { - return &AttrCache{ +func NewAttrCache() *attrCache { + return &attrCache{ attrs: make(map[uint64]map[string]interface{}), } } From fcf6517c7e15319a2ad0a398246e88cda5e69f16 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:51 -0500 Subject: [PATCH 061/138] Unexport boltdb.AttrStore --- boltdb/attrstore.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/boltdb/attrstore.go b/boltdb/attrstore.go index 40d478f3a..3849e0964 100644 --- a/boltdb/attrstore.go +++ b/boltdb/attrstore.go @@ -63,8 +63,8 @@ func (c *attrCache) Set(id uint64, attrs map[string]interface{}) { c.attrs[id] = attrs } -// AttrStore represents a storage layer for attributes. -type AttrStore struct { +// attrStore represents a storage layer for attributes. +type attrStore struct { mu sync.RWMutex path string db *bolt.DB @@ -80,17 +80,17 @@ func NewAttrCache() *attrCache { // NewAttrStore returns a new instance of AttrStore. func NewAttrStore(path string) pilosa.AttrStore { - return &AttrStore{ + return &attrStore{ path: path, attrCache: NewAttrCache(), } } // Path returns path to the store's data file. -func (s *AttrStore) Path() string { return s.path } +func (s *attrStore) Path() string { return s.path } // Open opens and initializes the store. -func (s *AttrStore) Open() error { +func (s *attrStore) Open() error { // Open storage. db, err := bolt.Open(s.path, 0666, &bolt.Options{Timeout: 1 * time.Second}) if err != nil { @@ -112,7 +112,7 @@ func (s *AttrStore) Open() error { } // Close closes the store. -func (s *AttrStore) Close() error { +func (s *attrStore) Close() error { if s.db != nil { s.db.Close() } @@ -120,7 +120,7 @@ func (s *AttrStore) Close() error { } // Attrs returns a set of attributes by ID. -func (s *AttrStore) Attrs(id uint64) (m map[string]interface{}, err error) { +func (s *attrStore) Attrs(id uint64) (m map[string]interface{}, err error) { s.mu.RLock() defer s.mu.RUnlock() @@ -147,7 +147,7 @@ func (s *AttrStore) Attrs(id uint64) (m map[string]interface{}, err error) { } // SetAttrs sets attribute values for a given ID. -func (s *AttrStore) SetAttrs(id uint64, m map[string]interface{}) error { +func (s *attrStore) SetAttrs(id uint64, m map[string]interface{}) error { // Ignore empty maps. if len(m) == 0 { return nil @@ -184,7 +184,7 @@ func (s *AttrStore) SetAttrs(id uint64, m map[string]interface{}) error { } // SetBulkAttrs sets attribute values for a set of ids. -func (s *AttrStore) SetBulkAttrs(m map[uint64]map[string]interface{}) error { +func (s *attrStore) SetBulkAttrs(m map[uint64]map[string]interface{}) error { s.mu.Lock() defer s.mu.Unlock() @@ -220,7 +220,7 @@ func (s *AttrStore) SetBulkAttrs(m map[uint64]map[string]interface{}) error { } // Blocks returns a list of all blocks in the store. -func (s *AttrStore) Blocks() ([]pilosa.AttrBlock, error) { +func (s *attrStore) Blocks() ([]pilosa.AttrBlock, error) { tx, err := s.db.Begin(false) if err != nil { return nil, errors.Wrap(err, "starting transaction") @@ -251,7 +251,7 @@ func (s *AttrStore) Blocks() ([]pilosa.AttrBlock, error) { } // BlockData returns all data for a single block. -func (s *AttrStore) BlockData(i uint64) (map[uint64]map[string]interface{}, error) { +func (s *attrStore) BlockData(i uint64) (map[uint64]map[string]interface{}, error) { m := make(map[uint64]map[string]interface{}) // Start read-only transaction. From 9db210927838c29993b722a08989231ffb7eab9f Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:56:57 -0500 Subject: [PATCH 062/138] Unexport boltdb.NewAttrCache --- boltdb/attrstore.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/boltdb/attrstore.go b/boltdb/attrstore.go index 3849e0964..1a9ddcf6e 100644 --- a/boltdb/attrstore.go +++ b/boltdb/attrstore.go @@ -71,8 +71,8 @@ type attrStore struct { attrCache *attrCache } -// NewAttrCache returns a new instance of AttrCache. -func NewAttrCache() *attrCache { +// newAttrCache returns a new instance of AttrCache. +func newAttrCache() *attrCache { return &attrCache{ attrs: make(map[uint64]map[string]interface{}), } @@ -82,7 +82,7 @@ func NewAttrCache() *attrCache { func NewAttrStore(path string) pilosa.AttrStore { return &attrStore{ path: path, - attrCache: NewAttrCache(), + attrCache: newAttrCache(), } } From 4c3600f1c4e1737d788b2a3f1f7fbe05b3512d68 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:03 -0500 Subject: [PATCH 063/138] Unexport cmd.Checker --- cmd/check.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/check.go b/cmd/check.go index 56ae13265..f4b53231a 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -25,10 +25,10 @@ import ( "github.com/pilosa/pilosa/ctl" ) -var Checker *ctl.CheckCommand +var checker *ctl.CheckCommand func NewCheckCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { - Checker = ctl.NewCheckCommand(os.Stdin, os.Stdout, os.Stderr) + checker = ctl.NewCheckCommand(os.Stdin, os.Stdout, os.Stderr) checkCmd := &cobra.Command{ Use: "check [path2]...", Short: "Do a consistency check on a pilosa data file.", @@ -39,8 +39,8 @@ Performs a consistency check on data files. if len(args) == 0 { return fmt.Errorf("path required") } - Checker.Paths = args - if err := Checker.Run(context.Background()); err != nil { + checker.Paths = args + if err := checker.Run(context.Background()); err != nil { return err } return nil From 618f6c8af45ec081f5ed5037749d299042ca1d11 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:10 -0500 Subject: [PATCH 064/138] Unexport cmd.Conf --- cmd/config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 9452cbc3c..953074f9c 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -25,10 +25,10 @@ import ( "github.com/pilosa/pilosa/server" ) -var Conf *ctl.ConfigCommand +var conf *ctl.ConfigCommand func NewConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { - Conf = ctl.NewConfigCommand(os.Stdin, os.Stdout, os.Stderr) + conf = ctl.NewConfigCommand(os.Stdin, os.Stdout, os.Stderr) Server := server.NewCommand(stdin, stdout, stderr) confCmd := &cobra.Command{ Use: "config", @@ -36,8 +36,8 @@ func NewConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command Long: `config prints the current configuration to stdout`, RunE: func(cmd *cobra.Command, args []string) error { - Conf.Config = Server.Config - if err := Conf.Run(context.Background()); err != nil { + conf.Config = Server.Config + if err := conf.Run(context.Background()); err != nil { return err } return nil From 35ae352599b65be45181b9901fe8e8d46dadd857 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:16 -0500 Subject: [PATCH 065/138] Unexport cmd.GenerateConf --- cmd/generate_config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/generate_config.go b/cmd/generate_config.go index b0622b64d..346d38b56 100644 --- a/cmd/generate_config.go +++ b/cmd/generate_config.go @@ -24,17 +24,17 @@ import ( "github.com/pilosa/pilosa/ctl" ) -var GenerateConf *ctl.GenerateConfigCommand +var generateConf *ctl.GenerateConfigCommand func NewGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { - GenerateConf = ctl.NewGenerateConfigCommand(os.Stdin, os.Stdout, os.Stderr) + generateConf = ctl.NewGenerateConfigCommand(os.Stdin, os.Stdout, os.Stderr) confCmd := &cobra.Command{ Use: "generate-config", Short: "Print the default configuration.", Long: `generate-config prints the default configuration to stdout `, RunE: func(cmd *cobra.Command, args []string) error { - if err := GenerateConf.Run(context.Background()); err != nil { + if err := generateConf.Run(context.Background()); err != nil { return err } return nil From 1d941efbb22dfc38b18bc55b14984f3f43e462f1 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:22 -0500 Subject: [PATCH 066/138] Unexport cmd.Inspector --- cmd/inspect.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/inspect.go b/cmd/inspect.go index e8526a414..08eacb441 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -25,10 +25,10 @@ import ( "github.com/pilosa/pilosa/ctl" ) -var Inspector *ctl.InspectCommand +var inspector *ctl.InspectCommand func NewInspectCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { - Inspector = ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr) + inspector = ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr) inspectCmd := &cobra.Command{ Use: "inspect", @@ -42,8 +42,8 @@ Inspects a data file and provides stats. } else if len(args) > 1 { return fmt.Errorf("only one path allowed") } - Inspector.Path = args[0] - if err := Inspector.Run(context.Background()); err != nil { + inspector.Path = args[0] + if err := inspector.Run(context.Background()); err != nil { return err } return nil From 004f1c7df105e737c79969772323bbff9ca2ce20 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:29 -0500 Subject: [PATCH 067/138] Unexport cmd.NewCheckCommand --- cmd/check.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/check.go b/cmd/check.go index f4b53231a..8785a78e1 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -27,7 +27,7 @@ import ( var checker *ctl.CheckCommand -func NewCheckCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { +func newCheckCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { checker = ctl.NewCheckCommand(os.Stdin, os.Stdout, os.Stderr) checkCmd := &cobra.Command{ Use: "check [path2]...", @@ -50,5 +50,5 @@ Performs a consistency check on data files. } func init() { - subcommandFns["check"] = NewCheckCommand + subcommandFns["check"] = newCheckCommand } From b42c24eaceb3cba6f80f4146af0ee33d79716e8f Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:35 -0500 Subject: [PATCH 068/138] Unexport cmd.NewConfigCommand --- cmd/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index 953074f9c..3d65fa131 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -27,7 +27,7 @@ import ( var conf *ctl.ConfigCommand -func NewConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { +func newConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { conf = ctl.NewConfigCommand(os.Stdin, os.Stdout, os.Stderr) Server := server.NewCommand(stdin, stdout, stderr) confCmd := &cobra.Command{ @@ -51,5 +51,5 @@ func NewConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command } func init() { - subcommandFns["config"] = NewConfigCommand + subcommandFns["config"] = newConfigCommand } From da4e3b0e140528b224efa3f3ff87f32ca1d03ceb Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:41 -0500 Subject: [PATCH 069/138] Unexport cmd.NewExportCommand --- cmd/export.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/export.go b/cmd/export.go index 9613d9544..d0f63edbf 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -26,7 +26,7 @@ import ( var Exporter *ctl.ExportCommand -func NewExportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { +func newExportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { Exporter = ctl.NewExportCommand(os.Stdin, os.Stdout, os.Stderr) exportCmd := &cobra.Command{ Use: "export", @@ -60,5 +60,5 @@ The file does not contain any headers. } func init() { - subcommandFns["export"] = NewExportCommand + subcommandFns["export"] = newExportCommand } From 4ec7a05524fc6cfabec824d69fcff200a06e36b1 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:48 -0500 Subject: [PATCH 070/138] Unexport cmd.NewGenerateConfigCommand --- cmd/generate_config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/generate_config.go b/cmd/generate_config.go index 346d38b56..0b5b81462 100644 --- a/cmd/generate_config.go +++ b/cmd/generate_config.go @@ -26,7 +26,7 @@ import ( var generateConf *ctl.GenerateConfigCommand -func NewGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { +func newGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { generateConf = ctl.NewGenerateConfigCommand(os.Stdin, os.Stdout, os.Stderr) confCmd := &cobra.Command{ Use: "generate-config", @@ -45,5 +45,5 @@ func NewGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra. } func init() { - subcommandFns["generate-config"] = NewGenerateConfigCommand + subcommandFns["generate-config"] = newGenerateConfigCommand } From c86758e998b5661925797463a5d367329bc79c57 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:57:54 -0500 Subject: [PATCH 071/138] Unexport cmd.NewImportCommand --- cmd/import.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/import.go b/cmd/import.go index 4d565adb7..7b4d00efd 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -25,8 +25,8 @@ import ( var Importer *ctl.ImportCommand -// NewImportCommand runs the Pilosa import subcommand for ingesting bulk data. -func NewImportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { +// newImportCommand runs the Pilosa import subcommand for ingesting bulk data. +func newImportCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { Importer = ctl.NewImportCommand(stdin, stdout, stderr) importCmd := &cobra.Command{ Use: "import", @@ -67,5 +67,5 @@ omitted. If it is present then its format should be YYYY-MM-DDTHH:MM. } func init() { - subcommandFns["import"] = NewImportCommand + subcommandFns["import"] = newImportCommand } From 18fd2e14c54da495a37b0c37e7ae702ae37fbe66 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:00 -0500 Subject: [PATCH 072/138] Unexport cmd.NewInspectCommand --- cmd/inspect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/inspect.go b/cmd/inspect.go index 08eacb441..096787337 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -27,7 +27,7 @@ import ( var inspector *ctl.InspectCommand -func NewInspectCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { +func newInspectCommand(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { inspector = ctl.NewInspectCommand(os.Stdin, os.Stdout, os.Stderr) inspectCmd := &cobra.Command{ @@ -53,5 +53,5 @@ Inspects a data file and provides stats. } func init() { - subcommandFns["inspect"] = NewInspectCommand + subcommandFns["inspect"] = newInspectCommand } From 73a7588e1b4bbf8b19d7d638683ee1e5df7b64f5 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:06 -0500 Subject: [PATCH 073/138] Unexport cmd.NewServeCmd --- cmd/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/server.go b/cmd/server.go index d906cf189..83d18504c 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -27,8 +27,8 @@ import ( // Server is global so that tests can control and verify it. var Server *server.Command -// NewServeCmd creates a pilosa server and runs it with command line flags. -func NewServeCmd(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { +// newServeCmd creates a pilosa server and runs it with command line flags. +func newServeCmd(stdin io.Reader, stdout, stderr io.Writer) *cobra.Command { Server = server.NewCommand(stdin, stdout, stderr) serveCmd := &cobra.Command{ Use: "server", @@ -52,5 +52,5 @@ on the configured port.`, } func init() { - subcommandFns["server"] = NewServeCmd + subcommandFns["server"] = newServeCmd } From 7185c0f79139e2a43d74b5e2af1ec94b7d1f71c4 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:12 -0500 Subject: [PATCH 074/138] Unexport ctl.CommandClient --- ctl/common.go | 4 ++-- ctl/export.go | 2 +- ctl/import.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ctl/common.go b/ctl/common.go index 44e01d406..f7f429c58 100644 --- a/ctl/common.go +++ b/ctl/common.go @@ -36,8 +36,8 @@ func SetTLSConfig(flags *pflag.FlagSet, certificatePath *string, certificateKeyP flags.BoolVarP(skipVerify, "tls.skip-verify", "", false, "Skip TLS certificate verification (not secure)") } -// CommandClient returns a pilosa.InternalHTTPClient for the command -func CommandClient(cmd CommandWithTLSSupport) (*http.InternalClient, error) { +// commandClient returns a pilosa.InternalHTTPClient for the command +func commandClient(cmd CommandWithTLSSupport) (*http.InternalClient, error) { tlsConfig := cmd.TLSConfiguration() var TLSConfig *tls.Config if tlsConfig.CertificatePath != "" && tlsConfig.CertificateKeyPath != "" { diff --git a/ctl/export.go b/ctl/export.go index 5bfbd529f..4a20b0cc2 100644 --- a/ctl/export.go +++ b/ctl/export.go @@ -75,7 +75,7 @@ func (cmd *ExportCommand) Run(ctx context.Context) error { } // Create a client to the server. - client, err := CommandClient(cmd) + client, err := commandClient(cmd) if err != nil { return errors.Wrap(err, "creating client") } diff --git a/ctl/import.go b/ctl/import.go index 370425115..83763f3ab 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -89,7 +89,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { return errors.New("path required") } // Create a client to the server. - client, err := CommandClient(cmd) + client, err := commandClient(cmd) if err != nil { return errors.Wrap(err, "creating client") } From f9a792ea49de1001f8d639efbe787d8dfca111d9 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:17 -0500 Subject: [PATCH 075/138] Unexport ctl.ImportCommand.IndexOptions --- ctl/import.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctl/import.go b/ctl/import.go index 83763f3ab..52d0c0c68 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -41,7 +41,7 @@ type ImportCommand struct { Field string `json:"field"` // Options for index & field to be created if they don't exist - IndexOptions pilosa.IndexOptions + indexOptions pilosa.IndexOptions // CreateSchema ensures the schema exists before import CreateSchema bool @@ -130,7 +130,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { } func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { - err := cmd.Client.EnsureIndex(ctx, cmd.Index, cmd.IndexOptions) + err := cmd.Client.EnsureIndex(ctx, cmd.Index, cmd.indexOptions) if err != nil { return fmt.Errorf("Error Creating Index: %s", err) } From eea29f664fc9ce9d7814c25d6079985460d64471 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:24 -0500 Subject: [PATCH 076/138] Unexport ctl.ImportCommand.Client --- ctl/import.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ctl/import.go b/ctl/import.go index 52d0c0c68..76b794a93 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -59,7 +59,7 @@ type ImportCommand struct { Sort bool `json:"sort"` // Reusable client. - Client pilosa.InternalClient `json:"-"` + client pilosa.InternalClient `json:"-"` // Standard input/output *pilosa.CmdIO @@ -93,7 +93,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { if err != nil { return errors.Wrap(err, "creating client") } - cmd.Client = client + cmd.client = client if cmd.CreateSchema { err := cmd.ensureSchema(ctx) @@ -104,7 +104,7 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { // Determine the field type in order to correctly handle the input data. fieldType := pilosa.DefaultFieldType - schema, err := cmd.Client.Schema(ctx) + schema, err := cmd.client.Schema(ctx) if err != nil { return errors.Wrap(err, "getting schema") } @@ -130,11 +130,11 @@ func (cmd *ImportCommand) Run(ctx context.Context) error { } func (cmd *ImportCommand) ensureSchema(ctx context.Context) error { - err := cmd.Client.EnsureIndex(ctx, cmd.Index, cmd.indexOptions) + err := cmd.client.EnsureIndex(ctx, cmd.Index, cmd.indexOptions) if err != nil { return fmt.Errorf("Error Creating Index: %s", err) } - err = cmd.Client.EnsureField(ctx, cmd.Index, cmd.Field) + err = cmd.client.EnsureField(ctx, cmd.Index, cmd.Field) if err != nil { return fmt.Errorf("Error Creating Field: %s", err) } @@ -254,7 +254,7 @@ func (cmd *ImportCommand) importBits(ctx context.Context, bits []pilosa.Bit) err } logger.Printf("importing shard: %d, n=%d", shard, len(chunk)) - if err := cmd.Client.Import(ctx, cmd.Index, cmd.Field, shard, chunk); err != nil { + if err := cmd.client.Import(ctx, cmd.Index, cmd.Field, shard, chunk); err != nil { return errors.Wrap(err, "importing") } } @@ -351,7 +351,7 @@ func (cmd *ImportCommand) importBitsK(ctx context.Context, bits []pilosa.Bit) er // TODO: does it help to sort the rowKeys? logger.Printf("importing keys: n=%d", len(bits)) - if err := cmd.Client.ImportK(ctx, cmd.Index, cmd.Field, bits); err != nil { + if err := cmd.client.ImportK(ctx, cmd.Index, cmd.Field, bits); err != nil { return errors.Wrap(err, "importing keys") } @@ -448,7 +448,7 @@ func (cmd *ImportCommand) importValues(ctx context.Context, vals []pilosa.FieldV } logger.Printf("importing shard: %d, n=%d", shard, len(vals)) - if err := cmd.Client.ImportValue(ctx, cmd.Index, cmd.Field, shard, vals); err != nil { + if err := cmd.client.ImportValue(ctx, cmd.Index, cmd.Field, shard, vals); err != nil { return errors.Wrap(err, "importing values") } } From dc97e34fb77da0d775b40b9d78f86b108c109959 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:30 -0500 Subject: [PATCH 077/138] Unexport proto.EncodeColumnAttrSet --- encoding/proto/proto.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index 0020260ab..e8ccabe5e 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -953,12 +953,12 @@ func decodeValCount(pb *internal.ValCount) pilosa.ValCount { func EncodeColumnAttrSets(a []*pilosa.ColumnAttrSet) []*internal.ColumnAttrSet { other := make([]*internal.ColumnAttrSet, len(a)) for i := range a { - other[i] = EncodeColumnAttrSet(a[i]) + other[i] = encodeColumnAttrSet(a[i]) } return other } -func EncodeColumnAttrSet(set *pilosa.ColumnAttrSet) *internal.ColumnAttrSet { +func encodeColumnAttrSet(set *pilosa.ColumnAttrSet) *internal.ColumnAttrSet { return &internal.ColumnAttrSet{ ID: set.ID, Attrs: encodeAttrs(set.Attrs), From 17a0bb62b79162b0e14ff81e98fda414b41d4664 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:37 -0500 Subject: [PATCH 078/138] Unexport proto.EncodeColumnAttrSets --- encoding/proto/proto.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index e8ccabe5e..cfa16e98d 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -337,7 +337,7 @@ func encodeQueryRequest(m *pilosa.QueryRequest) *internal.QueryRequest { func encodeQueryResponse(m *pilosa.QueryResponse) *internal.QueryResponse { pb := &internal.QueryResponse{ Results: make([]*internal.QueryResult, len(m.Results)), - ColumnAttrSets: EncodeColumnAttrSets(m.ColumnAttrSets), + ColumnAttrSets: encodeColumnAttrSets(m.ColumnAttrSets), } for i := range m.Results { @@ -950,7 +950,7 @@ func decodeValCount(pb *internal.ValCount) pilosa.ValCount { } } -func EncodeColumnAttrSets(a []*pilosa.ColumnAttrSet) []*internal.ColumnAttrSet { +func encodeColumnAttrSets(a []*pilosa.ColumnAttrSet) []*internal.ColumnAttrSet { other := make([]*internal.ColumnAttrSet, len(a)) for i := range a { other[i] = encodeColumnAttrSet(a[i]) From 052355014d3a4d2b63a46d9662e1d9d057065bb9 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:43 -0500 Subject: [PATCH 079/138] Unexport proto.EncodeNodes --- encoding/proto/proto.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index cfa16e98d..b0fe9d813 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -457,8 +457,8 @@ func encodeFieldOptions(o *pilosa.FieldOptions) *internal.FieldOptions { } } -// EncodeNodes converts a slice of Nodes into its internal representation. -func EncodeNodes(a []*pilosa.Node) []*internal.Node { +// encodeNodes converts a slice of Nodes into its internal representation. +func encodeNodes(a []*pilosa.Node) []*internal.Node { other := make([]*internal.Node, len(a)) for i := range a { other[i] = encodeNode(a[i]) @@ -487,7 +487,7 @@ func encodeClusterStatus(m *pilosa.ClusterStatus) *internal.ClusterStatus { return &internal.ClusterStatus{ State: m.State, ClusterID: m.ClusterID, - Nodes: EncodeNodes(m.Nodes), + Nodes: encodeNodes(m.Nodes), } } From bafc170420ccc0c59f52d69b48c1ff719b430844 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:48 -0500 Subject: [PATCH 080/138] Unexport proto.EncodePairs --- encoding/proto/proto.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index b0fe9d813..f6c1fd2d9 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -349,7 +349,7 @@ func encodeQueryResponse(m *pilosa.QueryResponse) *internal.QueryResponse { pb.Results[i].Row = EncodeRow(result) case []pilosa.Pair: pb.Results[i].Type = queryResultTypePairs - pb.Results[i].Pairs = EncodePairs(result) + pb.Results[i].Pairs = encodePairs(result) case pilosa.ValCount: pb.Results[i].Type = queryResultTypeValCount pb.Results[i].ValCount = EncodeValCount(result) @@ -976,7 +976,7 @@ func EncodeRow(r *pilosa.Row) *internal.Row { } } -func EncodePairs(a pilosa.Pairs) []*internal.Pair { +func encodePairs(a pilosa.Pairs) []*internal.Pair { other := make([]*internal.Pair, len(a)) for i := range a { other[i] = encodePair(a[i]) From b1d968f95e9748b585de720cdd74307f7c8d3312 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:54 -0500 Subject: [PATCH 081/138] Unexport proto.EncodeRow --- encoding/proto/proto.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index f6c1fd2d9..55983a702 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -346,7 +346,7 @@ func encodeQueryResponse(m *pilosa.QueryResponse) *internal.QueryResponse { switch result := m.Results[i].(type) { case *pilosa.Row: pb.Results[i].Type = queryResultTypeRow - pb.Results[i].Row = EncodeRow(result) + pb.Results[i].Row = encodeRow(result) case []pilosa.Pair: pb.Results[i].Type = queryResultTypePairs pb.Results[i].Pairs = encodePairs(result) @@ -965,7 +965,7 @@ func encodeColumnAttrSet(set *pilosa.ColumnAttrSet) *internal.ColumnAttrSet { } } -func EncodeRow(r *pilosa.Row) *internal.Row { +func encodeRow(r *pilosa.Row) *internal.Row { if r == nil { return nil } From c9497ec612aa5ea2a3465eac045acf4aa820299a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:58:59 -0500 Subject: [PATCH 082/138] Unexport proto.EncodeValCount --- encoding/proto/proto.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index 55983a702..d8367c468 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -352,7 +352,7 @@ func encodeQueryResponse(m *pilosa.QueryResponse) *internal.QueryResponse { pb.Results[i].Pairs = encodePairs(result) case pilosa.ValCount: pb.Results[i].Type = queryResultTypeValCount - pb.Results[i].ValCount = EncodeValCount(result) + pb.Results[i].ValCount = encodeValCount(result) case uint64: pb.Results[i].Type = queryResultTypeUint64 pb.Results[i].N = result @@ -992,7 +992,7 @@ func encodePair(p pilosa.Pair) *internal.Pair { } } -func EncodeValCount(vc pilosa.ValCount) *internal.ValCount { +func encodeValCount(vc pilosa.ValCount) *internal.ValCount { return &internal.ValCount{ Val: vc.Val, Count: vc.Count, From 446bfff91a5d74119fcc95d01accf05a136cf874 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:18 -0500 Subject: [PATCH 083/138] Unexport b.BTreeContainers --- enterprise/b/containers_btree.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/enterprise/b/containers_btree.go b/enterprise/b/containers_btree.go index 71727700f..443cb71d9 100644 --- a/enterprise/b/containers_btree.go +++ b/enterprise/b/containers_btree.go @@ -27,15 +27,15 @@ func cmp(a, b uint64) int { return int(a - b) } -type BTreeContainers struct { +type bTreeContainers struct { tree *Tree lastKey uint64 lastContainer *roaring.Container } -func NewBTreeContainers() *BTreeContainers { - return &BTreeContainers{ +func NewBTreeContainers() *bTreeContainers { + return &bTreeContainers{ tree: TreeNew(cmp), } } @@ -48,7 +48,7 @@ func NewBTreeBitmap(a ...uint64) *roaring.Bitmap { return b } -func (btc *BTreeContainers) Get(key uint64) *roaring.Container { +func (btc *bTreeContainers) Get(key uint64) *roaring.Container { // Check the last* cache for same container. if key == btc.lastKey && btc.lastContainer != nil { return btc.lastContainer @@ -64,7 +64,7 @@ func (btc *BTreeContainers) Get(key uint64) *roaring.Container { return c } -func (btc *BTreeContainers) Put(key uint64, c *roaring.Container) { +func (btc *bTreeContainers) Put(key uint64, c *roaring.Container) { // If a mapped container is added to the tree, reset the // lastContainer cache so that the cache is not pointing // at a read-only mmap. @@ -93,16 +93,16 @@ type updater struct { mapped bool } -func (btc *BTreeContainers) PutContainerValues(key uint64, containerType byte, n int, mapped bool) { +func (btc *bTreeContainers) PutContainerValues(key uint64, containerType byte, n int, mapped bool) { a := updater{key, containerType, n, mapped} btc.tree.Put(key, a.update) } -func (btc *BTreeContainers) Remove(key uint64) { +func (btc *bTreeContainers) Remove(key uint64) { btc.tree.Delete(key) } -func (btc *BTreeContainers) GetOrCreate(key uint64) *roaring.Container { +func (btc *bTreeContainers) GetOrCreate(key uint64) *roaring.Container { // Check the last* cache for same container. if key == btc.lastKey && btc.lastContainer != nil { return btc.lastContainer @@ -121,7 +121,7 @@ func (btc *BTreeContainers) GetOrCreate(key uint64) *roaring.Container { return btc.lastContainer } -func (btc *BTreeContainers) Count() (n uint64) { +func (btc *bTreeContainers) Count() (n uint64) { e, _ := btc.tree.Seek(0) _, c, err := e.Next() for err != io.EOF { @@ -131,7 +131,7 @@ func (btc *BTreeContainers) Count() (n uint64) { return } -func (btc *BTreeContainers) Clone() roaring.Containers { +func (btc *bTreeContainers) Clone() roaring.Containers { nbtc := NewBTreeContainers() itr, err := btc.tree.SeekFirst() @@ -148,7 +148,7 @@ func (btc *BTreeContainers) Clone() roaring.Containers { return nbtc } -func (btc *BTreeContainers) Last() (key uint64, c *roaring.Container) { +func (btc *bTreeContainers) Last() (key uint64, c *roaring.Container) { if btc.tree.Len() == 0 { return 0, nil } @@ -156,17 +156,17 @@ func (btc *BTreeContainers) Last() (key uint64, c *roaring.Container) { return k, v } -func (btc *BTreeContainers) Size() int { +func (btc *bTreeContainers) Size() int { return btc.tree.Len() } -func (btc *BTreeContainers) Reset() { +func (btc *bTreeContainers) Reset() { btc.tree = TreeNew(cmp) btc.lastKey = 0 btc.lastContainer = nil } -func (btc *BTreeContainers) Iterator(key uint64) (citer roaring.ContainerIterator, found bool) { +func (btc *bTreeContainers) Iterator(key uint64) (citer roaring.ContainerIterator, found bool) { e, ok := btc.tree.Seek(key) if ok { found = true From eac1bec54b356e8600e31f4d045b909c511584b7 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:20 -0500 Subject: [PATCH 084/138] Unexport b.Enumerator --- enterprise/b/btree.go | 32 ++++++++++++++++---------------- enterprise/b/containers_btree.go | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/enterprise/b/btree.go b/enterprise/b/btree.go index 3d4c09888..8d853083c 100644 --- a/enterprise/b/btree.go +++ b/enterprise/b/btree.go @@ -56,7 +56,7 @@ func init() { var ( btDPool = sync.Pool{New: func() interface{} { return &d{} }} - btEPool = btEpool{sync.Pool{New: func() interface{} { return &Enumerator{} }}} + btEPool = btEpool{sync.Pool{New: func() interface{} { return &enumerator{} }}} btTPool = btTpool{sync.Pool{New: func() interface{} { return &Tree{} }}} btXPool = sync.Pool{New: func() interface{} { return &x{} }} ) @@ -71,8 +71,8 @@ func (p *btTpool) get(cmp Cmp) *Tree { type btEpool struct{ sync.Pool } -func (p *btEpool) get(err error, hit bool, i int, k uint64, q *d, t *Tree, ver int64) *Enumerator { - x := p.Get().(*Enumerator) +func (p *btEpool) get(err error, hit bool, i int, k uint64, q *d, t *Tree, ver int64) *enumerator { + x := p.Get().(*enumerator) x.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver return x } @@ -98,15 +98,15 @@ type ( v *roaring.Container } - // Enumerator captures the state of enumerating a tree. It is returned + // enumerator captures the state of enumerating a tree. It is returned // from the Seek* methods. The enumerator is aware of any mutations // made to the tree in the process of enumerating it and automatically // resumes the enumeration at the proper key, if possible. // - // However, once an Enumerator returns io.EOF to signal "no more + // However, once an enumerator returns io.EOF to signal "no more // items", it does no more attempt to "resync" on tree mutation(s). In - // other words, io.EOF from an Enumerator is "sticky" (idempotent). - Enumerator struct { + // other words, io.EOF from an enumerator is "sticky" (idempotent). + enumerator struct { err error hit bool i int @@ -140,7 +140,7 @@ type ( var ( // R/O zero values zd d zde de - ze Enumerator + ze enumerator zk uint64 zt Tree zx x @@ -528,7 +528,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k uint64, v *roaring.Container) { // Seek returns an Enumerator positioned on an item such that k >= item's key. // ok reports if k == item.key The Enumerator's position is possibly after the // last item in the tree. -func (t *Tree) Seek(k uint64) (e *Enumerator, ok bool) { +func (t *Tree) Seek(k uint64) (e *enumerator, ok bool) { q := t.r if q == nil { e = btEPool.get(nil, false, 0, k, nil, t, t.ver) @@ -558,7 +558,7 @@ func (t *Tree) Seek(k uint64) (e *Enumerator, ok bool) { // SeekFirst returns an enumerator positioned on the first KV pair in the tree, // if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekFirst() (e *Enumerator, err error) { +func (t *Tree) SeekFirst() (e *enumerator, err error) { q := t.first if q == nil { return nil, io.EOF @@ -569,7 +569,7 @@ func (t *Tree) SeekFirst() (e *Enumerator, err error) { // SeekLast returns an enumerator positioned on the last KV pair in the tree, // if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekLast() (e *Enumerator, err error) { +func (t *Tree) SeekLast() (e *enumerator, err error) { q := t.last if q == nil { return nil, io.EOF @@ -850,7 +850,7 @@ func (t *Tree) underflowX(p *x, q *x, pi int, i int) (*x, int) { // Close recycles e to a pool for possible later reuse. No references to e // should exist or such references must not be used afterwards. -func (e *Enumerator) Close() { +func (e *enumerator) Close() { *e = ze btEPool.Put(e) } @@ -858,7 +858,7 @@ func (e *Enumerator) Close() { // Next returns the currently enumerated item, if it exists and moves to the // next item in the key collation order. If there is no item to return, err == // io.EOF is returned. -func (e *Enumerator) Next() (k uint64, v *roaring.Container, err error) { +func (e *enumerator) Next() (k uint64, v *roaring.Container, err error) { if err = e.err; err != nil { return } @@ -886,7 +886,7 @@ func (e *Enumerator) Next() (k uint64, v *roaring.Container, err error) { return } -func (e *Enumerator) next() error { +func (e *enumerator) next() error { if e.q == nil { e.err = io.EOF return io.EOF @@ -906,7 +906,7 @@ func (e *Enumerator) next() error { // Prev returns the currently enumerated item, if it exists and moves to the // previous item in the key collation order. If there is no item to return, err // == io.EOF is returned. -func (e *Enumerator) Prev() (k uint64, v *roaring.Container, err error) { +func (e *enumerator) Prev() (k uint64, v *roaring.Container, err error) { if err = e.err; err != nil { return } @@ -941,7 +941,7 @@ func (e *Enumerator) Prev() (k uint64, v *roaring.Container, err error) { return } -func (e *Enumerator) prev() error { +func (e *enumerator) prev() error { if e.q == nil { e.err = io.EOF return io.EOF diff --git a/enterprise/b/containers_btree.go b/enterprise/b/containers_btree.go index 443cb71d9..4c8527c8b 100644 --- a/enterprise/b/containers_btree.go +++ b/enterprise/b/containers_btree.go @@ -178,7 +178,7 @@ func (btc *bTreeContainers) Iterator(key uint64) (citer roaring.ContainerIterato } type btcIterator struct { - e *Enumerator + e *enumerator key uint64 val *roaring.Container } From fede4ac9f0af1a1c060b9847ac3fecc7cf46062a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:22 -0500 Subject: [PATCH 085/138] Unexport b.NewBTreeContainers --- enterprise/b/containers_btree.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/enterprise/b/containers_btree.go b/enterprise/b/containers_btree.go index 4c8527c8b..a61c862e6 100644 --- a/enterprise/b/containers_btree.go +++ b/enterprise/b/containers_btree.go @@ -34,7 +34,7 @@ type bTreeContainers struct { lastContainer *roaring.Container } -func NewBTreeContainers() *bTreeContainers { +func newBTreeContainers() *bTreeContainers { return &bTreeContainers{ tree: TreeNew(cmp), } @@ -42,7 +42,7 @@ func NewBTreeContainers() *bTreeContainers { func NewBTreeBitmap(a ...uint64) *roaring.Bitmap { b := &roaring.Bitmap{ - Containers: NewBTreeContainers(), + Containers: newBTreeContainers(), } b.Add(a...) return b @@ -132,7 +132,7 @@ func (btc *bTreeContainers) Count() (n uint64) { } func (btc *bTreeContainers) Clone() roaring.Containers { - nbtc := NewBTreeContainers() + nbtc := newBTreeContainers() itr, err := btc.tree.SeekFirst() if err == io.EOF { From 9a1f348580a6c7ce57b993c82a0b777c8d847f2e Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:24 -0500 Subject: [PATCH 086/138] Unexport b.Tree --- enterprise/b/btree.go | 62 ++++++++++++++++---------------- enterprise/b/containers_btree.go | 2 +- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/enterprise/b/btree.go b/enterprise/b/btree.go index 8d853083c..5ae5a7eb3 100644 --- a/enterprise/b/btree.go +++ b/enterprise/b/btree.go @@ -57,21 +57,21 @@ func init() { var ( btDPool = sync.Pool{New: func() interface{} { return &d{} }} btEPool = btEpool{sync.Pool{New: func() interface{} { return &enumerator{} }}} - btTPool = btTpool{sync.Pool{New: func() interface{} { return &Tree{} }}} + btTPool = btTpool{sync.Pool{New: func() interface{} { return &tree{} }}} btXPool = sync.Pool{New: func() interface{} { return &x{} }} ) type btTpool struct{ sync.Pool } -func (p *btTpool) get(cmp Cmp) *Tree { - x := p.Get().(*Tree) +func (p *btTpool) get(cmp Cmp) *tree { + x := p.Get().(*tree) x.cmp = cmp return x } type btEpool struct{ sync.Pool } -func (p *btEpool) get(err error, hit bool, i int, k uint64, q *d, t *Tree, ver int64) *enumerator { +func (p *btEpool) get(err error, hit bool, i int, k uint64, q *d, t *tree, ver int64) *enumerator { x := p.Get().(*enumerator) x.err, x.hit, x.i, x.k, x.q, x.t, x.ver = err, hit, i, k, q, t, ver return x @@ -112,12 +112,12 @@ type ( i int k uint64 q *d - t *Tree + t *tree ver int64 } - // Tree is a B+tree. - Tree struct { + // tree is a B+tree. + tree struct { c int cmp Cmp first *d @@ -142,7 +142,7 @@ var ( // R/O zero values zde de ze enumerator zk uint64 - zt Tree + zt tree zx x zxe xe ) @@ -235,12 +235,12 @@ func (l *d) mvR(r *d, c int) { // TreeNew returns a newly created, empty Tree. The compare function is used // for key collation. -func TreeNew(cmp Cmp) *Tree { +func TreeNew(cmp Cmp) *tree { return btTPool.get(cmp) } // Clear removes all K/V pairs from the tree. -func (t *Tree) Clear() { +func (t *tree) Clear() { if t.r == nil { return } @@ -252,13 +252,13 @@ func (t *Tree) Clear() { // Close performs Clear and recycles t to a pool for possible later reuse. No // references to t should exist or such references must not be used afterwards. -func (t *Tree) Close() { +func (t *tree) Close() { t.Clear() *t = zt btTPool.Put(t) } -func (t *Tree) cat(p *x, q, r *d, pi int) { +func (t *tree) cat(p *x, q, r *d, pi int) { t.ver++ q.mvL(r, r.c) if r.n != nil { @@ -286,7 +286,7 @@ func (t *Tree) cat(p *x, q, r *d, pi int) { t.r = q } -func (t *Tree) catX(p, q, r *x, pi int) { +func (t *tree) catX(p, q, r *x, pi int) { t.ver++ q.x[q.c].k = p.x[pi].k copy(q.x[q.c+1:], r.x[:r.c]) @@ -320,7 +320,7 @@ func (t *Tree) catX(p, q, r *x, pi int) { // Delete removes the k's KV pair, if it exists, in which case Delete returns // true. -func (t *Tree) Delete(k uint64) (ok bool) { +func (t *tree) Delete(k uint64) (ok bool) { pi := -1 var p *x q := t.r @@ -370,7 +370,7 @@ func (t *Tree) Delete(k uint64) (ok bool) { } } -func (t *Tree) extract(q *d, i int) { // (r *container) { +func (t *tree) extract(q *d, i int) { // (r *container) { t.ver++ //r = q.d[i].v // prepared for Extract q.c-- @@ -381,7 +381,7 @@ func (t *Tree) extract(q *d, i int) { // (r *container) { t.c-- } -func (t *Tree) find(q interface{}, k uint64) (i int, ok bool) { +func (t *tree) find(q interface{}, k uint64) (i int, ok bool) { var mk uint64 l := 0 switch x := q.(type) { @@ -419,7 +419,7 @@ func (t *Tree) find(q interface{}, k uint64) (i int, ok bool) { // First returns the first item of the tree in the key collating order, or // (zero-value, zero-value) if the tree is empty. -func (t *Tree) First() (k uint64, v *roaring.Container) { +func (t *tree) First() (k uint64, v *roaring.Container) { if q := t.first; q != nil { q := &q.d[0] k, v = q.k, q.v @@ -429,7 +429,7 @@ func (t *Tree) First() (k uint64, v *roaring.Container) { // Get returns the value associated with k and true if it exists. Otherwise Get // returns (zero-value, false). -func (t *Tree) Get(k uint64) (v *roaring.Container, ok bool) { +func (t *tree) Get(k uint64) (v *roaring.Container, ok bool) { q := t.r if q == nil { return @@ -455,7 +455,7 @@ func (t *Tree) Get(k uint64) (v *roaring.Container, ok bool) { } } -func (t *Tree) insert(q *d, i int, k uint64, v *roaring.Container) *d { +func (t *tree) insert(q *d, i int, k uint64, v *roaring.Container) *d { t.ver++ c := q.c if i < c { @@ -470,7 +470,7 @@ func (t *Tree) insert(q *d, i int, k uint64, v *roaring.Container) *d { // Last returns the last item of the tree in the key collating order, or // (zero-value, zero-value) if the tree is empty. -func (t *Tree) Last() (k uint64, v *roaring.Container) { +func (t *tree) Last() (k uint64, v *roaring.Container) { if q := t.last; q != nil { q := &q.d[q.c-1] k, v = q.k, q.v @@ -479,11 +479,11 @@ func (t *Tree) Last() (k uint64, v *roaring.Container) { } // Len returns the number of items in the tree. -func (t *Tree) Len() int { +func (t *tree) Len() int { return t.c } -func (t *Tree) overflow(p *x, q *d, pi, i int, k uint64, v *roaring.Container) { +func (t *tree) overflow(p *x, q *d, pi, i int, k uint64, v *roaring.Container) { t.ver++ l, r := p.siblings(pi) @@ -528,7 +528,7 @@ func (t *Tree) overflow(p *x, q *d, pi, i int, k uint64, v *roaring.Container) { // Seek returns an Enumerator positioned on an item such that k >= item's key. // ok reports if k == item.key The Enumerator's position is possibly after the // last item in the tree. -func (t *Tree) Seek(k uint64) (e *enumerator, ok bool) { +func (t *tree) Seek(k uint64) (e *enumerator, ok bool) { q := t.r if q == nil { e = btEPool.get(nil, false, 0, k, nil, t, t.ver) @@ -558,7 +558,7 @@ func (t *Tree) Seek(k uint64) (e *enumerator, ok bool) { // SeekFirst returns an enumerator positioned on the first KV pair in the tree, // if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekFirst() (e *enumerator, err error) { +func (t *tree) SeekFirst() (e *enumerator, err error) { q := t.first if q == nil { return nil, io.EOF @@ -569,7 +569,7 @@ func (t *Tree) SeekFirst() (e *enumerator, err error) { // SeekLast returns an enumerator positioned on the last KV pair in the tree, // if any. For an empty tree, err == io.EOF is returned and e will be nil. -func (t *Tree) SeekLast() (e *enumerator, err error) { +func (t *tree) SeekLast() (e *enumerator, err error) { q := t.last if q == nil { return nil, io.EOF @@ -579,7 +579,7 @@ func (t *Tree) SeekLast() (e *enumerator, err error) { } // Set sets the value associated with k. -func (t *Tree) Set(k uint64, v *roaring.Container) { +func (t *tree) Set(k uint64, v *roaring.Container) { //dbg("--- PRE Set(%v, %v)\n%s", k, v, t.dump()) //defer func() { // dbg("--- POST\n%s\n====\n", t.dump()) @@ -645,7 +645,7 @@ func (t *Tree) Set(k uint64, v *roaring.Container) { // tree.Put(k, func(uint64, bool){ return v, true }) // // modulo the differing return values. -func (t *Tree) Put(k uint64, upd func(oldV *roaring.Container, exists bool) (newV *roaring.Container, write bool)) (oldV *roaring.Container, written bool) { +func (t *tree) Put(k uint64, upd func(oldV *roaring.Container, exists bool) (newV *roaring.Container, write bool)) (oldV *roaring.Container, written bool) { pi := -1 var p *x q := t.r @@ -712,7 +712,7 @@ func (t *Tree) Put(k uint64, upd func(oldV *roaring.Container, exists bool) (new } } -func (t *Tree) split(p *x, q *d, pi, i int, k uint64, v *roaring.Container) { +func (t *tree) split(p *x, q *d, pi, i int, k uint64, v *roaring.Container) { t.ver++ r := btDPool.Get().(*d) if q.n != nil { @@ -747,7 +747,7 @@ func (t *Tree) split(p *x, q *d, pi, i int, k uint64, v *roaring.Container) { t.insert(q, i, k, v) } -func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) { +func (t *tree) splitX(p *x, q *x, pi int, i int) (*x, int) { t.ver++ r := btXPool.Get().(*x) copy(r.x[:], q.x[kx+1:]) @@ -771,7 +771,7 @@ func (t *Tree) splitX(p *x, q *x, pi int, i int) (*x, int) { return q, i } -func (t *Tree) underflow(p *x, q *d, pi int) { +func (t *tree) underflow(p *x, q *d, pi int) { t.ver++ l, r := p.siblings(pi) @@ -796,7 +796,7 @@ func (t *Tree) underflow(p *x, q *d, pi int) { t.cat(p, q, r, pi) } -func (t *Tree) underflowX(p *x, q *x, pi int, i int) (*x, int) { +func (t *tree) underflowX(p *x, q *x, pi int, i int) (*x, int) { t.ver++ var l, r *x diff --git a/enterprise/b/containers_btree.go b/enterprise/b/containers_btree.go index a61c862e6..02564dcc8 100644 --- a/enterprise/b/containers_btree.go +++ b/enterprise/b/containers_btree.go @@ -28,7 +28,7 @@ func cmp(a, b uint64) int { } type bTreeContainers struct { - tree *Tree + tree *tree lastKey uint64 lastContainer *roaring.Container From 6fbd373256a70c60c0c29d174be935d7f4e7b206 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:25 -0500 Subject: [PATCH 087/138] Unexport b.TreeNew --- enterprise/b/btree.go | 4 ++-- enterprise/b/containers_btree.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/enterprise/b/btree.go b/enterprise/b/btree.go index 5ae5a7eb3..044411bd7 100644 --- a/enterprise/b/btree.go +++ b/enterprise/b/btree.go @@ -233,9 +233,9 @@ func (l *d) mvR(r *d, c int) { // ----------------------------------------------------------------------- Tree -// TreeNew returns a newly created, empty Tree. The compare function is used +// treeNew returns a newly created, empty Tree. The compare function is used // for key collation. -func TreeNew(cmp Cmp) *tree { +func treeNew(cmp Cmp) *tree { return btTPool.get(cmp) } diff --git a/enterprise/b/containers_btree.go b/enterprise/b/containers_btree.go index 02564dcc8..95fcb09b3 100644 --- a/enterprise/b/containers_btree.go +++ b/enterprise/b/containers_btree.go @@ -36,7 +36,7 @@ type bTreeContainers struct { func newBTreeContainers() *bTreeContainers { return &bTreeContainers{ - tree: TreeNew(cmp), + tree: treeNew(cmp), } } @@ -161,7 +161,7 @@ func (btc *bTreeContainers) Size() int { } func (btc *bTreeContainers) Reset() { - btc.tree = TreeNew(cmp) + btc.tree = treeNew(cmp) btc.lastKey = 0 btc.lastContainer = nil } From 7db07ea72e889c6558bc866d5bba4368415f155f Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:30 -0500 Subject: [PATCH 088/138] Unexport gcnotify.ActiveGCNotifier --- gcnotify/gcnotify.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcnotify/gcnotify.go b/gcnotify/gcnotify.go index 76953a378..54313403d 100644 --- a/gcnotify/gcnotify.go +++ b/gcnotify/gcnotify.go @@ -20,25 +20,25 @@ import ( ) // Ensure ActiveGCNotifier implements interface. -var _ pilosa.GCNotifier = &ActiveGCNotifier{} +var _ pilosa.GCNotifier = &activeGCNotifier{} -type ActiveGCNotifier struct { +type activeGCNotifier struct { gcn *gcnotifier.GCNotifier } // NewActiveGCNotifier creates an active GCNotifier. -func NewActiveGCNotifier() *ActiveGCNotifier { - return &ActiveGCNotifier{ +func NewActiveGCNotifier() *activeGCNotifier { + return &activeGCNotifier{ gcn: gcnotifier.New(), } } // Close implements the GCNotifier interface. -func (n *ActiveGCNotifier) Close() { +func (n *activeGCNotifier) Close() { n.gcn.Close() } // AfterGC implements the GCNotifier interface. -func (n *ActiveGCNotifier) AfterGC() <-chan struct{} { +func (n *activeGCNotifier) AfterGC() <-chan struct{} { return n.gcn.AfterGC() } From 6c53ecc333d69f327d2700d2915843999e811786 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:36 -0500 Subject: [PATCH 089/138] Unexport gopsutil.SystemInfo --- gopsutil/systeminfo.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gopsutil/systeminfo.go b/gopsutil/systeminfo.go index 3310aeae1..8cdd77778 100644 --- a/gopsutil/systeminfo.go +++ b/gopsutil/systeminfo.go @@ -22,15 +22,15 @@ import ( var _ pilosa.SystemInfo = NewSystemInfo() -// SystemInfo is an implementation of pilosa.SystemInfo that uses gopsutil to collect information about the host OS. -type SystemInfo struct { +// systemInfo is an implementation of pilosa.systemInfo that uses gopsutil to collect information about the host OS. +type systemInfo struct { platform string family string osVersion string } // Uptime returns the system uptime in seconds. -func (s *SystemInfo) Uptime() (uptime uint64, err error) { +func (s *systemInfo) Uptime() (uptime uint64, err error) { hostInfo, err := host.Info() if err != nil { return 0, err @@ -39,7 +39,7 @@ func (s *SystemInfo) Uptime() (uptime uint64, err error) { } // collectPlatformInfo fetches and caches system platform information. -func (s *SystemInfo) collectPlatformInfo() error { +func (s *systemInfo) collectPlatformInfo() error { var err error if s.platform == "" { s.platform, s.family, s.osVersion, err = host.PlatformInformation() @@ -51,7 +51,7 @@ func (s *SystemInfo) collectPlatformInfo() error { } // Platform returns the system platform. -func (s *SystemInfo) Platform() (string, error) { +func (s *systemInfo) Platform() (string, error) { err := s.collectPlatformInfo() if err != nil { return "", err @@ -60,7 +60,7 @@ func (s *SystemInfo) Platform() (string, error) { } // Family returns the system family. -func (s *SystemInfo) Family() (string, error) { +func (s *systemInfo) Family() (string, error) { err := s.collectPlatformInfo() if err != nil { return "", err @@ -69,7 +69,7 @@ func (s *SystemInfo) Family() (string, error) { } // OSVersion returns the OS Version. -func (s *SystemInfo) OSVersion() (string, error) { +func (s *systemInfo) OSVersion() (string, error) { err := s.collectPlatformInfo() if err != nil { return "", err @@ -78,7 +78,7 @@ func (s *SystemInfo) OSVersion() (string, error) { } // MemFree returns the amount of free memory in bytes. -func (s *SystemInfo) MemFree() (uint64, error) { +func (s *systemInfo) MemFree() (uint64, error) { memInfo, err := mem.VirtualMemory() if err != nil { return 0, err @@ -87,7 +87,7 @@ func (s *SystemInfo) MemFree() (uint64, error) { } // MemTotal returns the amount of total memory in bytes. -func (s *SystemInfo) MemTotal() (uint64, error) { +func (s *systemInfo) MemTotal() (uint64, error) { memInfo, err := mem.VirtualMemory() if err != nil { return 0, err @@ -96,7 +96,7 @@ func (s *SystemInfo) MemTotal() (uint64, error) { } // MemUsed returns the amount of used memory in bytes. -func (s *SystemInfo) MemUsed() (uint64, error) { +func (s *systemInfo) MemUsed() (uint64, error) { memInfo, err := mem.VirtualMemory() if err != nil { return 0, err @@ -105,11 +105,11 @@ func (s *SystemInfo) MemUsed() (uint64, error) { } // KernelVersion returns the kernel version as a string. -func (s *SystemInfo) KernelVersion() (string, error) { +func (s *systemInfo) KernelVersion() (string, error) { return host.KernelVersion() } // NewSystemInfo is a constructor for the gopsutil implementation of SystemInfo. -func NewSystemInfo() *SystemInfo { - return &SystemInfo{} +func NewSystemInfo() *systemInfo { + return &systemInfo{} } From 6bc7470b0cba6c8cfb738468e7151e0d1540bb56 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:41 -0500 Subject: [PATCH 090/138] Unexport gossip.GossipMemberSet --- gossip/gossip.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/gossip/gossip.go b/gossip/gossip.go index 849b33d01..289eb505d 100644 --- a/gossip/gossip.go +++ b/gossip/gossip.go @@ -33,10 +33,10 @@ import ( ) // Ensure GossipMemberSet implements interfaces. -var _ memberlist.Delegate = &GossipMemberSet{} +var _ memberlist.Delegate = &gossipMemberSet{} -// GossipMemberSet represents a gossip implementation of MemberSet using memberlist. -type GossipMemberSet struct { +// gossipMemberSet represents a gossip implementation of MemberSet using memberlist. +type gossipMemberSet struct { mu sync.RWMutex memberlist *memberlist.Memberlist @@ -54,7 +54,7 @@ type GossipMemberSet struct { } // Open implements the MemberSet interface to start network activity. -func (g *GossipMemberSet) Open() (err error) { +func (g *gossipMemberSet) Open() (err error) { g.mu.Lock() g.memberlist, err = memberlist.Create(g.config.memberlistConfig) g.mu.Unlock() @@ -94,7 +94,7 @@ func (g *GossipMemberSet) Open() (err error) { } // joinWithRetry wraps the standard memberlist Join function in a retry. -func (g *GossipMemberSet) joinWithRetry(hosts []string) error { +func (g *gossipMemberSet) joinWithRetry(hosts []string) error { err := retry(60, 2*time.Second, func() error { _, err := g.memberlist.Join(hosts) return err @@ -126,11 +126,11 @@ type gossipConfig struct { } // GossipMemberSetOption describes a functional option for GossipMemberSet. -type GossipMemberSetOption func(*GossipMemberSet) error +type GossipMemberSetOption func(*gossipMemberSet) error // WithTransport is a functional option for providing a transport to NewGossipMemberSet. func WithTransport(transport *Transport) GossipMemberSetOption { - return func(g *GossipMemberSet) error { + return func(g *gossipMemberSet) error { g.transport = transport return nil } @@ -138,16 +138,16 @@ func WithTransport(transport *Transport) GossipMemberSetOption { // WithLogger is a functional option for providing a logger to NewGossipMemberSet. func WithLogger(logger *log.Logger) GossipMemberSetOption { - return func(g *GossipMemberSet) error { + return func(g *gossipMemberSet) error { g.logger = logger return nil } } // NewGossipMemberSet returns a new instance of GossipMemberSet based on options. -func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...GossipMemberSetOption) (*GossipMemberSet, error) { +func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...GossipMemberSetOption) (*gossipMemberSet, error) { host := api.Node().URI.Host - g := &GossipMemberSet{ + g := &gossipMemberSet{ papi: api, Logger: pilosa.NopLogger, } @@ -219,7 +219,7 @@ func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...GossipMemberSetO } // NodeMeta implementation of the memberlist.Delegate interface. -func (g *GossipMemberSet) NodeMeta(limit int) []byte { +func (g *gossipMemberSet) NodeMeta(limit int) []byte { buf, err := g.papi.Serializer.Marshal(g.papi.Node()) if err != nil { g.Logger.Printf("marshal message error: %s", err) @@ -230,7 +230,7 @@ func (g *GossipMemberSet) NodeMeta(limit int) []byte { // NotifyMsg implementation of the memberlist.Delegate interface // called when a user-data message is received. -func (g *GossipMemberSet) NotifyMsg(b []byte) { +func (g *gossipMemberSet) NotifyMsg(b []byte) { err := g.papi.ClusterMessage(context.Background(), bytes.NewBuffer(b)) if err != nil { g.Logger.Printf("cluster message error: %s", err) @@ -239,13 +239,13 @@ func (g *GossipMemberSet) NotifyMsg(b []byte) { // GetBroadcasts implementation of the memberlist.Delegate interface // called when user data messages can be broadcast. -func (g *GossipMemberSet) GetBroadcasts(overhead, limit int) [][]byte { +func (g *gossipMemberSet) GetBroadcasts(overhead, limit int) [][]byte { return g.broadcasts.GetBroadcasts(overhead, limit) } // LocalState implementation of the memberlist.Delegate interface // sends this Node's state data. -func (g *GossipMemberSet) LocalState(join bool) []byte { +func (g *gossipMemberSet) LocalState(join bool) []byte { m := &pilosa.NodeStatus{ Node: g.papi.Node(), MaxShards: g.papi.MaxShards(context.Background()), @@ -263,7 +263,7 @@ func (g *GossipMemberSet) LocalState(join bool) []byte { // MergeRemoteState implementation of the memberlist.Delegate interface // receive and process the remote side's LocalState. -func (g *GossipMemberSet) MergeRemoteState(buf []byte, join bool) { +func (g *gossipMemberSet) MergeRemoteState(buf []byte, join bool) { err := g.papi.ClusterMessage(context.Background(), bytes.NewBuffer(buf)) if err != nil { g.Logger.Printf("merge state error: %s", err) From d512b187b13262a1287cdf96160f4815206d431d Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:46 -0500 Subject: [PATCH 091/138] Unexport gossip.GossipMemberSetOption --- gossip/gossip.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gossip/gossip.go b/gossip/gossip.go index 289eb505d..0148ccd40 100644 --- a/gossip/gossip.go +++ b/gossip/gossip.go @@ -125,11 +125,11 @@ type gossipConfig struct { memberlistConfig *memberlist.Config } -// GossipMemberSetOption describes a functional option for GossipMemberSet. -type GossipMemberSetOption func(*gossipMemberSet) error +// gossipMemberSetOption describes a functional option for GossipMemberSet. +type gossipMemberSetOption func(*gossipMemberSet) error // WithTransport is a functional option for providing a transport to NewGossipMemberSet. -func WithTransport(transport *Transport) GossipMemberSetOption { +func WithTransport(transport *Transport) gossipMemberSetOption { return func(g *gossipMemberSet) error { g.transport = transport return nil @@ -137,7 +137,7 @@ func WithTransport(transport *Transport) GossipMemberSetOption { } // WithLogger is a functional option for providing a logger to NewGossipMemberSet. -func WithLogger(logger *log.Logger) GossipMemberSetOption { +func WithLogger(logger *log.Logger) gossipMemberSetOption { return func(g *gossipMemberSet) error { g.logger = logger return nil @@ -145,7 +145,7 @@ func WithLogger(logger *log.Logger) GossipMemberSetOption { } // NewGossipMemberSet returns a new instance of GossipMemberSet based on options. -func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...GossipMemberSetOption) (*gossipMemberSet, error) { +func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...gossipMemberSetOption) (*gossipMemberSet, error) { host := api.Node().URI.Host g := &gossipMemberSet{ papi: api, From d95aeae1758afcce8e01d404029eb211de838738 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:51 -0500 Subject: [PATCH 092/138] Unexport gossip.Transport.Net --- gossip/gossip.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gossip/gossip.go b/gossip/gossip.go index 0148ccd40..7650cff86 100644 --- a/gossip/gossip.go +++ b/gossip/gossip.go @@ -176,7 +176,7 @@ func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...gossipMemberSetO g.transport = transport } - port := g.transport.Net.GetAutoBindPort() + port := g.transport.net.GetAutoBindPort() var gossipKey []byte var err error @@ -189,7 +189,7 @@ func NewGossipMemberSet(cfg Config, api *pilosa.API, options ...gossipMemberSetO // memberlist config conf := memberlist.DefaultWANConfig() - conf.Transport = g.transport.Net + conf.Transport = g.transport.net conf.Name = api.Node().ID conf.BindAddr = api.Node().URI.Host conf.BindPort = port @@ -343,7 +343,7 @@ func (g *gossipEventReceiver) listen() { // Transport is a gossip transport for binding to a port. type Transport struct { //memberlist.Transport - Net *memberlist.NetTransport + net *memberlist.NetTransport URI *pilosa.URI } @@ -370,7 +370,7 @@ func NewTransport(host string, port int, logger *log.Logger) (*Transport, error) } return &Transport{ - Net: net, + net: net, URI: uri, }, nil } From 47c402c123e47d5bdd76ed3ccf16205f8c9a9b3c Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 21:59:57 -0500 Subject: [PATCH 093/138] Unexport http.Error.Code --- http/error.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/error.go b/http/error.go index 90fac3206..1a3f07c04 100644 --- a/http/error.go +++ b/http/error.go @@ -17,7 +17,7 @@ package http // Error defines a standard application error. type Error struct { // Machine-readable error code. - Code string `json:"code,omitempty"` + code string `json:"code,omitempty"` // Human-readable message. Message string `json:"message"` From 0a2b482945aac4ec2a6c0112953c8e38a016b25a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:02 -0500 Subject: [PATCH 094/138] Unexport http.Handler.Logger --- http/handler.go | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/http/handler.go b/http/handler.go index 0693a4d17..a827df410 100644 --- a/http/handler.go +++ b/http/handler.go @@ -44,7 +44,7 @@ import ( type Handler struct { Handler http.Handler - Logger pilosa.Logger + logger pilosa.Logger // Keeps the query argument validators for each handler validators map[string]*queryValidationSpec @@ -97,7 +97,7 @@ func OptHandlerAPI(api *pilosa.API) HandlerOption { func OptHandlerLogger(logger pilosa.Logger) HandlerOption { return func(h *Handler) error { - h.Logger = logger + h.logger = logger return nil } } @@ -112,7 +112,7 @@ func OptHandlerListener(ln net.Listener) HandlerOption { // NewHandler returns a new instance of Handler with a default logger. func NewHandler(opts ...HandlerOption) (*Handler, error) { handler := &Handler{ - Logger: pilosa.NopLogger, + logger: pilosa.NopLogger, } handler.Handler = NewRouter(handler) handler.populateValidators() @@ -140,7 +140,7 @@ func NewHandler(opts ...HandlerOption) (*Handler, error) { func (h *Handler) Serve() error { err := h.server.Serve(h.ln) if err != nil && err.Error() != "http: Server closed" { - h.Logger.Printf("HTTP handler terminated with error: %s\n", err) + h.logger.Printf("HTTP handler terminated with error: %s\n", err) return errors.Wrap(err, "serve http") } return nil @@ -240,7 +240,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusInternalServerError) stack := debug.Stack() msg := "PANIC: %s\n%s" - h.Logger.Printf(msg, err, stack) + h.logger.Printf(msg, err, stack) fmt.Fprintf(w, msg, err, stack) } }() @@ -254,7 +254,7 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { longQueryTime := h.api.LongQueryTime() if longQueryTime > 0 && dif > longQueryTime { - h.Logger.Printf("%s %s %v", r.Method, r.URL.String(), dif) + h.logger.Printf("%s %s %v", r.Method, r.URL.String(), dif) statsTags = append(statsTags, "slow_query") } @@ -357,7 +357,7 @@ func (h *Handler) handleGetSchema(w http.ResponseWriter, r *http.Request) { schema := h.api.Schema(r.Context()) if err := json.NewEncoder(w).Encode(map[string]interface{}{"indexes": schema}); err != nil { - h.Logger.Printf("write schema response error: %s", err) + h.logger.Printf("write schema response error: %s", err) } } @@ -373,7 +373,7 @@ func (h *Handler) handleGetStatus(w http.ResponseWriter, r *http.Request) { LocalID: h.api.Node().ID, } if err := json.NewEncoder(w).Encode(status); err != nil { - h.Logger.Printf("write status response error: %s", err) + h.logger.Printf("write status response error: %s", err) } } @@ -384,7 +384,7 @@ func (h *Handler) handleGetInfo(w http.ResponseWriter, r *http.Request) { } info := h.api.Info() if err := json.NewEncoder(w).Encode(info); err != nil { - h.Logger.Printf("write info response error: %s", err) + h.logger.Printf("write info response error: %s", err) } } @@ -436,7 +436,7 @@ func (h *Handler) handlePostQuery(w http.ResponseWriter, r *http.Request) { // Write response back to client. if err := h.writeQueryResponse(w, r, &resp); err != nil { - h.Logger.Printf("write query response error: %s", err) + h.logger.Printf("write query response error: %s", err) } } @@ -449,7 +449,7 @@ func (h *Handler) handleGetShardsMax(w http.ResponseWriter, r *http.Request) { if err := json.NewEncoder(w).Encode(getShardsMaxResponse{ Standard: h.api.MaxShards(r.Context()), }); err != nil { - h.Logger.Printf("write shards-max response error: %s", err) + h.logger.Printf("write shards-max response error: %s", err) } } @@ -472,7 +472,7 @@ func (h *Handler) handleGetIndex(w http.ResponseWriter, r *http.Request) { for _, idx := range h.api.Schema(r.Context()) { if idx.Name == indexName { if err := json.NewEncoder(w).Encode(idx); err != nil { - h.Logger.Printf("write response error: %s", err) + h.logger.Printf("write response error: %s", err) } return } @@ -618,7 +618,7 @@ func (h *Handler) handlePostIndexAttrDiff(w http.ResponseWriter, r *http.Request if err := json.NewEncoder(w).Encode(postIndexAttrDiffResponse{ Attrs: attrs, }); err != nil { - h.Logger.Printf("response encoding error: %s", err) + h.logger.Printf("response encoding error: %s", err) } } @@ -795,7 +795,7 @@ func (h *Handler) handlePostFieldAttrDiff(w http.ResponseWriter, r *http.Request if err := json.NewEncoder(w).Encode(postFieldAttrDiffResponse{ Attrs: attrs, }); err != nil { - h.Logger.Printf("response encoding error: %s", err) + h.logger.Printf("response encoding error: %s", err) } } @@ -1026,7 +1026,7 @@ func (h *Handler) handleGetFragmentNodes(w http.ResponseWriter, r *http.Request) // Write to response. if err := json.NewEncoder(w).Encode(nodes); err != nil { - h.Logger.Printf("json write error: %s", err) + h.logger.Printf("json write error: %s", err) } } @@ -1078,7 +1078,7 @@ func (h *Handler) handleGetFragmentBlocks(w http.ResponseWriter, r *http.Request if err := json.NewEncoder(w).Encode(getFragmentBlocksResponse{ Blocks: blocks, }); err != nil { - h.Logger.Printf("block response encoding error: %s", err) + h.logger.Printf("block response encoding error: %s", err) } } @@ -1098,7 +1098,7 @@ func (h *Handler) handleGetVersion(w http.ResponseWriter, r *http.Request) { Version: h.api.Version(), }) if err != nil { - h.Logger.Printf("write version response error: %s", err) + h.logger.Printf("write version response error: %s", err) } } @@ -1166,7 +1166,7 @@ func (h *Handler) handlePostClusterResizeSetCoordinator(w http.ResponseWriter, r Old: oldNode, New: newNode, }); err != nil { - h.Logger.Printf("response encoding error: %s", err) + h.logger.Printf("response encoding error: %s", err) } } @@ -1207,7 +1207,7 @@ func (h *Handler) handlePostClusterResizeRemoveNode(w http.ResponseWriter, r *ht if err := json.NewEncoder(w).Encode(removeNodeResponse{ Remove: removeNode, }); err != nil { - h.Logger.Printf("response encoding error: %s", err) + h.logger.Printf("response encoding error: %s", err) } } @@ -1243,7 +1243,7 @@ func (h *Handler) handlePostClusterResizeAbort(w http.ResponseWriter, r *http.Re if err := json.NewEncoder(w).Encode(clusterResizeAbortResponse{ Info: msg, }); err != nil { - h.Logger.Printf("response encoding error: %s", err) + h.logger.Printf("response encoding error: %s", err) } } @@ -1279,7 +1279,7 @@ func (h *Handler) handlePostClusterMessage(w http.ResponseWriter, r *http.Reques } if err := json.NewEncoder(w).Encode(defaultClusterMessageResponse{}); err != nil { - h.Logger.Printf("response encoding error: %s", err) + h.logger.Printf("response encoding error: %s", err) } } From 46e40f71e4a4c8bc52988d06682e93197257ba9a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:08 -0500 Subject: [PATCH 095/138] Unexport http.Handler.AllowedOrigins --- http/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/handler.go b/http/handler.go index a827df410..041743fcf 100644 --- a/http/handler.go +++ b/http/handler.go @@ -51,7 +51,7 @@ type Handler struct { api *pilosa.API - AllowedOrigins []string + allowedOrigins []string ln net.Listener From a3bd753cfad4661c3f59d91086ac993718f2f3a7 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:14 -0500 Subject: [PATCH 096/138] Unexport http.HandlerOption --- http/handler.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/http/handler.go b/http/handler.go index 041743fcf..cd8ebddba 100644 --- a/http/handler.go +++ b/http/handler.go @@ -75,10 +75,10 @@ type errorResponse struct { Error string `json:"error"` } -// HandlerOption is a functional option type for pilosa.Handler -type HandlerOption func(s *Handler) error +// handlerOption is a functional option type for pilosa.Handler +type handlerOption func(s *Handler) error -func OptHandlerAllowedOrigins(origins []string) HandlerOption { +func OptHandlerAllowedOrigins(origins []string) handlerOption { return func(h *Handler) error { h.Handler = handlers.CORS( handlers.AllowedOrigins(origins), @@ -88,21 +88,21 @@ func OptHandlerAllowedOrigins(origins []string) HandlerOption { } } -func OptHandlerAPI(api *pilosa.API) HandlerOption { +func OptHandlerAPI(api *pilosa.API) handlerOption { return func(h *Handler) error { h.api = api return nil } } -func OptHandlerLogger(logger pilosa.Logger) HandlerOption { +func OptHandlerLogger(logger pilosa.Logger) handlerOption { return func(h *Handler) error { h.logger = logger return nil } } -func OptHandlerListener(ln net.Listener) HandlerOption { +func OptHandlerListener(ln net.Listener) handlerOption { return func(h *Handler) error { h.ln = ln return nil @@ -110,7 +110,7 @@ func OptHandlerListener(ln net.Listener) HandlerOption { } // NewHandler returns a new instance of Handler with a default logger. -func NewHandler(opts ...HandlerOption) (*Handler, error) { +func NewHandler(opts ...handlerOption) (*Handler, error) { handler := &Handler{ logger: pilosa.NopLogger, } From e460a58bfa640878e89b07fe20d1347c4c315c43 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:20 -0500 Subject: [PATCH 097/138] Unexport http.InternalClient.HTTPClient --- http/client.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/http/client.go b/http/client.go index 7453c87fd..bf5c9f5dc 100644 --- a/http/client.go +++ b/http/client.go @@ -38,7 +38,7 @@ type InternalClient struct { serializer pilosa.Serializer // The client to use for HTTP communication. - HTTPClient *http.Client + httpClient *http.Client } // NewInternalClient returns a new instance of InternalClient to connect to host. @@ -60,7 +60,7 @@ func NewInternalClientFromURI(defaultURI *pilosa.URI, remoteClient *http.Client) return &InternalClient{ defaultURI: defaultURI, serializer: proto.Serializer{}, - HTTPClient: remoteClient, + httpClient: remoteClient, } } @@ -84,7 +84,7 @@ func (c *InternalClient) maxShardByIndex(ctx context.Context) (map[string]uint64 req.Header.Set("Accept", "application/json") // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -115,7 +115,7 @@ func (c *InternalClient) Schema(ctx context.Context) ([]*pilosa.IndexInfo, error req.Header.Set("Accept", "application/json") // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -152,7 +152,7 @@ func (c *InternalClient) CreateIndex(ctx context.Context, index string, opt pilo req.Header.Set("User-Agent", "pilosa/"+pilosa.Version) // Execute request against the host. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return errors.Wrap(err, "executing request") } @@ -191,7 +191,7 @@ func (c *InternalClient) FragmentNodes(ctx context.Context, index string, shard req.Header.Set("Accept", "application/json") // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -238,7 +238,7 @@ func (c *InternalClient) QueryNode(ctx context.Context, uri *pilosa.URI, index s req.Header.Set("User-Agent", "pilosa/"+pilosa.Version) // Execute request against the host. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -390,7 +390,7 @@ func (c *InternalClient) importNode(ctx context.Context, node *pilosa.Node, inde req.Header.Set("User-Agent", "pilosa/"+pilosa.Version) // Execute request against the host. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return errors.Wrap(err, "executing request") } @@ -512,7 +512,7 @@ func (c *InternalClient) exportNodeCSV(ctx context.Context, node *pilosa.Node, i req.Header.Set("User-Agent", "pilosa/"+pilosa.Version) // Execute request against the host. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return errors.Wrap(err, "executing request") } @@ -555,7 +555,7 @@ func (c *InternalClient) backupShardNode(ctx context.Context, index, field strin req.Header.Set("User-Agent", "pilosa/"+pilosa.Version) // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -599,7 +599,7 @@ func (c *InternalClient) CreateField(ctx context.Context, index, field string) e req.Header.Set("User-Agent", "pilosa/"+pilosa.Version) // Execute request against the host. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return errors.Wrap(err, "executing request") } @@ -645,7 +645,7 @@ func (c *InternalClient) FragmentBlocks(ctx context.Context, uri *pilosa.URI, in req.Header.Set("Accept", "application/json") // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -693,7 +693,7 @@ func (c *InternalClient) BlockData(ctx context.Context, uri *pilosa.URI, index, req.Header.Set("Accept", "application/protobuf") req.Header.Set("User-Agent", "pilosa/"+pilosa.Version) - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, nil, errors.Wrap(err, "executing request") } @@ -741,7 +741,7 @@ func (c *InternalClient) ColumnAttrDiff(ctx context.Context, uri *pilosa.URI, in req.Header.Set("Accept", "application/json") // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -785,7 +785,7 @@ func (c *InternalClient) RowAttrDiff(ctx context.Context, uri *pilosa.URI, index req.Header.Set("Accept", "application/json") // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return nil, errors.Wrap(err, "executing request") } @@ -820,7 +820,7 @@ func (c *InternalClient) SendMessage(ctx context.Context, uri *pilosa.URI, msg [ req.Header.Set("Accept", "application/json") // Execute request. - resp, err := c.HTTPClient.Do(req.WithContext(ctx)) + resp, err := c.httpClient.Do(req.WithContext(ctx)) if err != nil { return fmt.Errorf("executing http request: %v", err) } From ab26a1be4b8d0085be38b4387a3761e5328b27d2 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:25 -0500 Subject: [PATCH 098/138] Unexport http.NewRouter --- http/handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/http/handler.go b/http/handler.go index cd8ebddba..6df406e14 100644 --- a/http/handler.go +++ b/http/handler.go @@ -114,7 +114,7 @@ func NewHandler(opts ...handlerOption) (*Handler, error) { handler := &Handler{ logger: pilosa.NopLogger, } - handler.Handler = NewRouter(handler) + handler.Handler = newRouter(handler) handler.populateValidators() for _, opt := range opts { @@ -183,8 +183,8 @@ func (h *Handler) queryArgValidator(next http.Handler) http.Handler { }) } -// NewRouter creates a new mux http router. -func NewRouter(handler *Handler) *mux.Router { +// newRouter creates a new mux http router. +func newRouter(handler *Handler) *mux.Router { router := mux.NewRouter() router.HandleFunc("/", handler.handleHome).Methods("GET") router.HandleFunc("/cluster/resize/abort", handler.handlePostClusterResizeAbort).Methods("POST") From 88b45edd7c73d7dfaff401d88ee5cb7eaca5f389 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:31 -0500 Subject: [PATCH 099/138] Unexport http.QueryResultTypeBool --- http/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/handler.go b/http/handler.go index 6df406e14..a51a1e0d0 100644 --- a/http/handler.go +++ b/http/handler.go @@ -1109,7 +1109,7 @@ const ( QueryResultTypePairs QueryResultTypeValCount QueryResultTypeUint64 - QueryResultTypeBool + queryResultTypeBool ) // parseUint64Slice returns a slice of uint64s from a comma-delimited string. From 9a708234c868a6c2db0953c18354a95efe47e255 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:36 -0500 Subject: [PATCH 100/138] Unexport http.QueryResultTypeNil --- http/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/handler.go b/http/handler.go index a51a1e0d0..312483d72 100644 --- a/http/handler.go +++ b/http/handler.go @@ -1104,7 +1104,7 @@ func (h *Handler) handleGetVersion(w http.ResponseWriter, r *http.Request) { // QueryResult types. const ( - QueryResultTypeNil uint32 = iota + queryResultTypeNil uint32 = iota QueryResultTypeRow QueryResultTypePairs QueryResultTypeValCount From 04417d870d356b375b5c0ed1e962bd59c9c6c1e6 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:42 -0500 Subject: [PATCH 101/138] Unexport http.QueryResultTypeValCount --- http/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http/handler.go b/http/handler.go index 312483d72..4946f69e0 100644 --- a/http/handler.go +++ b/http/handler.go @@ -1107,7 +1107,7 @@ const ( queryResultTypeNil uint32 = iota QueryResultTypeRow QueryResultTypePairs - QueryResultTypeValCount + queryResultTypeValCount QueryResultTypeUint64 queryResultTypeBool ) From 55d13d869fe5301ad3adc1a7feb90060813df5d2 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:48 -0500 Subject: [PATCH 102/138] Unexport http.TranslateStore --- http/translator.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/http/translator.go b/http/translator.go index 08235bf47..d094a8c28 100644 --- a/http/translator.go +++ b/http/translator.go @@ -14,41 +14,41 @@ import ( ) // Ensure implementation implements inteface. -var _ pilosa.TranslateStore = (*TranslateStore)(nil) +var _ pilosa.TranslateStore = (*translateStore)(nil) -// TranslateStore represents an implementation of TranslateStore that +// translateStore represents an implementation of translateStore that // communicates over HTTP. This is used with the TranslateHandler. -type TranslateStore struct { +type translateStore struct { URL string } // NewTranslateStore returns a new instance of TranslateStore. -func NewTranslateStore(rawurl string) *TranslateStore { - return &TranslateStore{URL: rawurl} +func NewTranslateStore(rawurl string) *translateStore { + return &translateStore{URL: rawurl} } // TranslateColumnsToUint64 is not currently implemented. -func (s *TranslateStore) TranslateColumnsToUint64(index string, values []string) ([]uint64, error) { +func (s *translateStore) TranslateColumnsToUint64(index string, values []string) ([]uint64, error) { return nil, pilosa.ErrNotImplemented } // TranslateColumnToString is not currently implemented. -func (s *TranslateStore) TranslateColumnToString(index string, values uint64) (string, error) { +func (s *translateStore) TranslateColumnToString(index string, values uint64) (string, error) { return "", pilosa.ErrNotImplemented } // TranslateRowsToUint64 is not currently implemented. -func (s *TranslateStore) TranslateRowsToUint64(index, frame string, values []string) ([]uint64, error) { +func (s *translateStore) TranslateRowsToUint64(index, frame string, values []string) ([]uint64, error) { return nil, pilosa.ErrNotImplemented } // TranslateRowToString is not currently implemented. -func (s *TranslateStore) TranslateRowToString(index, frame string, values uint64) (string, error) { +func (s *translateStore) TranslateRowToString(index, frame string, values uint64) (string, error) { return "", pilosa.ErrNotImplemented } // Reader returns a reader that can stream data from a remote store. -func (s *TranslateStore) Reader(ctx context.Context, off int64) (io.ReadCloser, error) { +func (s *translateStore) Reader(ctx context.Context, off int64) (io.ReadCloser, error) { // Generate remote URL. u, err := url.Parse(s.URL) if err != nil { From 536f6cff8a1ffbaf4b43da9cad6d181a91f5b326 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:52 -0500 Subject: [PATCH 103/138] Unexport inmem.TranslateStore --- inmem/translator.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/inmem/translator.go b/inmem/translator.go index b620b2d03..4e1e96b55 100644 --- a/inmem/translator.go +++ b/inmem/translator.go @@ -9,10 +9,10 @@ import ( ) // Ensure type implements interface. -var _ pilosa.TranslateStore = &TranslateStore{} +var _ pilosa.TranslateStore = &translateStore{} -// TranslateStore is an in-memory storage engine for translating string-to-uint64 values. -type TranslateStore struct { +// translateStore is an in-memory storage engine for translating string-to-uint64 values. +type translateStore struct { mu sync.RWMutex cols map[string]*translateIndex @@ -20,21 +20,21 @@ type TranslateStore struct { } // NewTranslateStore returns a new instance of TranslateStore. -func NewTranslateStore() *TranslateStore { - return &TranslateStore{ +func NewTranslateStore() *translateStore { + return &translateStore{ cols: make(map[string]*translateIndex), rows: make(map[frameKey]*translateIndex), } } // Reader returns an error because it is not supported by the inmem store. -func (s *TranslateStore) Reader(ctx context.Context, offset int64) (io.ReadCloser, error) { +func (s *translateStore) Reader(ctx context.Context, offset int64) (io.ReadCloser, error) { return nil, pilosa.ErrReplicationNotSupported } // TranslateColumnsToUint64 converts value to a uint64 id. // If value does not have an associated id then one is created. -func (s *TranslateStore) TranslateColumnsToUint64(index string, values []string) ([]uint64, error) { +func (s *translateStore) TranslateColumnsToUint64(index string, values []string) ([]uint64, error) { ret := make([]uint64, len(values)) // Read value under read lock. @@ -103,7 +103,7 @@ func (s *TranslateStore) TranslateColumnsToUint64(index string, values []string) // TranslateColumnToString converts a uint64 id to its associated string value. // If the id is not associated with a string value then a blank string is returned. -func (s *TranslateStore) TranslateColumnToString(index string, value uint64) (string, error) { +func (s *translateStore) TranslateColumnToString(index string, value uint64) (string, error) { s.mu.RLock() if idx := s.cols[index]; idx != nil { if ret, ok := idx.reverse[value]; ok { @@ -115,7 +115,7 @@ func (s *TranslateStore) TranslateColumnToString(index string, value uint64) (st return "", nil } -func (s *TranslateStore) TranslateRowsToUint64(index, frame string, values []string) ([]uint64, error) { +func (s *translateStore) TranslateRowsToUint64(index, frame string, values []string) ([]uint64, error) { key := frameKey{index, frame} ret := make([]uint64, len(values)) @@ -184,7 +184,7 @@ func (s *TranslateStore) TranslateRowsToUint64(index, frame string, values []str return ret, nil } -func (s *TranslateStore) TranslateRowToString(index, frame string, value uint64) (string, error) { +func (s *translateStore) TranslateRowToString(index, frame string, value uint64) (string, error) { s.mu.RLock() if idx := s.rows[frameKey{index, frame}]; idx != nil { if ret, ok := idx.reverse[value]; ok { From a22d83b880a972d2e636b1f190fb07e053e703cb Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:55 -0500 Subject: [PATCH 104/138] Unexport lru.Cache.Clear --- lru/lru.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lru/lru.go b/lru/lru.go index 532cc45e6..31bcd1375 100644 --- a/lru/lru.go +++ b/lru/lru.go @@ -120,8 +120,8 @@ func (c *Cache) Len() int { return c.ll.Len() } -// Clear purges all stored items from the cache. -func (c *Cache) Clear() { +// clear purges all stored items from the cache. +func (c *Cache) clear() { if c.OnEvicted != nil { for _, e := range c.cache { kv := e.Value.(*entry) From ffae51549bbf51abc32e1913a49b040b817e618c Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:00:59 -0500 Subject: [PATCH 105/138] Unexport lru.Cache.Remove --- lru/lru.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lru/lru.go b/lru/lru.go index 31bcd1375..bd70df780 100644 --- a/lru/lru.go +++ b/lru/lru.go @@ -82,8 +82,8 @@ func (c *Cache) Get(key Key) (value interface{}, ok bool) { return } -// Remove removes the provided key from the cache. -func (c *Cache) Remove(key Key) { +// remove removes the provided key from the cache. +func (c *Cache) remove(key Key) { if c.cache == nil { return } From 91ce0d6c576d78e0f4a6c3d7d87169d714d252fa Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:01:03 -0500 Subject: [PATCH 106/138] Unexport lru.Cache.RemoveOldest --- lru/lru.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lru/lru.go b/lru/lru.go index bd70df780..9e944703f 100644 --- a/lru/lru.go +++ b/lru/lru.go @@ -66,7 +66,7 @@ func (c *Cache) Add(key Key, value interface{}) { ele := c.ll.PushFront(&entry{key, value}) c.cache[key] = ele if c.MaxEntries != 0 && c.ll.Len() > c.MaxEntries { - c.RemoveOldest() + c.removeOldest() } } @@ -92,8 +92,8 @@ func (c *Cache) remove(key Key) { } } -// RemoveOldest removes the oldest item from the cache. -func (c *Cache) RemoveOldest() { +// removeOldest removes the oldest item from the cache. +func (c *Cache) removeOldest() { if c.cache == nil { return } From d6f0789511f5651ff2d7e83c9447a8f5ed253f19 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:01:07 -0500 Subject: [PATCH 107/138] Unexport lru.Cache.MaxEntries --- lru/lru.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lru/lru.go b/lru/lru.go index 9e944703f..59f896f7e 100644 --- a/lru/lru.go +++ b/lru/lru.go @@ -21,9 +21,9 @@ import "container/list" // Cache is an LRU cache. It is not safe for concurrent access. type Cache struct { - // MaxEntries is the maximum number of cache entries before + // maxEntries is the maximum number of cache entries before // an item is evicted. Zero means no limit. - MaxEntries int + maxEntries int // OnEvicted optionally specificies a callback function to be // executed when an entry is purged from the cache. @@ -46,7 +46,7 @@ type entry struct { // that eviction is done by the caller. func New(maxEntries int) *Cache { return &Cache{ - MaxEntries: maxEntries, + maxEntries: maxEntries, ll: list.New(), cache: make(map[interface{}]*list.Element), } @@ -65,7 +65,7 @@ func (c *Cache) Add(key Key, value interface{}) { } ele := c.ll.PushFront(&entry{key, value}) c.cache[key] = ele - if c.MaxEntries != 0 && c.ll.Len() > c.MaxEntries { + if c.maxEntries != 0 && c.ll.Len() > c.maxEntries { c.removeOldest() } } From 3a4763858014d0f4b2563dff6a0f7cabbfb1099a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:01:39 -0500 Subject: [PATCH 108/138] Unexport pql.Call.Keys --- pql/ast.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pql/ast.go b/pql/ast.go index 47baa9d6c..f95da9f40 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -312,8 +312,8 @@ func (c *Call) UintSliceArg(key string) ([]uint64, bool, error) { } } -// Keys returns a list of argument keys in sorted order. -func (c *Call) Keys() []string { +// keys returns a list of argument keys in sorted order. +func (c *Call) keys() []string { a := make([]string, 0, len(c.Args)) for k := range c.Args { a = append(a, k) @@ -369,7 +369,7 @@ func (c *Call) String() string { } // Write arguments in key order. - for i, key := range c.Keys() { + for i, key := range c.keys() { if i > 0 { buf.WriteString(", ") } From aa7f6fca75d1b6fb8eed0e9daca81d66d5c4e30b Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:01:45 -0500 Subject: [PATCH 109/138] Unexport pql.FormatValue --- pql/ast.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pql/ast.go b/pql/ast.go index f95da9f40..88095c49b 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -379,7 +379,7 @@ func (c *Call) String() string { case *Condition: fmt.Fprintf(&buf, "%v %s", key, v.String()) default: - fmt.Fprintf(&buf, "%v=%s", key, FormatValue(v)) + fmt.Fprintf(&buf, "%v=%s", key, formatValue(v)) } } @@ -408,7 +408,7 @@ type Condition struct { // String returns the string representation of the condition. func (cond *Condition) String() string { - return fmt.Sprintf("%s %s", cond.Op.String(), FormatValue(cond.Value)) + return fmt.Sprintf("%s %s", cond.Op.String(), formatValue(cond.Value)) } // IntSliceValue reads cond.Value as a slice of uint64. @@ -436,7 +436,7 @@ func (cond *Condition) IntSliceValue() ([]int64, error) { } } -func FormatValue(v interface{}) string { +func formatValue(v interface{}) string { switch v := v.(type) { case string: return fmt.Sprintf("%q", v) From 75ea43c9da999b07171b81162ad80476160ad1ac Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:01:50 -0500 Subject: [PATCH 110/138] Unexport pql.Parser --- pql/parser.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pql/parser.go b/pql/parser.go index 83498f207..3bc91a2ee 100644 --- a/pql/parser.go +++ b/pql/parser.go @@ -25,16 +25,16 @@ import ( // TimeFormat is the go-style time format used to parse string dates. const TimeFormat = "2006-01-02T15:04" -// Parser represents a parser for the PQL language. -type Parser struct { +// parser represents a parser for the PQL language. +type parser struct { r io.Reader //scanner *bufScanner PQL } // NewParser returns a new instance of Parser. -func NewParser(r io.Reader) *Parser { - return &Parser{ +func NewParser(r io.Reader) *parser { + return &parser{ r: r, // scanner: newBufScanner(r), } @@ -46,7 +46,7 @@ func ParseString(s string) (*Query, error) { } // Parse parses the next node in the query. -func (p *Parser) Parse() (*Query, error) { +func (p *parser) Parse() (*Query, error) { buf, err := ioutil.ReadAll(p.r) if err != nil { return nil, errors.Wrap(err, "reading buffer to parse") From fb7de28557ba33ccb247651bbfa5ffe26136f102 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:01:56 -0500 Subject: [PATCH 111/138] Unexport pql.TimeFormat --- pql/ast.go | 2 +- pql/parser.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pql/ast.go b/pql/ast.go index 88095c49b..88af892ad 100644 --- a/pql/ast.go +++ b/pql/ast.go @@ -445,7 +445,7 @@ func formatValue(v interface{}) string { case []uint64: return fmt.Sprintf("%s", joinUint64Slice(v)) case time.Time: - return fmt.Sprintf("\"%s\"", v.Format(TimeFormat)) + return fmt.Sprintf("\"%s\"", v.Format(timeFormat)) case *Condition: return v.String() default: diff --git a/pql/parser.go b/pql/parser.go index 3bc91a2ee..611294971 100644 --- a/pql/parser.go +++ b/pql/parser.go @@ -22,8 +22,8 @@ import ( "github.com/pkg/errors" ) -// TimeFormat is the go-style time format used to parse string dates. -const TimeFormat = "2006-01-02T15:04" +// timeFormat is the go-style time format used to parse string dates. +const timeFormat = "2006-01-02T15:04" // parser represents a parser for the PQL language. type parser struct { From c73fc795da203aaec96d99700171e3b9ef5959fe Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:03 -0500 Subject: [PATCH 112/138] Unexport roaring.BitmapInfo --- roaring/roaring.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index 07f1600a7..1e0f72a83 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -725,8 +725,8 @@ func (b *Bitmap) Iterator() *Iterator { } // Info returns stats for the bitmap. -func (b *Bitmap) Info() BitmapInfo { - info := BitmapInfo{ +func (b *Bitmap) Info() bitmapInfo { + info := bitmapInfo{ OpN: b.opN, Containers: make([]ContainerInfo, 0, b.Containers.Size()), } @@ -788,8 +788,8 @@ func (b *Bitmap) Flip(start, end uint64) *Bitmap { return result } -// BitmapInfo represents a point-in-time snapshot of bitmap stats. -type BitmapInfo struct { +// bitmapInfo represents a point-in-time snapshot of bitmap stats. +type bitmapInfo struct { OpN int Containers []ContainerInfo } From 72fcb37f807c9b7395e60287bb5aa85d7cba9949 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:08 -0500 Subject: [PATCH 113/138] Unexport roaring.Container.Optimize --- roaring/roaring.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index 1e0f72a83..a1295fd80 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -500,7 +500,7 @@ func (b *Bitmap) Optimize() { citer, _ := b.Containers.Iterator(0) for citer.Next() { _, c := citer.Value() - c.Optimize() + c.optimize() } } @@ -1315,9 +1315,9 @@ func (c *Container) countRuns() (r int) { return 0 } -// Optimize converts the container to the type which will take up the least +// optimize converts the container to the type which will take up the least // amount of space. -func (c *Container) Optimize() { +func (c *Container) optimize() { if c.n == 0 { return } @@ -2142,7 +2142,7 @@ func intersectBitmapBitmap(a, b *Container) *Container { output.n += int(popcount(v)) } - output.Optimize() + output.optimize() return output } @@ -2621,7 +2621,7 @@ RUNLOOP: output.n += int(run.last - start + 1) } } - output.Optimize() + output.optimize() return output } From 9098b0d1312c2f46acb42fff0d06055c864cf5c6 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:15 -0500 Subject: [PATCH 114/138] Unexport roaring.ContainerArray --- roaring/roaring.go | 46 +++++++++++++------------- roaring/roaring_helpers_test.go | 24 +++++++------- roaring/roaring_internal_test.go | 56 ++++++++++++++++---------------- 3 files changed, 63 insertions(+), 63 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index a1295fd80..ed6667c79 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -51,8 +51,8 @@ const ( // bitmapN is the number of values in a container.bitmap. bitmapN = (1 << 16) / 64 - //ContainerArray indicates a container of bit position values - ContainerArray = byte(1) + //containerArray indicates a container of bit position values + containerArray = byte(1) //ContainerBitmap indicates a container of bits packed in a uint64 array block ContainerBitmap = byte(2) @@ -663,7 +663,7 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error { runCount := binary.LittleEndian.Uint16(data[offset : offset+runCountHeaderSize]) c.runs = (*[0xFFFFFFF]interval16)(unsafe.Pointer(&data[offset+runCountHeaderSize]))[:runCount] opsOffset = int(offset) + runCountHeaderSize + len(c.runs)*interval16Size - case ContainerArray: + case containerArray: c.runs = nil c.bitmap = nil c.array = (*[0xFFFFFFF]uint16)(unsafe.Pointer(&data[offset]))[:c.n] @@ -1021,7 +1021,7 @@ func (iv interval16) runlen() int { // newContainer returns a new instance of container. func NewContainer() *Container { - return &Container{containerType: ContainerArray} + return &Container{containerType: containerArray} } // Mapped returns true if the container is mapped directly to a byte slice @@ -1043,7 +1043,7 @@ func (c *Container) Update(containerType byte, n int, mapped bool) { // isArray returns true if the container is an array container. func (c *Container) isArray() bool { - return c.containerType == ContainerArray + return c.containerType == containerArray } // isBitmap returns true if the container is a bitmap container. @@ -1066,7 +1066,7 @@ func (c *Container) unmap() { } switch c.containerType { - case ContainerArray: + case containerArray: tmp := make([]uint16, len(c.array)) copy(tmp, c.array) c.array = tmp @@ -1327,7 +1327,7 @@ func (c *Container) optimize() { if runs <= RunMaxSize && runs <= c.n/2 { newType = ContainerRun } else if c.n < ArrayMaxSize { - newType = ContainerArray + newType = containerArray } else { newType = ContainerBitmap } @@ -1340,7 +1340,7 @@ func (c *Container) optimize() { c.arrayToRun() } } else if c.isBitmap() { - if newType == ContainerArray { + if newType == containerArray { c.bitmapToArray() } else if newType == ContainerRun { c.bitmapToRun() @@ -1348,7 +1348,7 @@ func (c *Container) optimize() { } else if c.isRun() { if newType == ContainerBitmap { c.runToBitmap() - } else if newType == ContainerArray { + } else if newType == containerArray { c.runToArray() } } @@ -1487,7 +1487,7 @@ func (c *Container) runMax() uint16 { // bitmapToArray converts from bitmap format to array format. func (c *Container) bitmapToArray() { c.array = make([]uint16, 0, c.n) - c.containerType = ContainerArray + c.containerType = containerArray // return early if empty if c.n == 0 { @@ -1634,7 +1634,7 @@ func (c *Container) arrayToRun() { // runToArray converts from RLE format to array format. func (c *Container) runToArray() { - c.containerType = ContainerArray + c.containerType = containerArray c.array = make([]uint16, 0, c.n) // return early if empty @@ -1658,7 +1658,7 @@ func (c *Container) Clone() *Container { other := &Container{n: c.n, containerType: c.containerType} switch c.containerType { - case ContainerArray: + case containerArray: other.array = make([]uint16, len(c.array)) copy(other.array, c.array) case ContainerBitmap: @@ -1977,7 +1977,7 @@ func intersect(a, b *Container) *Container { } func intersectArrayArray(a, b *Container) *Container { - output := &Container{containerType: ContainerArray} + output := &Container{containerType: containerArray} na, nb := len(a.array), len(b.array) for i, j := 0, 0; i < na && j < nb; { va, vb := a.array[i], b.array[j] @@ -1998,7 +1998,7 @@ func intersectArrayArray(a, b *Container) *Container { // container. The return is always an array container (since it's guaranteed to // be low-cardinality) func intersectArrayRun(a, b *Container) *Container { - output := &Container{containerType: ContainerArray} + output := &Container{containerType: containerArray} na, nb := len(a.array), len(b.runs) for i, j := 0, 0; i < na && j < nb; { va, vb := a.array[i], b.runs[j] @@ -2059,7 +2059,7 @@ func intersectBitmapRun(a, b *Container) *Container { var output *Container if b.n < ArrayMaxSize { // output is array container - output = &Container{containerType: ContainerArray} + output = &Container{containerType: containerArray} for _, iv := range b.runs { for i := iv.start; i <= iv.last; i++ { if a.bitmapContains(i) { @@ -2119,7 +2119,7 @@ func intersectBitmapRun(a, b *Container) *Container { } func intersectArrayBitmap(a, b *Container) *Container { - output := &Container{containerType: ContainerArray} + output := &Container{containerType: containerArray} for _, va := range a.array { bmidx := va / 64 bidx := va % 64 @@ -2175,7 +2175,7 @@ func union(a, b *Container) *Container { } func unionArrayArray(a, b *Container) *Container { - output := &Container{containerType: ContainerArray} + output := &Container{containerType: containerArray} na, nb := len(a.array), len(b.array) for i, j := 0, 0; ; { if i >= na && j >= nb { @@ -2387,7 +2387,7 @@ func (c *Container) equals(c2 *Container) bool { if c.mapped != c2.mapped || c.containerType != c2.containerType || c.n != c2.n { return false } - if c.containerType == ContainerArray { + if c.containerType == containerArray { if len(c.array) != len(c2.array) { return false } @@ -2476,7 +2476,7 @@ func difference(a, b *Container) *Container { // differenceArrayArray computes the difference bween two arrays. func differenceArrayArray(a, b *Container) *Container { - output := &Container{containerType: ContainerArray} + output := &Container{containerType: containerArray} na, nb := len(a.array), len(b.array) for i, j := 0, 0; i < na; { va := a.array[i] @@ -2507,7 +2507,7 @@ func differenceArrayRun(a, b *Container) *Container { return a.Clone() } - output := &Container{array: make([]uint16, 0, a.n), containerType: ContainerArray} + output := &Container{array: make([]uint16, 0, a.n), containerType: containerArray} // cardinality upper bound: card(A) i := 0 // array index @@ -2542,7 +2542,7 @@ func differenceArrayRun(a, b *Container) *Container { // keep all array elements after end of runs // It's possible that output was converted from array to bitmap in output.add() // so check container type before proceeding. - if output.containerType == ContainerArray { + if output.containerType == containerArray { output.array = append(output.array, a.array[i:]...) // TODO: consider handling container.n mutations in one place // like we do with container.add(). @@ -2747,7 +2747,7 @@ func differenceRunRun(a, b *Container) *Container { } func differenceArrayBitmap(a, b *Container) *Container { - output := &Container{containerType: ContainerArray} + output := &Container{containerType: containerArray} for _, va := range a.array { bmidx := va / 64 bidx := va % 64 @@ -2821,7 +2821,7 @@ func xor(a, b *Container) *Container { } func xorArrayArray(a, b *Container) *Container { - output := &Container{containerType: ContainerArray} + output := &Container{containerType: containerArray} na, nb := len(a.array), len(b.array) for i, j := 0, 0; i < na || j < nb; { if i < na && j >= nb { diff --git a/roaring/roaring_helpers_test.go b/roaring/roaring_helpers_test.go index 24db8e1ca..3ed42d8db 100644 --- a/roaring/roaring_helpers_test.go +++ b/roaring/roaring_helpers_test.go @@ -236,7 +236,7 @@ func doContainer(containerType byte, data interface{}) *Container { } switch containerType { - case ContainerArray: + case containerArray: c.array = data.([]uint16) case ContainerBitmap: c.bitmap = data.([]uint64) @@ -253,17 +253,17 @@ func setupContainerTests() map[byte]map[string]*Container { cts := make(map[byte]map[string]*Container) // array containers - cts[ContainerArray] = map[string]*Container{ - "empty": doContainer(ContainerArray, arrayEmpty()), - "full": doContainer(ContainerArray, arrayFull()), - "firstBitSet": doContainer(ContainerArray, arrayFirstBitSet()), - "lastBitSet": doContainer(ContainerArray, arrayLastBitSet()), - "firstBitUnset": doContainer(ContainerArray, arrayFirstBitUnset()), - "lastBitUnset": doContainer(ContainerArray, arrayLastBitUnset()), - "innerBitsSet": doContainer(ContainerArray, arrayInnerBitsSet()), - "outerBitsSet": doContainer(ContainerArray, arrayOuterBitsSet()), - "oddBitsSet": doContainer(ContainerArray, arrayOddBitsSet()), - "evenBitsSet": doContainer(ContainerArray, arrayEvenBitsSet()), + cts[containerArray] = map[string]*Container{ + "empty": doContainer(containerArray, arrayEmpty()), + "full": doContainer(containerArray, arrayFull()), + "firstBitSet": doContainer(containerArray, arrayFirstBitSet()), + "lastBitSet": doContainer(containerArray, arrayLastBitSet()), + "firstBitUnset": doContainer(containerArray, arrayFirstBitUnset()), + "lastBitUnset": doContainer(containerArray, arrayLastBitUnset()), + "innerBitsSet": doContainer(containerArray, arrayInnerBitsSet()), + "outerBitsSet": doContainer(containerArray, arrayOuterBitsSet()), + "oddBitsSet": doContainer(containerArray, arrayOddBitsSet()), + "evenBitsSet": doContainer(containerArray, arrayEvenBitsSet()), } // bitmap containers diff --git a/roaring/roaring_internal_test.go b/roaring/roaring_internal_test.go index 6e1f105bf..c478c6209 100644 --- a/roaring/roaring_internal_test.go +++ b/roaring/roaring_internal_test.go @@ -290,7 +290,7 @@ func TestIntersectionCountArrayBitmap2(t *testing.T) { for i, test := range tests { a.array = test.array - a.containerType = ContainerArray + a.containerType = containerArray b.bitmap = test.bitmap b.containerType = ContainerBitmap ret := intersectionCountArrayBitmap(a, b) @@ -349,7 +349,7 @@ func TestRunMax(t *testing.T) { } func TestIntersectionCountArrayRun(t *testing.T) { - a := &Container{containerType: ContainerArray, array: []uint16{1, 5, 10, 11, 12}} + a := &Container{containerType: containerArray, array: []uint16{1, 5, 10, 11, 12}} b := &Container{containerType: ContainerRun, runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}} ret := intersectionCountArrayRun(a, b) @@ -458,7 +458,7 @@ func TestIntersectArrayRun(t *testing.T) { } for i, test := range tests { - a.containerType = ContainerArray + a.containerType = containerArray b.containerType = ContainerRun a.array = test.array b.runs = test.runs @@ -660,7 +660,7 @@ func TestUnionMixed(t *testing.T) { // array container a := &Container{} a.array = []uint16{1, 4, 5, 7, 10, 11, 12} - a.containerType = ContainerArray + a.containerType = containerArray a.n = 7 // bitmap container @@ -716,7 +716,7 @@ func TestIntersectMixed(t *testing.T) { a.containerType = ContainerRun b.array = []uint16{1, 4, 5, 7, 10, 11, 12} b.n = 7 - b.containerType = ContainerArray + b.containerType = containerArray res := intersect(a, b) if !reflect.DeepEqual(res.array, []uint16{5, 7, 10}) { t.Fatalf("test #1 expected %v, but got %v", []uint16{5, 7, 10}, res.array) @@ -766,11 +766,11 @@ func TestDifferenceMixed(t *testing.T) { b.array = []uint16{0, 2, 4, 6, 8, 10, 12} b.n = len(b.array) - b.containerType = ContainerArray + b.containerType = containerArray d.array = []uint16{1, 3, 5, 7, 9, 11, 12} d.n = len(d.array) - d.containerType = ContainerArray + d.containerType = containerArray res := difference(a, b) @@ -927,7 +927,7 @@ func TestUnionArrayRun(t *testing.T) { for i, test := range tests { a.array = test.array b.runs = test.runs - a.containerType = ContainerArray + a.containerType = containerArray b.containerType = ContainerRun ret := unionArrayRun(a, b) if !reflect.DeepEqual(ret.array, test.exp) { @@ -977,7 +977,7 @@ func TestBitmapSetRange(t *testing.T) { } func TestArrayToBitmap(t *testing.T) { - a := &Container{containerType: ContainerArray} + a := &Container{containerType: containerArray} tests := []struct { array []uint16 exp []uint64 @@ -1171,7 +1171,7 @@ func TestBitmapToRun(t *testing.T) { } func TestArrayToRun(t *testing.T) { - a := &Container{containerType: ContainerArray} + a := &Container{containerType: containerArray} tests := []struct { array []uint16 exp []interval16 @@ -1372,7 +1372,7 @@ func TestBitmapCountRuns(t *testing.T) { } func TestArrayCountRuns(t *testing.T) { - c := &Container{containerType: ContainerArray} + c := &Container{containerType: containerArray} tests := []struct { array []uint16 exp int @@ -1413,7 +1413,7 @@ func TestArrayCountRuns(t *testing.T) { } func TestDifferenceArrayRun(t *testing.T) { - a := &Container{containerType: ContainerArray} + a := &Container{containerType: containerArray} b := &Container{containerType: ContainerRun} tests := []struct { array []uint16 @@ -1440,7 +1440,7 @@ func TestDifferenceArrayRun(t *testing.T) { func TestDifferenceRunArray(t *testing.T) { a := &Container{containerType: ContainerRun} - b := &Container{containerType: ContainerArray} + b := &Container{containerType: containerArray} tests := []struct { runs []interval16 array []uint16 @@ -1667,7 +1667,7 @@ func TestDifferenceBitmapRun(t *testing.T) { func TestDifferenceBitmapArray(t *testing.T) { b := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} - a := &Container{containerType: ContainerArray} + a := &Container{containerType: containerArray} tests := []struct { bitmap []uint64 array []uint16 @@ -1780,7 +1780,7 @@ func TestDifferenceRunRun(t *testing.T) { } func TestWriteReadArray(t *testing.T) { - ca := &Container{array: []uint16{1, 10, 100, 1000}, n: 4, containerType: ContainerArray} + ca := &Container{array: []uint16{1, 10, 100, 1000}, n: 4, containerType: containerArray} ba := NewFileBitmap() ba.Containers.Put(0, ca) ba2 := NewFileBitmap() @@ -1877,21 +1877,21 @@ func TestXorArrayRun(t *testing.T) { exp *Container }{ { - a: &Container{array: []uint16{1, 5, 10, 11, 12}, containerType: ContainerArray}, + a: &Container{array: []uint16{1, 5, 10, 11, 12}, containerType: containerArray}, b: &Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: ContainerRun}, - exp: &Container{array: []uint16{1, 2, 3, 4, 6, 7, 8, 9, 11, 13, 15, 16}, containerType: ContainerArray, n: 12}, + exp: &Container{array: []uint16{1, 2, 3, 4, 6, 7, 8, 9, 11, 13, 15, 16}, containerType: containerArray, n: 12}, }, { - a: &Container{array: []uint16{1, 5, 10, 11, 12, 13, 14}, containerType: ContainerArray}, + a: &Container{array: []uint16{1, 5, 10, 11, 12, 13, 14}, containerType: containerArray}, b: &Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: ContainerRun}, - exp: &Container{array: []uint16{1, 2, 3, 4, 6, 7, 8, 9, 11, 14, 15, 16}, containerType: ContainerArray, n: 12}, + exp: &Container{array: []uint16{1, 2, 3, 4, 6, 7, 8, 9, 11, 14, 15, 16}, containerType: containerArray, n: 12}, }, { - a: &Container{array: []uint16{65535}, containerType: ContainerArray}, + a: &Container{array: []uint16{65535}, containerType: containerArray}, b: &Container{runs: []interval16{{start: 65534, last: 65535}}, containerType: ContainerRun}, - exp: &Container{array: []uint16{65534}, containerType: ContainerArray, n: 1}, + exp: &Container{array: []uint16{65534}, containerType: containerArray, n: 1}, }, { - a: &Container{array: []uint16{65535}, containerType: ContainerArray}, + a: &Container{array: []uint16{65535}, containerType: containerArray}, b: &Container{runs: []interval16{{start: 65535, last: 65535}}, containerType: ContainerRun}, - exp: &Container{array: []uint16{}, containerType: ContainerArray, n: 0}, + exp: &Container{array: []uint16{}, containerType: containerArray, n: 0}, }, } @@ -2546,7 +2546,7 @@ func TestSearch64(t *testing.T) { } func TestIntersectArrayBitmap(t *testing.T) { - a, b := &Container{containerType: ContainerArray}, &Container{ + a, b := &Container{containerType: containerArray}, &Container{ containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN), } @@ -2594,7 +2594,7 @@ func TestIntersectArrayBitmap(t *testing.T) { for i, test := range tests { a.array = test.array - a.containerType = ContainerArray + a.containerType = containerArray for i, bmval := range test.bitmap { b.bitmap[i] = bmval } @@ -2722,11 +2722,11 @@ func TestContainerCombinations(t *testing.T) { cts := setupContainerTests() - containerTypes := []byte{ContainerArray, ContainerBitmap, ContainerRun} + containerTypes := []byte{containerArray, ContainerBitmap, ContainerRun} // map used for a more descriptive print cm := map[byte]string{ - ContainerArray: "array", + containerArray: "array", ContainerBitmap: "bitmap", ContainerRun: "run", } @@ -3198,7 +3198,7 @@ func TestContainerCombinations(t *testing.T) { // Convert to all container types and check result. for _, ct := range containerTypes { clone := ret.Clone() - if ct == ContainerArray { + if ct == containerArray { if clone.isBitmap() { clone.bitmapToArray() } else if clone.isRun() { From 692b72be18cb549f0802e883a0701114e8473ad1 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:21 -0500 Subject: [PATCH 115/138] Unexport roaring.ContainerBitmap --- roaring/roaring.go | 38 ++++++++++---------- roaring/roaring_helpers_test.go | 24 ++++++------- roaring/roaring_internal_test.go | 62 ++++++++++++++++---------------- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index ed6667c79..3f048a544 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -54,8 +54,8 @@ const ( //containerArray indicates a container of bit position values containerArray = byte(1) - //ContainerBitmap indicates a container of bits packed in a uint64 array block - ContainerBitmap = byte(2) + //containerBitmap indicates a container of bits packed in a uint64 array block + containerBitmap = byte(2) //ContainerRun indicates a container of run encoded bits ContainerRun = byte(3) @@ -668,7 +668,7 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error { c.bitmap = nil c.array = (*[0xFFFFFFF]uint16)(unsafe.Pointer(&data[offset]))[:c.n] opsOffset = int(offset) + len(c.array)*2 // sizeof(uint32) - case ContainerBitmap: + case containerBitmap: c.array = nil c.runs = nil c.bitmap = (*[0xFFFFFFF]uint64)(unsafe.Pointer(&data[offset]))[:bitmapN] @@ -1048,7 +1048,7 @@ func (c *Container) isArray() bool { // isBitmap returns true if the container is a bitmap container. func (c *Container) isBitmap() bool { - return c.containerType == ContainerBitmap + return c.containerType == containerBitmap } // isRun returns true if the container is a run-length-encoded container. @@ -1070,7 +1070,7 @@ func (c *Container) unmap() { tmp := make([]uint16, len(c.array)) copy(tmp, c.array) c.array = tmp - case ContainerBitmap: + case containerBitmap: tmp := make([]uint64, len(c.bitmap)) copy(tmp, c.bitmap) c.bitmap = tmp @@ -1329,12 +1329,12 @@ func (c *Container) optimize() { } else if c.n < ArrayMaxSize { newType = containerArray } else { - newType = ContainerBitmap + newType = containerBitmap } // Then convert accordingly. if c.isArray() { - if newType == ContainerBitmap { + if newType == containerBitmap { c.arrayToBitmap() } else if newType == ContainerRun { c.arrayToRun() @@ -1346,7 +1346,7 @@ func (c *Container) optimize() { c.bitmapToRun() } } else if c.isRun() { - if newType == ContainerBitmap { + if newType == containerBitmap { c.runToBitmap() } else if newType == containerArray { c.runToArray() @@ -1510,7 +1510,7 @@ func (c *Container) bitmapToArray() { // arrayToBitmap converts from array format to bitmap format. func (c *Container) arrayToBitmap() { c.bitmap = make([]uint64, bitmapN) - c.containerType = ContainerBitmap + c.containerType = containerBitmap // return early if empty if c.n == 0 { @@ -1529,7 +1529,7 @@ func (c *Container) arrayToBitmap() { // runToBitmap converts from RLE format to bitmap format. func (c *Container) runToBitmap() { c.bitmap = make([]uint64, bitmapN) - c.containerType = ContainerBitmap + c.containerType = containerBitmap // return early if empty if c.n == 0 { @@ -1661,7 +1661,7 @@ func (c *Container) Clone() *Container { case containerArray: other.array = make([]uint16, len(c.array)) copy(other.array, c.array) - case ContainerBitmap: + case containerBitmap: other.bitmap = make([]uint64, len(c.bitmap)) copy(other.bitmap, c.bitmap) case ContainerRun: @@ -1816,7 +1816,7 @@ func flipArray(b *Container) *Container { } func flipBitmap(b *Container) *Container { - other := &Container{bitmap: make([]uint64, bitmapN), containerType: ContainerBitmap} + other := &Container{bitmap: make([]uint64, bitmapN), containerType: containerBitmap} for i, bitmap := range b.bitmap { other.bitmap[i] = ^bitmap @@ -2078,7 +2078,7 @@ func intersectBitmapRun(a, b *Container) *Container { // the bitmap which are between runs. output = &Container{ bitmap: make([]uint64, bitmapN), - containerType: ContainerBitmap, + containerType: containerBitmap, } for j := 0; j < len(b.runs); j++ { vb := b.runs[j] @@ -2134,7 +2134,7 @@ func intersectArrayBitmap(a, b *Container) *Container { } func intersectBitmapBitmap(a, b *Container) *Container { - output := &Container{bitmap: make([]uint64, bitmapN), containerType: ContainerBitmap} + output := &Container{bitmap: make([]uint64, bitmapN), containerType: containerBitmap} for i := range a.bitmap { v := a.bitmap[i] & b.bitmap[i] @@ -2396,7 +2396,7 @@ func (c *Container) equals(c2 *Container) bool { return false } } - } else if c.containerType == ContainerBitmap { + } else if c.containerType == containerBitmap { if len(c.bitmap) != len(c2.bitmap) { return false } @@ -2434,7 +2434,7 @@ func unionArrayBitmap(a, b *Container) *Container { func unionBitmapBitmap(a, b *Container) *Container { output := &Container{ bitmap: make([]uint64, bitmapN), - containerType: ContainerBitmap, + containerType: containerBitmap, } for i := 0; i < bitmapN; i++ { @@ -2778,7 +2778,7 @@ func differenceBitmapArray(a, b *Container) *Container { } func differenceBitmapBitmap(a, b *Container) *Container { - output := &Container{bitmap: make([]uint64, bitmapN), containerType: ContainerBitmap} + output := &Container{bitmap: make([]uint64, bitmapN), containerType: containerBitmap} for i := range a.bitmap { v := a.bitmap[i] & (^b.bitmap[i]) @@ -2861,7 +2861,7 @@ func xorArrayBitmap(a, b *Container) *Container { // It's possible that output was converted from bitmap to array in output.remove() // so we only do this conversion if output is still a bitmap container. - if output.containerType == ContainerBitmap && output.count() < ArrayMaxSize { + if output.containerType == containerBitmap && output.count() < ArrayMaxSize { output.bitmapToArray() } @@ -2871,7 +2871,7 @@ func xorArrayBitmap(a, b *Container) *Container { func xorBitmapBitmap(a, b *Container) *Container { output := &Container{ bitmap: make([]uint64, bitmapN), - containerType: ContainerBitmap, + containerType: containerBitmap, } for i := 0; i < bitmapN; i++ { v := a.bitmap[i] ^ b.bitmap[i] diff --git a/roaring/roaring_helpers_test.go b/roaring/roaring_helpers_test.go index 3ed42d8db..7d0265efa 100644 --- a/roaring/roaring_helpers_test.go +++ b/roaring/roaring_helpers_test.go @@ -238,7 +238,7 @@ func doContainer(containerType byte, data interface{}) *Container { switch containerType { case containerArray: c.array = data.([]uint16) - case ContainerBitmap: + case containerBitmap: c.bitmap = data.([]uint64) case ContainerRun: c.runs = data.([]interval16) @@ -267,17 +267,17 @@ func setupContainerTests() map[byte]map[string]*Container { } // bitmap containers - cts[ContainerBitmap] = map[string]*Container{ - "empty": doContainer(ContainerBitmap, bitmapEmpty()), - "full": doContainer(ContainerBitmap, bitmapFull()), - "firstBitSet": doContainer(ContainerBitmap, bitmapFirstBitSet()), - "lastBitSet": doContainer(ContainerBitmap, bitmapLastBitSet()), - "firstBitUnset": doContainer(ContainerBitmap, bitmapFirstBitUnset()), - "lastBitUnset": doContainer(ContainerBitmap, bitmapLastBitUnset()), - "innerBitsSet": doContainer(ContainerBitmap, bitmapInnerBitsSet()), - "outerBitsSet": doContainer(ContainerBitmap, bitmapOuterBitsSet()), - "oddBitsSet": doContainer(ContainerBitmap, bitmapOddBitsSet()), - "evenBitsSet": doContainer(ContainerBitmap, bitmapEvenBitsSet()), + cts[containerBitmap] = map[string]*Container{ + "empty": doContainer(containerBitmap, bitmapEmpty()), + "full": doContainer(containerBitmap, bitmapFull()), + "firstBitSet": doContainer(containerBitmap, bitmapFirstBitSet()), + "lastBitSet": doContainer(containerBitmap, bitmapLastBitSet()), + "firstBitUnset": doContainer(containerBitmap, bitmapFirstBitUnset()), + "lastBitUnset": doContainer(containerBitmap, bitmapLastBitUnset()), + "innerBitsSet": doContainer(containerBitmap, bitmapInnerBitsSet()), + "outerBitsSet": doContainer(containerBitmap, bitmapOuterBitsSet()), + "oddBitsSet": doContainer(containerBitmap, bitmapOddBitsSet()), + "evenBitsSet": doContainer(containerBitmap, bitmapEvenBitsSet()), } // run containers diff --git a/roaring/roaring_internal_test.go b/roaring/roaring_internal_test.go index c478c6209..dc2693b85 100644 --- a/roaring/roaring_internal_test.go +++ b/roaring/roaring_internal_test.go @@ -203,7 +203,7 @@ func TestRunContains(t *testing.T) { } func TestBitmapCountRange(t *testing.T) { - c := Container{containerType: ContainerBitmap} + c := Container{containerType: containerBitmap} tests := []struct { start int end int @@ -229,11 +229,11 @@ func TestBitmapCountRange(t *testing.T) { func TestIntersectionCountArrayBitmap3(t *testing.T) { a, b := &Container{}, &Container{} - a.containerType = ContainerBitmap + a.containerType = containerBitmap a.bitmap = getFullBitmap() a.n = maxContainerVal + 1 - b.containerType = ContainerBitmap + b.containerType = containerBitmap b.bitmap = getFullBitmap() b.n = maxContainerVal + 1 res := intersectBitmapBitmap(a, b) @@ -292,7 +292,7 @@ func TestIntersectionCountArrayBitmap2(t *testing.T) { a.array = test.array a.containerType = containerArray b.bitmap = test.bitmap - b.containerType = ContainerBitmap + b.containerType = containerBitmap ret := intersectionCountArrayBitmap(a, b) if ret != test.exp { t.Fatalf("test #%v intersectCountArrayBitmap fail received: %v exp: %v", i, ret, test.exp) @@ -359,7 +359,7 @@ func TestIntersectionCountArrayRun(t *testing.T) { } func TestIntersectionCountBitmapRun(t *testing.T) { - a := &Container{containerType: ContainerBitmap, bitmap: []uint64{0x8000000000000000}} + a := &Container{containerType: containerBitmap, bitmap: []uint64{0x8000000000000000}} b := &Container{containerType: ContainerRun, runs: []interval16{{start: 63, last: 64}}} ret := intersectionCountBitmapRun(a, b) @@ -367,7 +367,7 @@ func TestIntersectionCountBitmapRun(t *testing.T) { t.Fatalf("count of %v with %v should be 1, but got %v", a.bitmap, b.runs, ret) } - a = &Container{containerType: ContainerBitmap, bitmap: []uint64{0xF0000001, 0xFF00000000000000, 0xFF000000000000F0, 0x0F0000}} + a = &Container{containerType: containerBitmap, bitmap: []uint64{0xF0000001, 0xFF00000000000000, 0xFF000000000000F0, 0x0F0000}} b = &Container{containerType: ContainerRun, runs: []interval16{{start: 29, last: 31}, {start: 125, last: 134}, {start: 191, last: 197}, {start: 200, last: 300}}} ret = intersectionCountBitmapRun(a, b) @@ -581,7 +581,7 @@ func TestIntersectBitmapRunBitmap(t *testing.T) { for i, v := range test.exp { exp[i] = v } - a.containerType = ContainerBitmap + a.containerType = containerBitmap b.containerType = ContainerRun ret := intersectBitmapRun(a, b) if ret.isArray() { @@ -642,7 +642,7 @@ func TestIntersectBitmapRunArray(t *testing.T) { a.bitmap[i] = v } b.runs = test.runs - a.containerType = ContainerBitmap + a.containerType = containerBitmap b.containerType = ContainerRun ret := intersectBitmapRun(a, b) if !reflect.DeepEqual(ret.array, test.exp) { @@ -667,7 +667,7 @@ func TestUnionMixed(t *testing.T) { b := &Container{bitmap: make([]uint64, bitmapN)} b.bitmap[0] = uint64(0x3) b.n = 2 - b.containerType = ContainerBitmap + b.containerType = containerBitmap // run container r := &Container{} @@ -732,7 +732,7 @@ func TestIntersectMixed(t *testing.T) { } c.bitmap = []uint64{0x60} c.n = 2 - c.containerType = ContainerBitmap + c.containerType = containerBitmap res = intersect(c, a) if !reflect.DeepEqual(res.array, []uint16{5, 6}) { @@ -790,7 +790,7 @@ func TestDifferenceMixed(t *testing.T) { c.bitmap = []uint64{0x64} c.n = c.countRange(0, 100) - c.containerType = ContainerBitmap + c.containerType = containerBitmap res = difference(c, a) if !reflect.DeepEqual(res.bitmap, []uint64{0x4}) { t.Fatalf("test #4 expected %v, but got %v", []uint16{4}, res.bitmap) @@ -937,7 +937,7 @@ func TestUnionArrayRun(t *testing.T) { } func TestBitmapSetRange(t *testing.T) { - c := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} + c := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} tests := []struct { bitmap []uint64 start uint64 @@ -1008,7 +1008,7 @@ func TestArrayToBitmap(t *testing.T) { } func TestBitmapToArray(t *testing.T) { - a := &Container{containerType: ContainerBitmap} + a := &Container{containerType: containerBitmap} tests := []struct { bitmap []uint64 exp []uint16 @@ -1093,7 +1093,7 @@ func getFullBitmap() []uint64 { } func TestBitmapToRun(t *testing.T) { - a := &Container{containerType: ContainerBitmap} + a := &Container{containerType: containerBitmap} tests := []struct { bitmap []uint64 exp []interval16 @@ -1239,7 +1239,7 @@ func TestRunToArray(t *testing.T) { } func TestBitmapZeroRange(t *testing.T) { - c := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} + c := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} tests := []struct { bitmap []uint64 start uint64 @@ -1283,7 +1283,7 @@ func TestBitmapZeroRange(t *testing.T) { } func TestUnionBitmapRun(t *testing.T) { - a := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} + a := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} b := &Container{containerType: ContainerRun} tests := []struct { bitmap []uint64 @@ -1322,7 +1322,7 @@ func TestUnionBitmapRun(t *testing.T) { } func TestBitmapCountRuns(t *testing.T) { - c := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} + c := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} tests := []struct { bitmap []uint64 exp int @@ -1521,7 +1521,7 @@ func MakeLastBitSet() []uint64 { func TestDifferenceRunBitmap(t *testing.T) { a := &Container{containerType: ContainerRun} - b := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} + b := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} tests := []struct { runs []interval16 bitmap []uint64 @@ -1583,7 +1583,7 @@ func TestDifferenceRunBitmap(t *testing.T) { } func TestDifferenceBitmapRun(t *testing.T) { - a := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} + a := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} b := &Container{containerType: ContainerRun} tests := []struct { bitmap []uint64 @@ -1666,7 +1666,7 @@ func TestDifferenceBitmapRun(t *testing.T) { } func TestDifferenceBitmapArray(t *testing.T) { - b := &Container{containerType: ContainerBitmap, bitmap: make([]uint64, bitmapN)} + b := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} a := &Container{containerType: containerArray} tests := []struct { bitmap []uint64 @@ -1716,8 +1716,8 @@ func TestDifferenceBitmapArray(t *testing.T) { } func TestDifferenceBitmapBitmap(t *testing.T) { - a := &Container{bitmap: make([]uint64, bitmapN), containerType: ContainerBitmap} - b := &Container{bitmap: make([]uint64, bitmapN), containerType: ContainerBitmap} + a := &Container{bitmap: make([]uint64, bitmapN), containerType: containerBitmap} + b := &Container{bitmap: make([]uint64, bitmapN), containerType: containerBitmap} tests := []struct { abitmap []uint64 bbitmap []uint64 @@ -1800,7 +1800,7 @@ func TestWriteReadArray(t *testing.T) { func TestWriteReadBitmap(t *testing.T) { // create bitmap containing > 4096 bits - cb := &Container{bitmap: make([]uint64, bitmapN), n: 129 * 32, containerType: ContainerBitmap} + cb := &Container{bitmap: make([]uint64, bitmapN), n: 129 * 32, containerType: containerBitmap} for i := 0; i < 129; i++ { cb.bitmap[i] = 0x5555555555555555 } @@ -1823,7 +1823,7 @@ func TestWriteReadBitmap(t *testing.T) { func TestWriteReadFullBitmap(t *testing.T) { // create bitmap containing > 4096 bits - cb := &Container{bitmap: make([]uint64, bitmapN), n: 65536, containerType: ContainerBitmap} + cb := &Container{bitmap: make([]uint64, bitmapN), n: 65536, containerType: containerBitmap} for i := 0; i < bitmapN; i++ { cb.bitmap[i] = 0xffffffffffffffff } @@ -2025,7 +2025,7 @@ func TestXorRunRun(t *testing.T) { } func TestBitmapXorRange(t *testing.T) { - c := &Container{bitmap: make([]uint64, bitmapN), containerType: ContainerBitmap} + c := &Container{bitmap: make([]uint64, bitmapN), containerType: containerBitmap} tests := []struct { bitmap []uint64 start uint64 @@ -2093,7 +2093,7 @@ func TestBitmapXorRange(t *testing.T) { } func TestXorBitmapRun(t *testing.T) { - a := &Container{containerType: ContainerBitmap} + a := &Container{containerType: containerBitmap} b := &Container{containerType: ContainerRun} tests := []struct { bitmap []uint64 @@ -2547,7 +2547,7 @@ func TestSearch64(t *testing.T) { func TestIntersectArrayBitmap(t *testing.T) { a, b := &Container{containerType: containerArray}, &Container{ - containerType: ContainerBitmap, + containerType: containerBitmap, bitmap: make([]uint64, bitmapN), } tests := []struct { @@ -2598,7 +2598,7 @@ func TestIntersectArrayBitmap(t *testing.T) { for i, bmval := range test.bitmap { b.bitmap[i] = bmval } - b.containerType = ContainerBitmap + b.containerType = containerBitmap ret := intersectArrayBitmap(a, b).array if len(ret) == 0 && len(test.exp) == 0 { continue @@ -2722,12 +2722,12 @@ func TestContainerCombinations(t *testing.T) { cts := setupContainerTests() - containerTypes := []byte{containerArray, ContainerBitmap, ContainerRun} + containerTypes := []byte{containerArray, containerBitmap, ContainerRun} // map used for a more descriptive print cm := map[byte]string{ containerArray: "array", - ContainerBitmap: "bitmap", + containerBitmap: "bitmap", ContainerRun: "run", } @@ -3212,7 +3212,7 @@ func TestContainerCombinations(t *testing.T) { if !(len(clone.array) == 0 && len(cts[ct][exp].array) == 0) && !reflect.DeepEqual(clone.array, cts[ct][exp].array) { t.Fatalf("test %s expected array %X, but got %X", desc, cts[ct][exp].array, clone.array) } - } else if ct == ContainerBitmap { + } else if ct == containerBitmap { if clone.isArray() { clone.arrayToBitmap() } else if clone.isRun() { From bdd4fb51ef72de5416d58cb3fc1ada1554dac51a Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:27 -0500 Subject: [PATCH 116/138] Unexport roaring.ContainerInfo --- roaring/roaring.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index 3f048a544..3793af4a0 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -728,7 +728,7 @@ func (b *Bitmap) Iterator() *Iterator { func (b *Bitmap) Info() bitmapInfo { info := bitmapInfo{ OpN: b.opN, - Containers: make([]ContainerInfo, 0, b.Containers.Size()), + Containers: make([]containerInfo, 0, b.Containers.Size()), } citer, _ := b.Containers.Iterator(0) @@ -791,7 +791,7 @@ func (b *Bitmap) Flip(start, end uint64) *Bitmap { // bitmapInfo represents a point-in-time snapshot of bitmap stats. type bitmapInfo struct { OpN int - Containers []ContainerInfo + Containers []containerInfo } // Iterator represents an iterator over a Bitmap. @@ -1730,8 +1730,8 @@ func (c *Container) size() int { } // info returns the current stats about the container. -func (c *Container) info() ContainerInfo { - info := ContainerInfo{N: c.n} +func (c *Container) info() containerInfo { + info := containerInfo{N: c.n} if c.isArray() { info.Type = "array" @@ -1787,8 +1787,8 @@ func (c *Container) check() error { return a } -// ContainerInfo represents a point-in-time snapshot of container stats. -type ContainerInfo struct { +// containerInfo represents a point-in-time snapshot of container stats. +type containerInfo struct { Key uint64 // container key Type string // container type (array, bitmap, or run) N int // number of bits From 67cfe4dcee6c162fa37f7b2d2d7b4f2970f4603c Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:33 -0500 Subject: [PATCH 117/138] Unexport roaring.ContainerRun --- roaring/roaring.go | 40 +++++++------- roaring/roaring_helpers_test.go | 24 ++++----- roaring/roaring_internal_test.go | 90 ++++++++++++++++---------------- 3 files changed, 77 insertions(+), 77 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index 3793af4a0..ab4c1cabd 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -57,8 +57,8 @@ const ( //containerBitmap indicates a container of bits packed in a uint64 array block containerBitmap = byte(2) - //ContainerRun indicates a container of run encoded bits - ContainerRun = byte(3) + //containerRun indicates a container of run encoded bits + containerRun = byte(3) maxContainerVal = 0xffff ) @@ -657,7 +657,7 @@ func (b *Bitmap) UnmarshalBinary(data []byte) error { citer.Next() _, c := citer.Value() switch c.containerType { - case ContainerRun: + case containerRun: c.array = nil c.bitmap = nil runCount := binary.LittleEndian.Uint16(data[offset : offset+runCountHeaderSize]) @@ -1053,7 +1053,7 @@ func (c *Container) isBitmap() bool { // isRun returns true if the container is a run-length-encoded container. func (c *Container) isRun() bool { - return c.containerType == ContainerRun + return c.containerType == containerRun } // unmap creates copies of the containers data in the heap. @@ -1074,7 +1074,7 @@ func (c *Container) unmap() { tmp := make([]uint64, len(c.bitmap)) copy(tmp, c.bitmap) c.bitmap = tmp - case ContainerRun: + case containerRun: tmp := make([]interval16, len(c.runs)) copy(tmp, c.runs) c.runs = tmp @@ -1325,7 +1325,7 @@ func (c *Container) optimize() { var newType byte if runs <= RunMaxSize && runs <= c.n/2 { - newType = ContainerRun + newType = containerRun } else if c.n < ArrayMaxSize { newType = containerArray } else { @@ -1336,13 +1336,13 @@ func (c *Container) optimize() { if c.isArray() { if newType == containerBitmap { c.arrayToBitmap() - } else if newType == ContainerRun { + } else if newType == containerRun { c.arrayToRun() } } else if c.isBitmap() { if newType == containerArray { c.bitmapToArray() - } else if newType == ContainerRun { + } else if newType == containerRun { c.bitmapToRun() } } else if c.isRun() { @@ -1551,7 +1551,7 @@ func (c *Container) runToBitmap() { // bitmapToRun converts from bitmap format to RLE format. func (c *Container) bitmapToRun() { - c.containerType = ContainerRun + c.containerType = containerRun // return early if empty if c.n == 0 { c.runs = make([]interval16, 0) @@ -1607,7 +1607,7 @@ func (c *Container) bitmapToRun() { // arrayToRun converts from array format to RLE format. func (c *Container) arrayToRun() { - c.containerType = ContainerRun + c.containerType = containerRun // return early if empty if c.n == 0 { c.runs = make([]interval16, 0) @@ -1664,7 +1664,7 @@ func (c *Container) Clone() *Container { case containerBitmap: other.bitmap = make([]uint64, len(c.bitmap)) copy(other.bitmap, c.bitmap) - case ContainerRun: + case containerRun: other.runs = make([]interval16, len(c.runs)) copy(other.runs, c.runs) } @@ -2017,7 +2017,7 @@ func intersectArrayRun(a, b *Container) *Container { // intersectRunRun computes the intersect of two run containers. func intersectRunRun(a, b *Container) *Container { - output := &Container{containerType: ContainerRun} + output := &Container{containerType: containerRun} na, nb := len(a.runs), len(b.runs) for i, j := 0, 0; i < na && j < nb; { va, vb := a.runs[i], b.runs[j] @@ -2211,7 +2211,7 @@ func unionArrayRun(a, b *Container) *Container { if b.n == maxContainerVal+1 { return b.Clone() } - output := &Container{containerType: ContainerRun} + output := &Container{containerType: containerRun} na, nb := len(a.array), len(b.runs) var vb interval16 var va uint16 @@ -2274,7 +2274,7 @@ func unionRunRun(a, b *Container) *Container { na, nb := len(a.runs), len(b.runs) output := &Container{ runs: make([]interval16, 0, na+nb), - containerType: ContainerRun, + containerType: containerRun, } var va, vb interval16 for i, j := 0, 0; i < na || j < nb; { @@ -2405,7 +2405,7 @@ func (c *Container) equals(c2 *Container) bool { return false } } - } else if c.containerType == ContainerRun { + } else if c.containerType == containerRun { if len(c.runs) != len(c2.runs) { return false } @@ -2575,7 +2575,7 @@ func differenceRunArray(a, b *Container) *Container { if a.n == 0 || b.n == 0 { return a.Clone() } - output := &Container{runs: make([]interval16, 0, len(a.runs)), containerType: ContainerRun} + output := &Container{runs: make([]interval16, 0, len(a.runs)), containerType: containerRun} bidx := 0 vb := b.array[bidx] @@ -2631,7 +2631,7 @@ func differenceRunBitmap(a, b *Container) *Container { if len(a.runs) > 0 && a.runs[0].start == 0 && a.runs[0].last == 65535 { return flipBitmap(b) } - output := &Container{containerType: ContainerRun} + output := &Container{containerType: containerRun} output.n = a.n if len(a.runs) == 0 { return output @@ -2697,7 +2697,7 @@ func differenceRunRun(a, b *Container) *Container { alen := len(a.runs) blen := len(b.runs) - output := &Container{runs: make([]interval16, 0, alen+blen), containerType: ContainerRun} // TODO allocate max then truncate? or something else + output := &Container{runs: make([]interval16, 0, alen+blen), containerType: containerRun} // TODO allocate max then truncate? or something else // cardinality upper bound: sum of number of runs // each B-run could split an A-run in two, up to len(b.runs) times @@ -3079,7 +3079,7 @@ func (a *ErrorList) AppendWithPrefix(err error, prefix string) { // xorArrayRun computes the exclusive or of an array and a run container. func xorArrayRun(a, b *Container) *Container { - output := &Container{containerType: ContainerRun} + output := &Container{containerType: containerRun} na, nb := len(a.array), len(b.runs) var vb interval16 var va uint16 @@ -3248,7 +3248,7 @@ func xorRunRun(a, b *Container) *Container { if nb == 0 { return a.Clone() } - output := &Container{containerType: ContainerRun} + output := &Container{containerType: containerRun} lastI, lastJ := -1, -1 diff --git a/roaring/roaring_helpers_test.go b/roaring/roaring_helpers_test.go index 7d0265efa..cd22978fb 100644 --- a/roaring/roaring_helpers_test.go +++ b/roaring/roaring_helpers_test.go @@ -240,7 +240,7 @@ func doContainer(containerType byte, data interface{}) *Container { c.array = data.([]uint16) case containerBitmap: c.bitmap = data.([]uint64) - case ContainerRun: + case containerRun: c.runs = data.([]interval16) } c.n = c.count() @@ -281,17 +281,17 @@ func setupContainerTests() map[byte]map[string]*Container { } // run containers - cts[ContainerRun] = map[string]*Container{ - "empty": doContainer(ContainerRun, runEmpty()), - "full": doContainer(ContainerRun, runFull()), - "firstBitSet": doContainer(ContainerRun, runFirstBitSet()), - "lastBitSet": doContainer(ContainerRun, runLastBitSet()), - "firstBitUnset": doContainer(ContainerRun, runFirstBitUnset()), - "lastBitUnset": doContainer(ContainerRun, runLastBitUnset()), - "innerBitsSet": doContainer(ContainerRun, runInnerBitsSet()), - "outerBitsSet": doContainer(ContainerRun, runOuterBitsSet()), - "oddBitsSet": doContainer(ContainerRun, runOddBitsSet()), - "evenBitsSet": doContainer(ContainerRun, runEvenBitsSet()), + cts[containerRun] = map[string]*Container{ + "empty": doContainer(containerRun, runEmpty()), + "full": doContainer(containerRun, runFull()), + "firstBitSet": doContainer(containerRun, runFirstBitSet()), + "lastBitSet": doContainer(containerRun, runLastBitSet()), + "firstBitUnset": doContainer(containerRun, runFirstBitUnset()), + "lastBitUnset": doContainer(containerRun, runLastBitUnset()), + "innerBitsSet": doContainer(containerRun, runInnerBitsSet()), + "outerBitsSet": doContainer(containerRun, runOuterBitsSet()), + "oddBitsSet": doContainer(containerRun, runOddBitsSet()), + "evenBitsSet": doContainer(containerRun, runEvenBitsSet()), } return cts diff --git a/roaring/roaring_internal_test.go b/roaring/roaring_internal_test.go index dc2693b85..5836782b8 100644 --- a/roaring/roaring_internal_test.go +++ b/roaring/roaring_internal_test.go @@ -33,7 +33,7 @@ func (c *Container) String() string { } func TestRunAppendInterval(t *testing.T) { - a := Container{containerType: ContainerRun} + a := Container{containerType: containerRun} tests := []struct { base []interval16 app interval16 @@ -82,7 +82,7 @@ func TestInterval16RunLen(t *testing.T) { } func TestContainerRunAdd(t *testing.T) { - c := Container{runs: make([]interval16, 0), containerType: ContainerRun} + c := Container{runs: make([]interval16, 0), containerType: containerRun} tests := []struct { op uint16 exp []interval16 @@ -113,7 +113,7 @@ func TestContainerRunAdd(t *testing.T) { } func TestContainerRunAdd2(t *testing.T) { - c := Container{runs: make([]interval16, 0), containerType: ContainerRun} + c := Container{runs: make([]interval16, 0), containerType: containerRun} ret := c.add(0) if !ret { t.Fatalf("result of adding new bit should be true: %v", c.runs) @@ -128,7 +128,7 @@ func TestContainerRunAdd2(t *testing.T) { } func TestRunCountRange(t *testing.T) { - c := Container{runs: make([]interval16, 0), containerType: ContainerRun} + c := Container{runs: make([]interval16, 0), containerType: containerRun} cnt := c.runCountRange(2, 9) if cnt != 0 { t.Fatalf("should get 0 from empty container, but got: %v", cnt) @@ -181,7 +181,7 @@ func TestRunCountRange(t *testing.T) { } func TestRunContains(t *testing.T) { - c := Container{runs: make([]interval16, 0), containerType: ContainerRun} + c := Container{runs: make([]interval16, 0), containerType: containerRun} if c.runContains(5) { t.Fatalf("empty run container should not contain 5") } @@ -301,7 +301,7 @@ func TestIntersectionCountArrayBitmap2(t *testing.T) { } func TestRunRemove(t *testing.T) { - c := Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: ContainerRun} + c := Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: containerRun} tests := []struct { op uint16 exp []interval16 @@ -335,7 +335,7 @@ func TestRunRemove(t *testing.T) { } func TestRunMax(t *testing.T) { - c := Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: ContainerRun} + c := Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: containerRun} max := c.max() if max != 16 { t.Fatalf("max for %v should be 16", c.runs) @@ -350,7 +350,7 @@ func TestRunMax(t *testing.T) { func TestIntersectionCountArrayRun(t *testing.T) { a := &Container{containerType: containerArray, array: []uint16{1, 5, 10, 11, 12}} - b := &Container{containerType: ContainerRun, runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}} + b := &Container{containerType: containerRun, runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}} ret := intersectionCountArrayRun(a, b) if ret != 3 { @@ -360,7 +360,7 @@ func TestIntersectionCountArrayRun(t *testing.T) { func TestIntersectionCountBitmapRun(t *testing.T) { a := &Container{containerType: containerBitmap, bitmap: []uint64{0x8000000000000000}} - b := &Container{containerType: ContainerRun, runs: []interval16{{start: 63, last: 64}}} + b := &Container{containerType: containerRun, runs: []interval16{{start: 63, last: 64}}} ret := intersectionCountBitmapRun(a, b) if ret != 1 { @@ -368,7 +368,7 @@ func TestIntersectionCountBitmapRun(t *testing.T) { } a = &Container{containerType: containerBitmap, bitmap: []uint64{0xF0000001, 0xFF00000000000000, 0xFF000000000000F0, 0x0F0000}} - b = &Container{containerType: ContainerRun, runs: []interval16{{start: 29, last: 31}, {start: 125, last: 134}, {start: 191, last: 197}, {start: 200, last: 300}}} + b = &Container{containerType: containerRun, runs: []interval16{{start: 29, last: 31}, {start: 125, last: 134}, {start: 191, last: 197}, {start: 200, last: 300}}} ret = intersectionCountBitmapRun(a, b) if ret != 14 { @@ -416,8 +416,8 @@ func TestIntersectionCountRunRun(t *testing.T) { bruns: []interval16{{start: 9, last: 9}, {start: 11, last: 17}}, exp: 6}, } for i, test := range tests { - a.containerType = ContainerRun - b.containerType = ContainerRun + a.containerType = containerRun + b.containerType = containerRun a.runs = test.aruns b.runs = test.bruns ret := intersectionCountRunRun(a, b) @@ -459,7 +459,7 @@ func TestIntersectArrayRun(t *testing.T) { for i, test := range tests { a.containerType = containerArray - b.containerType = ContainerRun + b.containerType = containerRun a.array = test.array b.runs = test.runs ret := intersectArrayRun(a, b) @@ -516,8 +516,8 @@ func TestIntersectRunRun(t *testing.T) { }, } for i, test := range tests { - a.containerType = ContainerRun - b.containerType = ContainerRun + a.containerType = containerRun + b.containerType = containerRun a.runs = test.aruns b.runs = test.bruns ret := intersectRunRun(a, b) @@ -582,7 +582,7 @@ func TestIntersectBitmapRunBitmap(t *testing.T) { exp[i] = v } a.containerType = containerBitmap - b.containerType = ContainerRun + b.containerType = containerRun ret := intersectBitmapRun(a, b) if ret.isArray() { ret.arrayToBitmap() @@ -643,7 +643,7 @@ func TestIntersectBitmapRunArray(t *testing.T) { } b.runs = test.runs a.containerType = containerBitmap - b.containerType = ContainerRun + b.containerType = containerRun ret := intersectBitmapRun(a, b) if !reflect.DeepEqual(ret.array, test.exp) { t.Fatalf("test #%v expected %v, but got %v", i, test.exp, ret.array) @@ -672,7 +672,7 @@ func TestUnionMixed(t *testing.T) { // run container r := &Container{} r.runs = []interval16{{start: 5, last: 10}} - r.containerType = ContainerRun + r.containerType = containerRun r.n = 6 t.Run("various container Unions", func(t *testing.T) { @@ -713,7 +713,7 @@ func TestIntersectMixed(t *testing.T) { a.runs = []interval16{{start: 5, last: 10}} a.n = 6 - a.containerType = ContainerRun + a.containerType = containerRun b.array = []uint16{1, 4, 5, 7, 10, 11, 12} b.n = 7 b.containerType = containerArray @@ -762,7 +762,7 @@ func TestDifferenceMixed(t *testing.T) { a.runs = []interval16{{start: 5, last: 10}} a.n = a.runCountRange(0, 100) - a.containerType = ContainerRun + a.containerType = containerRun b.array = []uint16{0, 2, 4, 6, 8, 10, 12} b.n = len(b.array) @@ -885,8 +885,8 @@ func TestUnionRunRun(t *testing.T) { for i, test := range tests { a.runs = test.aruns b.runs = test.bruns - a.containerType = ContainerRun - b.containerType = ContainerRun + a.containerType = containerRun + b.containerType = containerRun ret := unionRunRun(a, b) if !reflect.DeepEqual(ret.runs, test.exp) { t.Fatalf("test #%v expected %v, but got %v", i, test.exp, ret.runs) @@ -928,7 +928,7 @@ func TestUnionArrayRun(t *testing.T) { a.array = test.array b.runs = test.runs a.containerType = containerArray - b.containerType = ContainerRun + b.containerType = containerRun ret := unionArrayRun(a, b) if !reflect.DeepEqual(ret.array, test.exp) { t.Fatalf("test #%v expected %v, but got %v", i, test.exp, ret.array) @@ -1039,7 +1039,7 @@ func TestBitmapToArray(t *testing.T) { } func TestRunToBitmap(t *testing.T) { - a := &Container{containerType: ContainerRun} + a := &Container{containerType: containerRun} tests := []struct { runs []interval16 exp []uint64 @@ -1205,7 +1205,7 @@ func TestArrayToRun(t *testing.T) { } func TestRunToArray(t *testing.T) { - a := &Container{containerType: ContainerRun} + a := &Container{containerType: containerRun} tests := []struct { runs []interval16 exp []uint16 @@ -1284,7 +1284,7 @@ func TestBitmapZeroRange(t *testing.T) { func TestUnionBitmapRun(t *testing.T) { a := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} - b := &Container{containerType: ContainerRun} + b := &Container{containerType: containerRun} tests := []struct { bitmap []uint64 runs []interval16 @@ -1414,7 +1414,7 @@ func TestArrayCountRuns(t *testing.T) { func TestDifferenceArrayRun(t *testing.T) { a := &Container{containerType: containerArray} - b := &Container{containerType: ContainerRun} + b := &Container{containerType: containerRun} tests := []struct { array []uint16 runs []interval16 @@ -1439,7 +1439,7 @@ func TestDifferenceArrayRun(t *testing.T) { } func TestDifferenceRunArray(t *testing.T) { - a := &Container{containerType: ContainerRun} + a := &Container{containerType: containerRun} b := &Container{containerType: containerArray} tests := []struct { runs []interval16 @@ -1520,7 +1520,7 @@ func MakeLastBitSet() []uint64 { } func TestDifferenceRunBitmap(t *testing.T) { - a := &Container{containerType: ContainerRun} + a := &Container{containerType: containerRun} b := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} tests := []struct { runs []interval16 @@ -1584,7 +1584,7 @@ func TestDifferenceRunBitmap(t *testing.T) { func TestDifferenceBitmapRun(t *testing.T) { a := &Container{containerType: containerBitmap, bitmap: make([]uint64, bitmapN)} - b := &Container{containerType: ContainerRun} + b := &Container{containerType: containerRun} tests := []struct { bitmap []uint64 runs []interval16 @@ -1746,8 +1746,8 @@ func TestDifferenceBitmapBitmap(t *testing.T) { } func TestDifferenceRunRun(t *testing.T) { - a := &Container{containerType: ContainerRun} - b := &Container{containerType: ContainerRun} + a := &Container{containerType: containerRun} + b := &Container{containerType: containerRun} tests := []struct { aruns []interval16 bruns []interval16 @@ -1852,7 +1852,7 @@ func TestWriteReadFullBitmap(t *testing.T) { } func TestWriteReadRun(t *testing.T) { - cr := &Container{runs: []interval16{{start: 3, last: 13}, {start: 100, last: 109}}, n: 21, containerType: ContainerRun} + cr := &Container{runs: []interval16{{start: 3, last: 13}, {start: 100, last: 109}}, n: 21, containerType: containerRun} br := NewFileBitmap() br.Containers.Put(0, cr) br2 := NewFileBitmap() @@ -1878,19 +1878,19 @@ func TestXorArrayRun(t *testing.T) { }{ { a: &Container{array: []uint16{1, 5, 10, 11, 12}, containerType: containerArray}, - b: &Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: ContainerRun}, + b: &Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: containerRun}, exp: &Container{array: []uint16{1, 2, 3, 4, 6, 7, 8, 9, 11, 13, 15, 16}, containerType: containerArray, n: 12}, }, { a: &Container{array: []uint16{1, 5, 10, 11, 12, 13, 14}, containerType: containerArray}, - b: &Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: ContainerRun}, + b: &Container{runs: []interval16{{start: 2, last: 10}, {start: 12, last: 13}, {start: 15, last: 16}}, containerType: containerRun}, exp: &Container{array: []uint16{1, 2, 3, 4, 6, 7, 8, 9, 11, 14, 15, 16}, containerType: containerArray, n: 12}, }, { a: &Container{array: []uint16{65535}, containerType: containerArray}, - b: &Container{runs: []interval16{{start: 65534, last: 65535}}, containerType: ContainerRun}, + b: &Container{runs: []interval16{{start: 65534, last: 65535}}, containerType: containerRun}, exp: &Container{array: []uint16{65534}, containerType: containerArray, n: 1}, }, { a: &Container{array: []uint16{65535}, containerType: containerArray}, - b: &Container{runs: []interval16{{start: 65535, last: 65535}}, containerType: ContainerRun}, + b: &Container{runs: []interval16{{start: 65535, last: 65535}}, containerType: containerRun}, exp: &Container{array: []uint16{}, containerType: containerArray, n: 0}, }, } @@ -1912,8 +1912,8 @@ func TestXorArrayRun(t *testing.T) { //special case that didn't fit the xorrunrun table testing below. func TestXorRunRun1(t *testing.T) { - a := &Container{containerType: ContainerRun} - b := &Container{containerType: ContainerRun} + a := &Container{containerType: containerRun} + b := &Container{containerType: containerRun} a.runs = []interval16{{start: 4, last: 10}} b.runs = []interval16{{start: 5, last: 10}} ret := xorRunRun(a, b) @@ -1927,8 +1927,8 @@ func TestXorRunRun1(t *testing.T) { } func TestXorRunRun(t *testing.T) { - a := &Container{containerType: ContainerRun} - b := &Container{containerType: ContainerRun} + a := &Container{containerType: containerRun} + b := &Container{containerType: containerRun} tests := []struct { aruns []interval16 bruns []interval16 @@ -2094,7 +2094,7 @@ func TestBitmapXorRange(t *testing.T) { func TestXorBitmapRun(t *testing.T) { a := &Container{containerType: containerBitmap} - b := &Container{containerType: ContainerRun} + b := &Container{containerType: containerRun} tests := []struct { bitmap []uint64 runs []interval16 @@ -2722,13 +2722,13 @@ func TestContainerCombinations(t *testing.T) { cts := setupContainerTests() - containerTypes := []byte{containerArray, containerBitmap, ContainerRun} + containerTypes := []byte{containerArray, containerBitmap, containerRun} // map used for a more descriptive print cm := map[byte]string{ containerArray: "array", containerBitmap: "bitmap", - ContainerRun: "run", + containerRun: "run", } testOps := []testOp{ @@ -3224,7 +3224,7 @@ func TestContainerCombinations(t *testing.T) { if !reflect.DeepEqual(clone.bitmap, cts[ct][exp].bitmap) { t.Fatalf("test %s expected bitmap %X, but got %X", desc, cts[ct][exp].bitmap, clone.bitmap) } - } else if ct == ContainerRun { + } else if ct == containerRun { if clone.isArray() { clone.arrayToRun() } else if clone.isBitmap() { From 5ec9d3af222f220c4e85e2b9f8a789339408eab2 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:39 -0500 Subject: [PATCH 118/138] Unexport roaring.NewSliceContainers --- roaring/containers.go | 4 ++-- roaring/roaring.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/roaring/containers.go b/roaring/containers.go index 19871050b..a993ebfdb 100644 --- a/roaring/containers.go +++ b/roaring/containers.go @@ -21,7 +21,7 @@ type SliceContainers struct { lastContainer *Container } -func NewSliceContainers() *SliceContainers { +func newSliceContainers() *SliceContainers { return &SliceContainers{} } @@ -102,7 +102,7 @@ func (sc *SliceContainers) GetOrCreate(key uint64) *Container { } func (sc *SliceContainers) Clone() Containers { - other := NewSliceContainers() + other := newSliceContainers() other.keys = make([]uint64, len(sc.keys)) other.containers = make([]*Container, len(sc.containers)) copy(other.keys, sc.keys) diff --git a/roaring/roaring.go b/roaring/roaring.go index ab4c1cabd..c15b965e1 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -117,7 +117,7 @@ type Bitmap struct { // NewBitmap returns a Bitmap with an initial set of values. func NewBitmap(a ...uint64) *Bitmap { b := &Bitmap{ - Containers: NewSliceContainers(), + Containers: newSliceContainers(), } b.Add(a...) return b From 89c28043dd078133240d8d500af2258a72866998 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:46 -0500 Subject: [PATCH 119/138] Unexport roaring.RunMaxSize --- roaring/roaring.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/roaring/roaring.go b/roaring/roaring.go index c15b965e1..2544c5007 100644 --- a/roaring/roaring.go +++ b/roaring/roaring.go @@ -987,8 +987,8 @@ func (itr *Iterator) peek() uint64 { // ArrayMaxSize represents the maximum size of array containers. const ArrayMaxSize = 4096 -// RunMaxSize represents the maximum size of run length encoded containers. -const RunMaxSize = 2048 +// runMaxSize represents the maximum size of run length encoded containers. +const runMaxSize = 2048 // Container represents a Container for uint16 integers. // @@ -1324,7 +1324,7 @@ func (c *Container) optimize() { runs := c.countRuns() var newType byte - if runs <= RunMaxSize && runs <= c.n/2 { + if runs <= runMaxSize && runs <= c.n/2 { newType = containerRun } else if c.n < ArrayMaxSize { newType = containerArray @@ -2047,7 +2047,7 @@ func intersectRunRun(a, b *Container) *Container { } if output.n < ArrayMaxSize && len(output.runs) > output.n/2 { output.runToArray() - } else if len(output.runs) > RunMaxSize { + } else if len(output.runs) > runMaxSize { output.runToBitmap() } return output @@ -2232,7 +2232,7 @@ func unionArrayRun(a, b *Container) *Container { } if output.n < ArrayMaxSize { output.runToArray() - } else if len(output.runs) > RunMaxSize { + } else if len(output.runs) > runMaxSize { output.runToBitmap() } return output @@ -2292,7 +2292,7 @@ func unionRunRun(a, b *Container) *Container { j++ } } - if len(output.runs) > RunMaxSize { + if len(output.runs) > runMaxSize { output.runToBitmap() } return output @@ -2676,7 +2676,7 @@ func differenceRunBitmap(a, b *Container) *Container { if output.n < ArrayMaxSize && len(output.runs) > output.n/2 { output.runToArray() - } else if len(output.runs) > RunMaxSize { + } else if len(output.runs) > runMaxSize { output.runToBitmap() } return output @@ -3135,7 +3135,7 @@ func xorArrayRun(a, b *Container) *Container { } if output.n < ArrayMaxSize { output.runToArray() - } else if len(output.runs) > RunMaxSize { + } else if len(output.runs) > runMaxSize { output.runToBitmap() } return output @@ -3281,7 +3281,7 @@ func xorRunRun(a, b *Container) *Container { if output.n < ArrayMaxSize && len(output.runs) > output.n/2 { output.runToArray() - } else if len(output.runs) > RunMaxSize { + } else if len(output.runs) > runMaxSize { output.runToBitmap() } return output @@ -3296,7 +3296,7 @@ func xorBitmapRun(a, b *Container) *Container { if output.n < ArrayMaxSize && len(output.runs) > output.n/2 { output.runToArray() - } else if len(output.runs) > RunMaxSize { + } else if len(output.runs) > runMaxSize { output.runToBitmap() } return output From c134535229e87bd8d20796d769053fddc97a5450 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:52 -0500 Subject: [PATCH 120/138] Unexport roaring.SliceContainers --- roaring/containers.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/roaring/containers.go b/roaring/containers.go index a993ebfdb..8cdddf607 100644 --- a/roaring/containers.go +++ b/roaring/containers.go @@ -14,18 +14,18 @@ package roaring -type SliceContainers struct { +type sliceContainers struct { keys []uint64 containers []*Container lastKey uint64 lastContainer *Container } -func newSliceContainers() *SliceContainers { - return &SliceContainers{} +func newSliceContainers() *sliceContainers { + return &sliceContainers{} } -func (sc *SliceContainers) Get(key uint64) *Container { +func (sc *sliceContainers) Get(key uint64) *Container { i := search64(sc.keys, key) if i < 0 { return nil @@ -33,7 +33,7 @@ func (sc *SliceContainers) Get(key uint64) *Container { return sc.containers[i] } -func (sc *SliceContainers) Put(key uint64, c *Container) { +func (sc *sliceContainers) Put(key uint64, c *Container) { i := search64(sc.keys, key) // If index is negative then there's not an exact match @@ -46,7 +46,7 @@ func (sc *SliceContainers) Put(key uint64, c *Container) { } -func (sc *SliceContainers) PutContainerValues(key uint64, containerType byte, n int, mapped bool) { +func (sc *sliceContainers) PutContainerValues(key uint64, containerType byte, n int, mapped bool) { i := search64(sc.keys, key) if i < 0 { c := NewContainer() @@ -63,7 +63,7 @@ func (sc *SliceContainers) PutContainerValues(key uint64, containerType byte, n } -func (sc *SliceContainers) Remove(key uint64) { +func (sc *sliceContainers) Remove(key uint64) { i := search64(sc.keys, key) if i < 0 { return @@ -72,7 +72,7 @@ func (sc *SliceContainers) Remove(key uint64) { sc.containers = append(sc.containers[:i], sc.containers[i+1:]...) } -func (sc *SliceContainers) insertAt(key uint64, c *Container, i int) { +func (sc *sliceContainers) insertAt(key uint64, c *Container, i int) { sc.keys = append(sc.keys, 0) copy(sc.keys[i+1:], sc.keys[i:]) sc.keys[i] = key @@ -82,7 +82,7 @@ func (sc *SliceContainers) insertAt(key uint64, c *Container, i int) { sc.containers[i] = c } -func (sc *SliceContainers) GetOrCreate(key uint64) *Container { +func (sc *sliceContainers) GetOrCreate(key uint64) *Container { // Check the last* cache for same container. if key == sc.lastKey && sc.lastContainer != nil { return sc.lastContainer @@ -101,7 +101,7 @@ func (sc *SliceContainers) GetOrCreate(key uint64) *Container { return sc.lastContainer } -func (sc *SliceContainers) Clone() Containers { +func (sc *sliceContainers) Clone() Containers { other := newSliceContainers() other.keys = make([]uint64, len(sc.keys)) other.containers = make([]*Container, len(sc.containers)) @@ -112,19 +112,19 @@ func (sc *SliceContainers) Clone() Containers { return other } -func (sc *SliceContainers) Last() (key uint64, c *Container) { +func (sc *sliceContainers) Last() (key uint64, c *Container) { if len(sc.keys) == 0 { return 0, nil } return sc.keys[len(sc.keys)-1], sc.containers[len(sc.keys)-1] } -func (sc *SliceContainers) Size() int { +func (sc *sliceContainers) Size() int { return len(sc.keys) } -func (sc *SliceContainers) Count() uint64 { +func (sc *sliceContainers) Count() uint64 { n := uint64(0) for i := range sc.containers { n += uint64(sc.containers[i].n) @@ -132,14 +132,14 @@ func (sc *SliceContainers) Count() uint64 { return n } -func (sc *SliceContainers) Reset() { +func (sc *sliceContainers) Reset() { sc.keys = sc.keys[:0] sc.containers = sc.containers[:0] sc.lastContainer = nil sc.lastKey = 0 } -func (sc *SliceContainers) seek(key uint64) (int, bool) { +func (sc *sliceContainers) seek(key uint64) (int, bool) { i := search64(sc.keys, key) found := true if i < 0 { @@ -149,13 +149,13 @@ func (sc *SliceContainers) seek(key uint64) (int, bool) { return i, found } -func (sc *SliceContainers) Iterator(key uint64) (citer ContainerIterator, found bool) { +func (sc *sliceContainers) Iterator(key uint64) (citer ContainerIterator, found bool) { i, found := sc.seek(key) return &SliceIterator{e: sc, i: i}, found } type SliceIterator struct { - e *SliceContainers + e *sliceContainers i int key uint64 value *Container From 31cab33fbe1db68e096f655c657f096d7d447172 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:02:57 -0500 Subject: [PATCH 121/138] Unexport roaring.SliceIterator --- roaring/containers.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roaring/containers.go b/roaring/containers.go index 8cdddf607..5275d4f04 100644 --- a/roaring/containers.go +++ b/roaring/containers.go @@ -151,17 +151,17 @@ func (sc *sliceContainers) seek(key uint64) (int, bool) { func (sc *sliceContainers) Iterator(key uint64) (citer ContainerIterator, found bool) { i, found := sc.seek(key) - return &SliceIterator{e: sc, i: i}, found + return &sliceIterator{e: sc, i: i}, found } -type SliceIterator struct { +type sliceIterator struct { e *sliceContainers i int key uint64 value *Container } -func (si *SliceIterator) Next() bool { +func (si *sliceIterator) Next() bool { if si.e == nil || si.i > len(si.e.keys)-1 { return false } @@ -172,6 +172,6 @@ func (si *SliceIterator) Next() bool { return true } -func (si *SliceIterator) Value() (uint64, *Container) { +func (si *sliceIterator) Value() (uint64, *Container) { return si.key, si.value } From 6023474ed4a8f18c670b0cfc23762cdf7a271240 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:05 -0500 Subject: [PATCH 122/138] Unexport server.Command.SetupNetworking --- server/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/server.go b/server/server.go index 401da09e8..3c91c9fb2 100644 --- a/server/server.go +++ b/server/server.go @@ -124,7 +124,7 @@ func (m *Command) Start() (err error) { } // SetupNetworking - err = m.SetupNetworking() + err = m.setupNetworking() if err != nil { return errors.Wrap(err, "setting up networking") } @@ -299,8 +299,8 @@ func (m *Command) SetupServer() error { } -// SetupNetworking sets up internode communication based on the configuration. -func (m *Command) SetupNetworking() error { +// setupNetworking sets up internode communication based on the configuration. +func (m *Command) setupNetworking() error { if m.Config.Cluster.Disabled { return nil } From 94e633b7eb53ac4363a538a905a0251524cdc77f Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:10 -0500 Subject: [PATCH 123/138] Unexport server.DefaultDiagnosticsInterval --- server/default.go | 4 ++-- server/server.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/default.go b/server/default.go index a7131c82a..ce2fe8aaa 100644 --- a/server/default.go +++ b/server/default.go @@ -20,5 +20,5 @@ package server import "time" -// DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics. A value of 0 disables diagnostics. -const DefaultDiagnosticsInterval = time.Duration(0) +// defaultDiagnosticsInterval is the default sync frequency diagnostic metrics. A value of 0 disables diagnostics. +const defaultDiagnosticsInterval = time.Duration(0) diff --git a/server/server.go b/server/server.go index 3c91c9fb2..76414dec4 100644 --- a/server/server.go +++ b/server/server.go @@ -222,7 +222,7 @@ func (m *Command) SetupServer() error { diagnosticsInterval := time.Duration(0) if m.Config.Metric.Diagnostics { - diagnosticsInterval = time.Duration(DefaultDiagnosticsInterval) + diagnosticsInterval = time.Duration(defaultDiagnosticsInterval) } statsClient, err := NewStatsClient(m.Config.Metric.Service, m.Config.Metric.Host) From 167e41787fcd28bdf15f3a672a25a043fbd76175 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:16 -0500 Subject: [PATCH 124/138] Unexport server.NewStatsClient --- server/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/server.go b/server/server.go index 76414dec4..d71139096 100644 --- a/server/server.go +++ b/server/server.go @@ -225,7 +225,7 @@ func (m *Command) SetupServer() error { diagnosticsInterval = time.Duration(defaultDiagnosticsInterval) } - statsClient, err := NewStatsClient(m.Config.Metric.Service, m.Config.Metric.Host) + statsClient, err := newStatsClient(m.Config.Metric.Service, m.Config.Metric.Host) if err != nil { return errors.Wrap(err, "new stats client") } @@ -351,8 +351,8 @@ func (m *Command) Close() error { return nil } -// NewStatsClient creates a stats client from the config -func NewStatsClient(name string, host string) (pilosa.StatsClient, error) { +// newStatsClient creates a stats client from the config +func newStatsClient(name string, host string) (pilosa.StatsClient, error) { switch name { case "expvar": return pilosa.NewExpvarStatsClient(), nil From 989cc55ece4eaf3d10b2f36c7bb042c5693b2865 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:22 -0500 Subject: [PATCH 125/138] Unexport statsd.BufferLen --- statsd/statsd.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/statsd/statsd.go b/statsd/statsd.go index 81cfbb2b4..0bb369fac 100644 --- a/statsd/statsd.go +++ b/statsd/statsd.go @@ -29,8 +29,8 @@ const ( // Prefix is appended to each metric event name Prefix = "pilosa." - // BufferLen Stats lient buffer size. - BufferLen = 1024 + // bufferLen Stats lient buffer size. + bufferLen = 1024 ) // Ensure client implements interface. @@ -45,7 +45,7 @@ type StatsClient struct { // NewStatsClient returns a new instance of StatsClient. func NewStatsClient(host string) (*StatsClient, error) { - c, err := statsd.NewBuffered(host, BufferLen) + c, err := statsd.NewBuffered(host, bufferLen) if err != nil { return nil, err } From 8aa24e2c389c836c959d035544e5d7e1390c81d3 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:28 -0500 Subject: [PATCH 126/138] Unexport statsd.Prefix --- statsd/statsd.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/statsd/statsd.go b/statsd/statsd.go index 0bb369fac..232404a54 100644 --- a/statsd/statsd.go +++ b/statsd/statsd.go @@ -26,8 +26,8 @@ import ( // statsD defailt host is "127.0.0.1:8125" const ( - // Prefix is appended to each metric event name - Prefix = "pilosa." + // prefix is appended to each metric event name + prefix = "pilosa." // bufferLen Stats lient buffer size. bufferLen = 1024 @@ -80,7 +80,7 @@ func (c *StatsClient) WithTags(tags ...string) pilosa.StatsClient { // Count tracks the number of times something occurs per second. func (c *StatsClient) Count(name string, value int64, rate float64) { - if err := c.client.Count(Prefix+name, value, c.tags, rate); err != nil { + if err := c.client.Count(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Count error: %s", err) } } @@ -88,35 +88,35 @@ func (c *StatsClient) Count(name string, value int64, rate float64) { // CountWithCustomTags tracks the number of times something occurs per second with custom tags. func (c *StatsClient) CountWithCustomTags(name string, value int64, rate float64, t []string) { tags := append(c.tags, t...) - if err := c.client.Count(Prefix+name, value, tags, rate); err != nil { + if err := c.client.Count(prefix+name, value, tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Count error: %s", err) } } // Gauge sets the value of a metric. func (c *StatsClient) Gauge(name string, value float64, rate float64) { - if err := c.client.Gauge(Prefix+name, value, c.tags, rate); err != nil { + if err := c.client.Gauge(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Gauge error: %s", err) } } // Histogram tracks statistical distribution of a metric. func (c *StatsClient) Histogram(name string, value float64, rate float64) { - if err := c.client.Histogram(Prefix+name, value, c.tags, rate); err != nil { + if err := c.client.Histogram(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Histogram error: %s", err) } } // Set tracks number of unique elements. func (c *StatsClient) Set(name string, value string, rate float64) { - if err := c.client.Set(Prefix+name, value, c.tags, rate); err != nil { + if err := c.client.Set(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Set error: %s", err) } } // Timing tracks timing information for a metric. func (c *StatsClient) Timing(name string, value time.Duration, rate float64) { - if err := c.client.Timing(Prefix+name, value, c.tags, rate); err != nil { + if err := c.client.Timing(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Timing error: %s", err) } } From 9236df38e9d350743d703bec5a1447723bfae25e Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:34 -0500 Subject: [PATCH 127/138] Unexport statsd.StatsClient --- statsd/statsd.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/statsd/statsd.go b/statsd/statsd.go index 232404a54..7a9ae6c14 100644 --- a/statsd/statsd.go +++ b/statsd/statsd.go @@ -34,44 +34,44 @@ const ( ) // Ensure client implements interface. -var _ pilosa.StatsClient = &StatsClient{} +var _ pilosa.StatsClient = &statsClient{} -// StatsClient represents a StatsD implementation of pilosa.StatsClient. -type StatsClient struct { +// statsClient represents a StatsD implementation of pilosa.statsClient. +type statsClient struct { client *statsd.Client tags []string logger pilosa.Logger } // NewStatsClient returns a new instance of StatsClient. -func NewStatsClient(host string) (*StatsClient, error) { +func NewStatsClient(host string) (*statsClient, error) { c, err := statsd.NewBuffered(host, bufferLen) if err != nil { return nil, err } - return &StatsClient{ + return &statsClient{ client: c, logger: pilosa.NopLogger, }, nil } // Open no-op -func (c *StatsClient) Open() {} +func (c *statsClient) Open() {} // Close closes the connection to the agent. -func (c *StatsClient) Close() error { +func (c *statsClient) Close() error { return c.client.Close() } // Tags returns a sorted list of tags on the client. -func (c *StatsClient) Tags() []string { +func (c *statsClient) Tags() []string { return c.tags } // WithTags returns a new client with additional tags appended. -func (c *StatsClient) WithTags(tags ...string) pilosa.StatsClient { - return &StatsClient{ +func (c *statsClient) WithTags(tags ...string) pilosa.StatsClient { + return &statsClient{ client: c.client, tags: unionStringSlice(c.tags, tags), logger: c.logger, @@ -79,14 +79,14 @@ func (c *StatsClient) WithTags(tags ...string) pilosa.StatsClient { } // Count tracks the number of times something occurs per second. -func (c *StatsClient) Count(name string, value int64, rate float64) { +func (c *statsClient) Count(name string, value int64, rate float64) { if err := c.client.Count(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Count error: %s", err) } } // CountWithCustomTags tracks the number of times something occurs per second with custom tags. -func (c *StatsClient) CountWithCustomTags(name string, value int64, rate float64, t []string) { +func (c *statsClient) CountWithCustomTags(name string, value int64, rate float64, t []string) { tags := append(c.tags, t...) if err := c.client.Count(prefix+name, value, tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Count error: %s", err) @@ -94,35 +94,35 @@ func (c *StatsClient) CountWithCustomTags(name string, value int64, rate float64 } // Gauge sets the value of a metric. -func (c *StatsClient) Gauge(name string, value float64, rate float64) { +func (c *statsClient) Gauge(name string, value float64, rate float64) { if err := c.client.Gauge(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Gauge error: %s", err) } } // Histogram tracks statistical distribution of a metric. -func (c *StatsClient) Histogram(name string, value float64, rate float64) { +func (c *statsClient) Histogram(name string, value float64, rate float64) { if err := c.client.Histogram(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Histogram error: %s", err) } } // Set tracks number of unique elements. -func (c *StatsClient) Set(name string, value string, rate float64) { +func (c *statsClient) Set(name string, value string, rate float64) { if err := c.client.Set(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Set error: %s", err) } } // Timing tracks timing information for a metric. -func (c *StatsClient) Timing(name string, value time.Duration, rate float64) { +func (c *statsClient) Timing(name string, value time.Duration, rate float64) { if err := c.client.Timing(prefix+name, value, c.tags, rate); err != nil { c.logger.Printf("statsd.StatsClient.Timing error: %s", err) } } // SetLogger sets the logger for client. -func (c *StatsClient) SetLogger(logger pilosa.Logger) { +func (c *statsClient) SetLogger(logger pilosa.Logger) { c.logger = logger } From 66df2cf126cb584014ce82345dbe7d24cbfd4403 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:40 -0500 Subject: [PATCH 128/138] Unexport test.BufferLogger --- test/logger.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/logger.go b/test/logger.go index b4a0079b1..60af32acb 100644 --- a/test/logger.go +++ b/test/logger.go @@ -20,20 +20,20 @@ import ( "io/ioutil" ) -// BufferLogger represents a test Logger that holds log messages +// bufferLogger represents a test Logger that holds log messages // in a buffer for review. -type BufferLogger struct { +type bufferLogger struct { buf *bytes.Buffer } // NewBufferLogger returns a new instance of BufferLogger. -func NewBufferLogger() *BufferLogger { - return &BufferLogger{ +func NewBufferLogger() *bufferLogger { + return &bufferLogger{ buf: &bytes.Buffer{}, } } -func (b *BufferLogger) Printf(format string, v ...interface{}) { +func (b *bufferLogger) Printf(format string, v ...interface{}) { s := fmt.Sprintf(format, v...) _, err := b.buf.WriteString(s) if err != nil { @@ -41,8 +41,8 @@ func (b *BufferLogger) Printf(format string, v ...interface{}) { } } -func (b *BufferLogger) Debugf(format string, v ...interface{}) {} +func (b *bufferLogger) Debugf(format string, v ...interface{}) {} -func (b *BufferLogger) ReadAll() ([]byte, error) { +func (b *bufferLogger) ReadAll() ([]byte, error) { return ioutil.ReadAll(b.buf) } From 3aa759bff799446a54adfa75022e2085731c1a74 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:46 -0500 Subject: [PATCH 129/138] Unexport test.Command.Stdin --- test/pilosa.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pilosa.go b/test/pilosa.go index d56723e89..9e1a9a58b 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -36,7 +36,7 @@ type Command struct { commandOptions []server.CommandOption - Stdin bytes.Buffer + stdin bytes.Buffer Stdout bytes.Buffer Stderr bytes.Buffer } @@ -59,7 +59,7 @@ func NewCommand(opts ...server.CommandOption) *Command { m.Config.DataDir = path m.Config.Bind = "http://localhost:0" m.Config.Cluster.Disabled = true - m.Command.Stdin = &m.Stdin + m.Command.Stdin = &m.stdin m.Command.Stdout = &m.Stdout m.Command.Stderr = &m.Stderr From 44e0659934a7230dabad47741027d3d04fdad856 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:52 -0500 Subject: [PATCH 130/138] Unexport test.Command.Stdout --- test/pilosa.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pilosa.go b/test/pilosa.go index 9e1a9a58b..f6150a59a 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -37,7 +37,7 @@ type Command struct { commandOptions []server.CommandOption stdin bytes.Buffer - Stdout bytes.Buffer + stdout bytes.Buffer Stderr bytes.Buffer } @@ -60,7 +60,7 @@ func NewCommand(opts ...server.CommandOption) *Command { m.Config.Bind = "http://localhost:0" m.Config.Cluster.Disabled = true m.Command.Stdin = &m.stdin - m.Command.Stdout = &m.Stdout + m.Command.Stdout = &m.stdout m.Command.Stderr = &m.Stderr if testing.Verbose() { From 39504f8ded8e131f3c2be8a7f8e762e30288d2d9 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:03:58 -0500 Subject: [PATCH 131/138] Unexport test.Command.Stderr --- test/pilosa.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/pilosa.go b/test/pilosa.go index f6150a59a..9fb3152c5 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -38,7 +38,7 @@ type Command struct { stdin bytes.Buffer stdout bytes.Buffer - Stderr bytes.Buffer + stderr bytes.Buffer } func OptAllowedOrigins(origins []string) server.CommandOption { @@ -61,7 +61,7 @@ func NewCommand(opts ...server.CommandOption) *Command { m.Config.Cluster.Disabled = true m.Command.Stdin = &m.stdin m.Command.Stdout = &m.stdout - m.Command.Stderr = &m.Stderr + m.Command.Stderr = &m.stderr if testing.Verbose() { m.Command.Stdout = io.MultiWriter(os.Stdout, m.Command.Stdout) From 9ddb881bedd41647530f4a20577e916da8957603 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:04:04 -0500 Subject: [PATCH 132/138] Unexport test.Field.Close --- test/field.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/field.go b/test/field.go index 7a0439026..e0ad00442 100644 --- a/test/field.go +++ b/test/field.go @@ -49,8 +49,8 @@ func MustOpenField(opts pilosa.FieldOption) *Field { return f } -// Close closes the field and removes the underlying data. -func (f *Field) Close() error { +// close closes the field and removes the underlying data. +func (f *Field) close() error { defer os.RemoveAll(f.Path()) return f.Field.Close() } @@ -77,7 +77,7 @@ func (f *Field) Reopen() error { // Ensure field can set its cache func TestField_SetCacheSize(t *testing.T) { f := MustOpenField(pilosa.OptFieldTypeDefault()) - defer f.Close() + defer f.close() cacheSize := uint32(100) // Set & retrieve field cache size. From 48730e722fc716dc586690643abf7099b25faaf5 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:04:09 -0500 Subject: [PATCH 133/138] Unexport test.Field.Reopen --- test/field.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/field.go b/test/field.go index e0ad00442..140a8de11 100644 --- a/test/field.go +++ b/test/field.go @@ -55,8 +55,8 @@ func (f *Field) close() error { return f.Field.Close() } -// Reopen closes the index and reopens it. -func (f *Field) Reopen() error { +// reopen closes the index and reopens it. +func (f *Field) reopen() error { var err error if err := f.Field.Close(); err != nil { return err @@ -88,7 +88,7 @@ func TestField_SetCacheSize(t *testing.T) { } // Reload field and verify that it is persisted. - if err := f.Reopen(); err != nil { + if err := f.reopen(); err != nil { t.Fatal(err) } else if q := f.CacheSize(); q != cacheSize { t.Fatalf("unexpected field cache size (reopen): %d", q) From 66771b6ccdec6970162adc665c39b5854e998c65 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:04:15 -0500 Subject: [PATCH 134/138] Unexport test.MustOpenField --- test/field.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/field.go b/test/field.go index 140a8de11..40e55f4c4 100644 --- a/test/field.go +++ b/test/field.go @@ -40,8 +40,8 @@ func NewField(opts pilosa.FieldOption) *Field { return &Field{Field: field} } -// MustOpenField returns a new, opened field at a temporary path. Panic on error. -func MustOpenField(opts pilosa.FieldOption) *Field { +// mustOpenField returns a new, opened field at a temporary path. Panic on error. +func mustOpenField(opts pilosa.FieldOption) *Field { f := NewField(opts) if err := f.Open(); err != nil { panic(err) @@ -76,7 +76,7 @@ func (f *Field) reopen() error { // Ensure field can set its cache func TestField_SetCacheSize(t *testing.T) { - f := MustOpenField(pilosa.OptFieldTypeDefault()) + f := mustOpenField(pilosa.OptFieldTypeDefault()) defer f.close() cacheSize := uint32(100) From 8e026493a407264552d75f8117875001b9ed32e4 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:04:21 -0500 Subject: [PATCH 135/138] Unexport test.NewCommand --- test/pilosa.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/pilosa.go b/test/pilosa.go index 9fb3152c5..e1022ce8b 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -48,8 +48,8 @@ func OptAllowedOrigins(origins []string) server.CommandOption { } } -// NewCommand returns a new instance of Main with a temporary data directory and random port. -func NewCommand(opts ...server.CommandOption) *Command { +// newCommand returns a new instance of Main with a temporary data directory and random port. +func newCommand(opts ...server.CommandOption) *Command { path, err := ioutil.TempDir("", "pilosa-") if err != nil { panic(err) @@ -73,7 +73,7 @@ func NewCommand(opts ...server.CommandOption) *Command { // NewCommandNode returns a new instance of Command with clustering enabled. func NewCommandNode(isCoordinator bool, opts ...server.CommandOption) *Command { - m := NewCommand(opts...) + m := newCommand(opts...) m.Config.Cluster.Disabled = false m.Config.Cluster.Coordinator = isCoordinator return m @@ -81,7 +81,7 @@ func NewCommandNode(isCoordinator bool, opts ...server.CommandOption) *Command { // MustRunCommand returns a new, running Main. Panic on error. func MustRunCommand() *Command { - m := NewCommand() + m := newCommand() m.Config.Metric.Diagnostics = false // Disable diagnostics. if err := m.Start(); err != nil { panic(err) From 17d212444c406c012d8bb27f059849eff9f8ebc7 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:04:29 -0500 Subject: [PATCH 136/138] Unexport test.NewField --- test/field.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/field.go b/test/field.go index 40e55f4c4..bb5048575 100644 --- a/test/field.go +++ b/test/field.go @@ -27,8 +27,8 @@ type Field struct { *pilosa.Field } -// NewField returns a new instance of Field d/0. -func NewField(opts pilosa.FieldOption) *Field { +// newField returns a new instance of Field d/0. +func newField(opts pilosa.FieldOption) *Field { path, err := ioutil.TempDir("", "pilosa-field-") if err != nil { panic(err) @@ -42,7 +42,7 @@ func NewField(opts pilosa.FieldOption) *Field { // mustOpenField returns a new, opened field at a temporary path. Panic on error. func mustOpenField(opts pilosa.FieldOption) *Field { - f := NewField(opts) + f := newField(opts) if err := f.Open(); err != nil { panic(err) } From c004ffba3e91190d194ab32a3c2a57f01155509f Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:04:37 -0500 Subject: [PATCH 137/138] Unexport test.NewIndex --- test/index.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/index.go b/test/index.go index 9b7c1684b..ae2b997a9 100644 --- a/test/index.go +++ b/test/index.go @@ -26,8 +26,8 @@ type Index struct { *pilosa.Index } -// NewIndex returns a new instance of Index. -func NewIndex() *Index { +// newIndex returns a new instance of Index. +func newIndex() *Index { path, err := ioutil.TempDir("", "pilosa-index-") if err != nil { panic(err) @@ -41,7 +41,7 @@ func NewIndex() *Index { // MustOpenIndex returns a new, opened index at a temporary path. Panic on error. func MustOpenIndex() *Index { - index := NewIndex() + index := newIndex() if err := index.Open(); err != nil { panic(err) } From 50d57ec229d871daf3191a198c820010793d8f04 Mon Sep 17 00:00:00 2001 From: Cody Soyland Date: Thu, 5 Jul 2018 22:46:49 -0500 Subject: [PATCH 138/138] Unexport server.DefaultDiagnosticsInterval (in release tag) --- server/release.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/release.go b/server/release.go index 54d00b244..d988f4f81 100644 --- a/server/release.go +++ b/server/release.go @@ -20,5 +20,5 @@ package server import "time" -// DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics. -const DefaultDiagnosticsInterval = 1 * time.Hour +// defaultDiagnosticsInterval is the default sync frequency diagnostic metrics. +const defaultDiagnosticsInterval = 1 * time.Hour