Merge pull request #1457 from travisturner/remove-dead-code

remove some dead code highlighed by the unexport script
This commit is contained in:
Travis Turner 2018-07-05 08:40:54 -05:00 committed by GitHub
commit 3b898bf801
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 20 additions and 126 deletions

57
api.go
View file

@ -372,55 +372,6 @@ func (api *API) ShardNodes(ctx context.Context, indexName string, shard uint64)
return api.cluster.shardNodes(indexName, shard), nil
}
// MarshalFragment returns an object which can write the specified fragment's data
// to an io.Writer. The serialized data can be read back into a fragment with
// the UnmarshalFragment API call.
func (api *API) MarshalFragment(ctx context.Context, indexName string, fieldName string, shard uint64) (io.WriterTo, error) {
if err := api.validate(apiMarshalFragment); err != nil {
return nil, errors.Wrap(err, "validating api method")
}
// Retrieve fragment from holder.
f := api.holder.fragment(indexName, fieldName, viewStandard, shard)
if f == nil {
return nil, ErrFragmentNotFound
}
return f, nil
}
// UnmarshalFragment creates a new fragment (if necessary) and reads data from a
// Reader which was previously written by MarshalFragment to populate the
// fragment's data.
func (api *API) UnmarshalFragment(ctx context.Context, indexName string, fieldName string, shard uint64, reader io.ReadCloser) error {
if err := api.validate(apiUnmarshalFragment); err != nil {
return errors.Wrap(err, "validating api method")
}
// Retrieve field.
f := api.holder.Field(indexName, fieldName)
if f == nil {
return ErrFieldNotFound
}
// Retrieve view.
view, err := f.createViewIfNotExists(viewStandard)
if err != nil {
return errors.Wrap(err, "creating view")
}
// Retrieve fragment from field.
frag, err := view.CreateFragmentIfNotExists(shard)
if err != nil {
return errors.Wrap(err, "creating fragment")
}
// Read fragment in from request body.
if _, err := frag.ReadFrom(reader); err != nil {
return errors.Wrap(err, "reading fragment")
}
return nil
}
// FragmentBlockData is an endpoint for internal usage. It is not guaranteed to
// return anything useful. Currently it returns protobuf encoded row and column
// ids from a "block" which is a subdivision of a fragment.
@ -891,7 +842,6 @@ const (
apiIndexAttrDiff
//apiLocalID // not implemented
//apiLongQueryTime // not implemented
apiMarshalFragment
//apiMaxShards // not implemented
apiQuery
apiRecalculateCaches
@ -902,15 +852,13 @@ const (
apiShardNodes
//apiState // not implemented
//apiStatsWithTags // not implemented
apiUnmarshalFragment
//apiVersion // not implemented
apiViews
)
var methodsCommon = map[apiMethod]struct{}{
apiClusterMessage: struct{}{},
apiMarshalFragment: struct{}{},
apiSetCoordinator: struct{}{},
apiClusterMessage: struct{}{},
apiSetCoordinator: struct{}{},
}
var methodsResizing = map[apiMethod]struct{}{
@ -936,6 +884,5 @@ var methodsNormal = map[apiMethod]struct{}{
apiRecalculateCaches: struct{}{},
apiRemoveNode: struct{}{},
apiShardNodes: struct{}{},
apiUnmarshalFragment: struct{}{},
apiViews: struct{}{},
}

View file

@ -4,9 +4,9 @@ package pilosa
import "strconv"
const _apiMethod_name = "apiClusterMessageapiCreateFieldapiCreateIndexapiDeleteFieldapiDeleteIndexapiDeleteViewapiExportCSVapiFragmentBlockDataapiFragmentBlocksapiFieldapiFieldAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiMarshalFragmentapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiSetCoordinatorapiShardNodesapiUnmarshalFragmentapiViews"
const _apiMethod_name = "apiClusterMessageapiCreateFieldapiCreateIndexapiDeleteFieldapiDeleteIndexapiDeleteViewapiExportCSVapiFragmentBlockDataapiFragmentBlocksapiFieldapiFieldAttrDiffapiImportapiImportValueapiIndexapiIndexAttrDiffapiQueryapiRecalculateCachesapiRemoveNodeapiResizeAbortapiSetCoordinatorapiShardNodesapiViews"
var _apiMethod_index = [...]uint16{0, 17, 31, 45, 59, 73, 86, 98, 118, 135, 143, 159, 168, 182, 190, 206, 224, 232, 252, 265, 279, 296, 309, 329, 337}
var _apiMethod_index = [...]uint16{0, 17, 31, 45, 59, 73, 86, 98, 118, 135, 143, 159, 168, 182, 190, 206, 214, 234, 247, 261, 278, 291, 299}
func (i apiMethod) String() string {
if i < 0 || i >= apiMethod(len(_apiMethod_index)-1) {

View file

@ -45,8 +45,7 @@ const (
ClusterStateResizing = "RESIZING"
// NodeState represents the state of a node during startup.
NodeStateLoading = "LOADING"
NodeStateReady = "READY"
NodeStateReady = "READY"
// resizeJob states.
resizeJobStateRunning = "RUNNING"

View file

@ -204,13 +204,6 @@ func (f *Field) Type() string {
return f.options.Type
}
// CacheType returns the caching mode for the field.
func (f *Field) CacheType() string {
f.mu.RLock()
defer f.mu.RUnlock()
return f.options.CacheType
}
// SetCacheSize sets the cache size for ranked fames. Persists to meta file on update.
// defaults to DefaultCacheSize 50000
func (f *Field) SetCacheSize(v uint32) error {

28
row.go
View file

@ -216,25 +216,6 @@ func (r *Row) InvalidateCount() {
}
}
// IncrementCount increments the row cached counter, note this is an optimization that assumes that the caller is aware the size increased.
func (r *Row) IncrementCount(i uint64) {
seg := r.segment(i / ShardWidth)
if seg != nil {
seg.n++
}
}
// DecrementCount decrements the row cached counter.
func (r *Row) DecrementCount(i uint64) {
seg := r.segment(i / ShardWidth)
if seg != nil {
if seg.n > 0 {
seg.n--
}
}
}
// Count returns the number of columns in the row.
func (r *Row) Count() uint64 {
var n uint64
@ -297,15 +278,6 @@ func DecodeRow(pr *internal.Row) *Row {
return r
}
// Union performs a union on a slice of rows.
func Union(rows []*Row) *Row {
other := rows[0]
for _, r := range rows[1:] {
other = other.Union(r)
}
return other
}
// 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.

View file

@ -70,15 +70,6 @@ func (q TimeQuantum) Type() string {
return "TimeQuantum"
}
// ParseTimeQuantum parses v into a time quantum.
func ParseTimeQuantum(v string) (TimeQuantum, error) {
q := TimeQuantum(strings.ToUpper(v))
if !q.Valid() {
return "", ErrInvalidTimeQuantum
}
return q, nil
}
// viewByTimeUnit returns the view name for time with a given quantum unit.
func viewByTimeUnit(name string, t time.Time, unit rune) string {
switch unit {

View file

@ -16,6 +16,7 @@ package pilosa
import (
"reflect"
"strings"
"testing"
"time"
)
@ -23,7 +24,7 @@ import (
// Ensure string can be parsed into time quantum.
func TestParseTimeQuantum(t *testing.T) {
t.Run("OK", func(t *testing.T) {
if q, err := ParseTimeQuantum("YMDH"); err != nil {
if q, err := parseTimeQuantum("YMDH"); err != nil {
t.Fatalf("unexpected error: %s", err)
} else if q != TimeQuantum("YMDH") {
t.Fatalf("unexpected quantum: %#v", q)
@ -31,7 +32,7 @@ func TestParseTimeQuantum(t *testing.T) {
})
t.Run("ErrInvalidTimeQuantum", func(t *testing.T) {
if _, err := ParseTimeQuantum("BADQUANTUM"); err != ErrInvalidTimeQuantum {
if _, err := parseTimeQuantum("BADQUANTUM"); err != ErrInvalidTimeQuantum {
t.Fatalf("unexpected error: %s", err)
}
})
@ -160,9 +161,18 @@ func mustParseTime(value string) time.Time {
// mustParseTimeQuantum parses v into a time quantum. Panic on error.
func mustParseTimeQuantum(v string) TimeQuantum {
q, err := ParseTimeQuantum(v)
q, err := parseTimeQuantum(v)
if err != nil {
panic(err)
}
return q
}
// parseTimeQuantum parses v into a time quantum.
func parseTimeQuantum(v string) (TimeQuantum, error) {
q := TimeQuantum(strings.ToUpper(v))
if !q.Valid() {
return "", ErrInvalidTimeQuantum
}
return q, nil
}

12
uri.go
View file

@ -148,14 +148,6 @@ func (u URI) String() string {
return fmt.Sprintf("%s://%s:%d", u.scheme, u.host, u.port)
}
// Equals returns true if the checked URI is equivalent to this URI.
func (u URI) Equals(other *URI) bool {
if other == nil {
return false
}
return u == *other
}
// Path returns URI with path
func (u *URI) Path(path string) string {
return fmt.Sprintf("%s%s", u.Normalize(), path)
@ -163,7 +155,7 @@ func (u *URI) Path(path string) string {
// The following methods are required to implement pflag Value interface.
// Set sets the time quantum value.
// Set sets the uri value.
func (u *URI) Set(value string) error {
uri, err := NewURIFromAddress(value)
if err != nil {
@ -173,7 +165,7 @@ func (u *URI) Set(value string) error {
return nil
}
// Type returns the type of a time quantum value.
// Type returns the type of a uri.
func (u URI) Type() string {
return "URI"
}

View file

@ -76,16 +76,6 @@ func TestURIPath(t *testing.T) {
}
}
func TestEquals(t *testing.T) {
uri1 := DefaultURI()
if uri1.Equals(nil) {
t.Fatalf("URI should not be equal to nil")
}
if !uri1.Equals(DefaultURI()) {
t.Fatalf("URI should be equal to another URI with the same scheme, host and port")
}
}
func TestSetScheme(t *testing.T) {
uri := DefaultURI()
target := "fun"