Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
Found via `codespell -L atleast,thur,confg,thar,waht,allo,tast` and
`typos --hidden --format brief`
  • Loading branch information
kianmeng committed Jan 19, 2025
1 parent 96e50b0 commit e050b06
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Besides your standard OS versions, there is an additional `pcre` build which is

PCRE2 also comes with pitfalls, two of the most important are:
1. That *rare* is now dynamically linked, meaning that you need to have libc and libpcre installed
2. That pcre is an exponential-time algorithm (re2 is linear). While it can be significantly faster than go's `re2`, it can also be catastropically slower in some situations. There is a good post [here](https://swtch.com/~rsc/regexp/regexp1.html) that talks about regexp timings.
2. That pcre is an exponential-time algorithm (re2 is linear). While it can be significantly faster than go's `re2`, it can also be catastrophically slower in some situations. There is a good post [here](https://swtch.com/~rsc/regexp/regexp1.html) that talks about regexp timings.

I will leave it up to the user as to which they find suitable to use for their situation. Generally, if you know what *rare* is getting as an input, the pcre version is perfectly safe and can be much faster.

Expand Down Expand Up @@ -140,7 +140,7 @@ $ rare histo input.txt
Matched: 6 / 6 (Groups: 4)
```

### Extact status and size from nginx logs
### Extract status and size from nginx logs
```sh
$ rare filter -n 4 -m "(\d{3}) (\d+)" -e "{1} {2}" access.log
404 169
Expand Down
2 changes: 1 addition & 1 deletion cmd/spark.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func sparkCommand() *cli.Command {
},
&cli.BoolFlag{
Name: "notruncate",
Usage: "Disable truncating data that doesnt fit in the sparkline",
Usage: "Disable truncating data that doesn't fit in the sparkline",
Value: false,
},
&cli.StringFlag{
Expand Down
2 changes: 1 addition & 1 deletion docs/cli-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Create rows of sparkline graphs

**--noout**: Don't output any aggregation to stdout

**--notruncate**: Disable truncating data that doesnt fit in the sparkline
**--notruncate**: Disable truncating data that doesn't fit in the sparkline

**--num, --rows, -n**="": Number of elements (rows) to display (default: 20)

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Take a look at [examples](usage/examples.md) to see more of what *rare* does.

PCRE2 also comes with pitfalls, two of the most important are:
1. That *rare* is now dynamically linked, meaning that you need to have libc and libpcre installed
2. That pcre is an exponential-time algorithm (re2 is linear). While it can be significantly faster than go's `re2`, it can also be catastropically slower in some situations. There is a good post [here](https://swtch.com/~rsc/regexp/regexp1.html) that talks about regexp timings.
2. That pcre is an exponential-time algorithm (re2 is linear). While it can be significantly faster than go's `re2`, it can also be catastrophically slower in some situations. There is a good post [here](https://swtch.com/~rsc/regexp/regexp1.html) that talks about regexp timings.

I will leave it up to the user as to which they find suitable to use for their situation. Generally, if you know what *rare* is getting as an input, the pcre version is perfectly safe and can be much faster.

Expand Down
2 changes: 1 addition & 1 deletion docs/usage/aggregators.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ rare help histogram

### Summary

The histogram format outputs an aggregation by counting the occurences
The histogram format outputs an aggregation by counting the occurrences
of an extracted match. That is to say, on every line a regex will be
matched (or not), and the matched groups can be used to extract and build
a key, that will act as the bucketing name.
Expand Down
8 changes: 4 additions & 4 deletions docs/usage/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Arguments surrounded by `[]` are optional.

Syntax: `{coalesce ...}`

Evaluates arguments in-order, chosing the first non-empty result.
Evaluates arguments in-order, choosing the first non-empty result.

#### Select Field

Expand Down Expand Up @@ -501,11 +501,11 @@ Parse a given time-string into a unix second time (default format: `cache`)

##### Format Auto-Detection

If the format argument is ommitted or set to "auto", it will attempt to resolve the format of the time.
If the format argument is omitted or set to "auto", it will attempt to resolve the format of the time.

If the format is unable to be resolved, it must be specified manually with a format below, or a custom format.

If ommitted or "cache": The first seen date will determine the format for all dates going forward (faster)
If omitted or "cache": The first seen date will determine the format for all dates going forward (faster)

If "auto": The date format will be auto-detected with each parse. This can be used if the date could be in different formats (slower)

Expand Down Expand Up @@ -564,7 +564,7 @@ Syntax: `{duration dur}`

Use a duration expressed in s,m,h and convert it to seconds eg `{duration 24h}`

From there, you can do arithmatic on time, for instance: `{sumi {time now} {duration 1h}}`
From there, you can do arithmetic on time, for instance: `{sumi {time now} {duration 1h}}`

##### Format Duration

Expand Down
8 changes: 4 additions & 4 deletions docs/usage/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ you can specify `-t` or `--tail` to start following at the end.

There are two ways to read from a pipe: implicit and explicit.

Implicitely, if *rare* detects its stdin is a pipe, it will read it simply by not providing any arguments
Implicitly, if *rare* detects its stdin is a pipe, it will read it simply by not providing any arguments

`cat file.log | rare <aggregator>` or `rare <aggregator> < file.log`

Explicitely, you can pass a single read argument of `-` (dash) to mandate reading from stdin
Explicitly, you can pass a single read argument of `-` (dash) to mandate reading from stdin

`cat file.log | rare <aggregator> -`

Expand Down Expand Up @@ -93,11 +93,11 @@ at the cost of being less real-time if input generation is slow.

To counteract this, in the *follow* or *stdin* cases, there's also a flush timeout of
250ms. This means if a new line has been received, and the duration has passed,
that the batch will be processed irregardless of its current size.
that the batch will be processed regardless of its current size.

You can tweak this value with `--batch`

`rare <aggreagator> --batch=10 ...`
`rare <aggregator> --batch=10 ...`

In addition, you can tweak how many batches are buffered for the extractor with `--batch-buffer`.
By default, it will buffer 2 batches for every worker. More buffers take more memory, and
Expand Down
2 changes: 1 addition & 1 deletion docs/usage/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Read more at:

Expressions `-e` take the match groups, and other pieces of information, and build
a string-based key. The match groups can be operated on by helpers to build
the string-key (eg arithmatic, json parsing, simple logic).
the string-key (eg arithmetic, json parsing, simple logic).

The result of this key will act as the key for the aggregation stage.

Expand Down
2 changes: 1 addition & 1 deletion pkg/expressions/keyBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (s *KeyBuilder) Func(name string, f KeyBuilderFunction) {
}

// Compile builds a new key-builder, returning error(s) on build issues
// if the CompiledKeyBuilder is not nil, then something is still useable (albeit may have problems)
// if the CompiledKeyBuilder is not nil, then something is still usable (albeit may have problems)
func (s *KeyBuilder) Compile(template string) (*CompiledKeyBuilder, *CompilerErrors) {
kb := &CompiledKeyBuilder{
stages: make([]KeyBuilderStage, 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// Simple helper that will take 2 or more integers, and apply an operation
func arithmaticHelperi(equation func(int, int) int) KeyBuilderFunction {
func ArithmeticHelperi(equation func(int, int) int) KeyBuilderFunction {
return KeyBuilderFunction(func(args []KeyBuilderStage) (KeyBuilderStage, error) {
if len(args) < 2 {
return stageErrArgRange(args, "2+")
Expand All @@ -31,7 +31,7 @@ func arithmaticHelperi(equation func(int, int) int) KeyBuilderFunction {
}

// Simple helper that will take 2 or more integers, and apply an operation
func arithmaticHelperf(equation func(float64, float64) float64) KeyBuilderFunction {
func ArithmeticHelperf(equation func(float64, float64) float64) KeyBuilderFunction {
return KeyBuilderFunction(func(args []KeyBuilderStage) (KeyBuilderStage, error) {
if len(args) < 2 {
return stageErrArgRange(args, "2+")
Expand All @@ -56,7 +56,7 @@ func arithmaticHelperf(equation func(float64, float64) float64) KeyBuilderFuncti
}

// Helper that takes in a float, operates on it
func unaryArithmaticHelperf(op func(float64) float64) KeyBuilderFunction {
func unaryArithmeticHelperf(op func(float64) float64) KeyBuilderFunction {
return func(args []KeyBuilderStage) (KeyBuilderStage, error) {
if len(args) != 1 {
return stageErrArgCount(args, 1)
Expand All @@ -74,7 +74,7 @@ func unaryArithmaticHelperf(op func(float64) float64) KeyBuilderFunction {
}

// Helper that takes in a float, operates on it, and spits out an int
func unaryArithmaticHelperfi(op func(float64) int64) KeyBuilderFunction {
func unaryArithmeticHelperfi(op func(float64) int64) KeyBuilderFunction {
return func(args []KeyBuilderStage) (KeyBuilderStage, error) {
if len(args) != 1 {
return stageErrArgCount(args, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"github.com/stretchr/testify/assert"
)

func TestArithmatic(t *testing.T) {
func TestArithmetic(t *testing.T) {
kb, _ := NewStdKeyBuilder().Compile("{sumi {1} {4}} {multi {1} 2} {divi {1} 2} {subi {1} 10} {modi {1} 7}")
key := kb.BuildKey(mockContext("ab", "100", "1000000", "5000000.123456", "22"))
assert.Equal(t, "122 200 50 90 2", key)
}

func TestArithmaticError(t *testing.T) {
func TestArithmeticError(t *testing.T) {
kb, _ := NewStdKeyBuilder().Compile("{sumi 1} {sumi 1 a} {sumi a 1} {sumi 1 1 b}")
key := kb.BuildKey(mockContext())
assert.Equal(t, "<ARGN> <BAD-TYPE> <BAD-TYPE> <BAD-TYPE>", key)
Expand All @@ -22,12 +22,12 @@ func TestMaxMin(t *testing.T) {
testExpression(t, mockContext(), `{maxi 1 1} {maxi 1 2} {maxi 5 1} {mini 1 1} {mini 1 2} {mini 5 1}`, "1 2 5 1 1 1")
}

func TestArithmaticf(t *testing.T) {
func TestArithmeticf(t *testing.T) {
kb, _ := NewStdKeyBuilder().Compile("{sumf {1} {4}} {multf {1} 2} {divf {1} 2} {subf {1} 10}")
key := kb.BuildKey(mockContext("ab", "100", "1000000", "5000000.123456", "22"))
assert.Equal(t, "122 200 50 90", key)
}
func TestArithmaticfError(t *testing.T) {
func TestArithmeticfError(t *testing.T) {
kb, _ := NewStdKeyBuilder().Compile("{sumf 1} {sumf 1 a} {sumf a 1} {sumf 1 2 a}")
key := kb.BuildKey(mockContext())
assert.Equal(t, "<ARGN> <BAD-TYPE> <BAD-TYPE> <BAD-TYPE>", key)
Expand Down
2 changes: 1 addition & 1 deletion pkg/expressions/stdlib/funcsComparators.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func stringComparator(equation func(string, string) string) KeyBuilderFunction {
}

// Checks equality, and returns truthy if equals, and empty if not
func arithmaticEqualityHelper(test func(float64, float64) bool) KeyBuilderFunction {
func ArithmeticEqualityHelper(test func(float64, float64) bool) KeyBuilderFunction {
return KeyBuilderFunction(func(args []KeyBuilderStage) (KeyBuilderStage, error) {
if len(args) != 2 {
return stageErrArgCount(args, 2)
Expand Down
2 changes: 1 addition & 1 deletion pkg/extractor/batchers/batcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *Batcher) syncReaderToBatcher(sourceName string, reader io.Reader, batch
}

// syncReaderToBatcherWithTimeFlush is similar to `syncReaderToBatcher`, except if it gets a new line
// it will flush the batch if n time has elapsed since the last flush, irregardless of how many items are in the current batch
// it will flush the batch if n time has elapsed since the last flush, regardless of how many items are in the current batch
// Good for potentially slow or more interactive workloads (tail, stdin, etc)
func (s *Batcher) syncReaderToBatcherWithTimeFlush(sourceName string, reader io.Reader, batchSize int, autoFlush time.Duration) {
readerMetrics := newReaderMetrics(reader)
Expand Down
2 changes: 1 addition & 1 deletion pkg/extractor/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (s *extractorInstance) processLineSync(source string, lineNum uint64, line
// as a pointer instead
lineStringPtr := *(*string)(unsafe.Pointer(&line))
// A context is created for each "instance", and since a context isn't shared beyond building a key
// it's significantly faster to re-use a single context per goroutine
// it's significantly faster to reuse a single context per goroutine
expContext := s.context
expContext.linePtr = lineStringPtr
expContext.indices = matches
Expand Down
2 changes: 1 addition & 1 deletion pkg/matchers/fastregex/pcre2.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (s *pcre2Regexp) MatchString(str string) bool {
return rc >= 0
}

// FindSubmatchIndex, like regexp, returns a set of string indecies where the results are
// FindSubmatchIndex, like regexp, returns a set of string indices where the results are
// FindSubmatchIndex is NOT thread-safe. You need to create an instance of the fastregex engine
func (s *pcre2Regexp) FindSubmatchIndex(b []byte) []int {
if len(b) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/matchers/fastregex/re2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package fastregex
import "regexp"

/*
The fallback exposes the re2/regexp go implementaiton in the
The fallback exposes the re2/regexp go implementation in the
cases where we can't compile with PCRE support
*/

Expand Down
2 changes: 1 addition & 1 deletion pkg/multiterm/termscaler/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s Scaler) remapMinMax(min, max int64) (float64, float64) {
return math.Floor(s.mapVal(float64(min))), math.Ceil(s.mapVal(float64(max)))
}

// Returns a val, betwen min and max, to a 0-1 float range
// Returns a val, between min and max, to a 0-1 float range
func (s Scaler) Scale(val, min, max int64) float64 {
if max < min {
return 0.0
Expand Down

0 comments on commit e050b06

Please sign in to comment.