Skip to content

Commit

Permalink
uncapitalize error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
OldPanda committed Aug 10, 2024
1 parent 40984e6 commit 3740b77
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bloomfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ func NewBloomFilter(expectedInsertions int, errRate float64) (*BloomFilter, erro
// * &Murur128Mitz64{}
func NewBloomFilterWithStrategy(expectedInsertions int, errRate float64, strategy Strategy) (*BloomFilter, error) {
if errRate <= 0.0 {
return nil, errors.New("Error rate must be > 0.0")
return nil, errors.New("error rate must be > 0.0")
}
if errRate >= 1.0 {
return nil, errors.New("Error rate must be < 1.0")
return nil, errors.New("error rate must be < 1.0")
}
if expectedInsertions < 0 {
return nil, errors.New("Expected insertions must be >= 0")
return nil, errors.New("expected insertions must be >= 0")
}
if expectedInsertions == 0 {
expectedInsertions = 1
Expand All @@ -64,28 +64,28 @@ func FromBytes(b []byte) (*BloomFilter, error) {
// read strategy
strategyByte, err := reader.ReadByte()
if err != nil {
return nil, fmt.Errorf("Failed to read strategy: %v", err)
return nil, fmt.Errorf("failed to read strategy: %v", err)
}
strategyIndex := int(strategyByte)
if strategyIndex >= len(strategyList) {
return nil, fmt.Errorf("Unknown strategy byte: %v", strategyByte)
return nil, fmt.Errorf("unknown strategy byte: %v", strategyByte)
}
strategy := strategyList[strategyIndex]

// read number of hash functions
numHashFuncByte, err := reader.ReadByte()
if err != nil {
return nil, fmt.Errorf("Failed to read number of hash functions: %v", err)
return nil, fmt.Errorf("failed to read number of hash functions: %v", err)
}
numHashFunctions := int(numHashFuncByte)

// read bitarray capacity
numUint64Bytes, err := ioutil.ReadAll(io.LimitReader(reader, 4))
if err != nil {
return nil, fmt.Errorf("Failed to read number of bits: %v", err)
return nil, fmt.Errorf("failed to read number of bits: %v", err)
}
if len(numUint64Bytes) != 4 {
return nil, fmt.Errorf("Not a valid uint32 bytes: %v", numUint64Bytes)
return nil, fmt.Errorf("not a valid uint32 bytes: %v", numUint64Bytes)
}
numUint64 := binary.BigEndian.Uint32(numUint64Bytes)
array := bitarray.NewBitArray(uint64(numUint64) * 64)
Expand All @@ -94,10 +94,10 @@ func FromBytes(b []byte) (*BloomFilter, error) {
for blockIdx := 0; blockIdx < int(numUint64); blockIdx++ {
block, err := ioutil.ReadAll(io.LimitReader(reader, 8))
if err != nil {
return nil, fmt.Errorf("Failed to build bitarray: %v", err)
return nil, fmt.Errorf("failed to build bitarray: %v", err)
}
if len(block) != 8 {
return nil, fmt.Errorf("Not a valid uint64 bytes: %v", block)
return nil, fmt.Errorf("not a valid uint64 bytes: %v", block)
}
num := binary.BigEndian.Uint64(block)
var pos uint64 = 1 << 63
Expand Down

0 comments on commit 3740b77

Please sign in to comment.