Fix issues found by golint without changing API.
This commit is contained in:
parent
684cf07725
commit
b21739c0e2
1 changed files with 13 additions and 13 deletions
26
gcs/gcs.go
26
gcs/gcs.go
|
@ -34,7 +34,7 @@ const (
|
|||
KeySize = 16
|
||||
)
|
||||
|
||||
// GCSFilter describes an immutable filter that can be built from
|
||||
// Filter describes an immutable filter that can be built from
|
||||
// a set of data elements, serialized, deserialized, and queried
|
||||
// in a thread-safe manner. The serialized form is compressed as
|
||||
// a Golomb Coded Set (GCS), but does not include N or P to allow
|
||||
|
@ -42,7 +42,7 @@ const (
|
|||
// hash function used is SipHash, a keyed function; the key used
|
||||
// in building the filter is required in order to match filter
|
||||
// values and is not included in the serialized form.
|
||||
type GCSFilter struct {
|
||||
type Filter struct {
|
||||
n uint32
|
||||
p uint8
|
||||
modulusP uint64
|
||||
|
@ -54,7 +54,7 @@ type GCSFilter struct {
|
|||
// `1/(2**P)`, key `key`, and including every `[]byte` in `data` as a member of
|
||||
// the set.
|
||||
func BuildGCSFilter(P uint8, key [KeySize]byte,
|
||||
data [][]byte) (*GCSFilter, error) {
|
||||
data [][]byte) (*Filter, error) {
|
||||
|
||||
// Some initial parameter checks: make sure we have data from which to
|
||||
// build the filter, and make sure our parameters will fit the hash
|
||||
|
@ -70,7 +70,7 @@ func BuildGCSFilter(P uint8, key [KeySize]byte,
|
|||
}
|
||||
|
||||
// Create the filter object and insert metadata.
|
||||
f := GCSFilter{
|
||||
f := Filter{
|
||||
n: uint32(len(data)),
|
||||
p: P,
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ func BuildGCSFilter(P uint8, key [KeySize]byte,
|
|||
|
||||
// FromBytes deserializes a GCS filter from a known N, P, and serialized
|
||||
// filter as returned by Bytes().
|
||||
func FromBytes(N uint32, P uint8, d []byte) (*GCSFilter, error) {
|
||||
func FromBytes(N uint32, P uint8, d []byte) (*Filter, error) {
|
||||
|
||||
// Basic sanity check.
|
||||
if P > 32 {
|
||||
|
@ -127,7 +127,7 @@ func FromBytes(N uint32, P uint8, d []byte) (*GCSFilter, error) {
|
|||
}
|
||||
|
||||
// Create the filter object and insert metadata.
|
||||
f := &GCSFilter{
|
||||
f := &Filter{
|
||||
n: N,
|
||||
p: P,
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ func FromBytes(N uint32, P uint8, d []byte) (*GCSFilter, error) {
|
|||
|
||||
// Bytes returns the serialized format of the GCS filter, which does not
|
||||
// include N or P (returned by separate methods) or the key used by SipHash.
|
||||
func (f *GCSFilter) Bytes() []byte {
|
||||
func (f *Filter) Bytes() []byte {
|
||||
filterData := make([]byte, len(f.filterData))
|
||||
copy(filterData, f.filterData)
|
||||
return filterData
|
||||
|
@ -150,18 +150,18 @@ func (f *GCSFilter) Bytes() []byte {
|
|||
|
||||
// P returns the filter's collision probability as a negative power of 2 (that
|
||||
// is, a collision probability of `1/2**20` is represented as 20).
|
||||
func (f *GCSFilter) P() uint8 {
|
||||
func (f *Filter) P() uint8 {
|
||||
return f.p
|
||||
}
|
||||
|
||||
// N returns the size of the data set used to build the filter.
|
||||
func (f *GCSFilter) N() uint32 {
|
||||
func (f *Filter) N() uint32 {
|
||||
return f.n
|
||||
}
|
||||
|
||||
// Match checks whether a []byte value is likely (within collision
|
||||
// probability) to be a member of the set represented by the filter.
|
||||
func (f *GCSFilter) Match(key [KeySize]byte, data []byte) (bool, error) {
|
||||
func (f *Filter) Match(key [KeySize]byte, data []byte) (bool, error) {
|
||||
|
||||
// Create a filter bitstream.
|
||||
filterData := f.Bytes()
|
||||
|
@ -195,7 +195,7 @@ func (f *GCSFilter) Match(key [KeySize]byte, data []byte) (bool, error) {
|
|||
// MatchAny returns checks whether any []byte value is likely (within
|
||||
// collision probability) to be a member of the set represented by the
|
||||
// filter faster than calling Match() for each value individually.
|
||||
func (f *GCSFilter) MatchAny(key [KeySize]byte, data [][]byte) (bool, error) {
|
||||
func (f *Filter) MatchAny(key [KeySize]byte, data [][]byte) (bool, error) {
|
||||
|
||||
// Basic sanity check.
|
||||
if len(data) == 0 {
|
||||
|
@ -252,7 +252,7 @@ func (f *GCSFilter) MatchAny(key [KeySize]byte, data [][]byte) (bool, error) {
|
|||
|
||||
// readFullUint64 reads a value represented by the sum of a unary multiple
|
||||
// of the filter's P modulus (`2**P`) and a big-endian P-bit remainder.
|
||||
func (f *GCSFilter) readFullUint64(b *bstream.BStream) (uint64, error) {
|
||||
func (f *Filter) readFullUint64(b *bstream.BStream) (uint64, error) {
|
||||
var v uint64
|
||||
|
||||
// Count the 1s until we reach a 0.
|
||||
|
@ -260,7 +260,7 @@ func (f *GCSFilter) readFullUint64(b *bstream.BStream) (uint64, error) {
|
|||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
for c == true {
|
||||
for c {
|
||||
v++
|
||||
c, err = b.ReadBit()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue