Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use.
This is where velocifilter comes in. By using the library we can provide
a single flag where the user may specify a flexible VQL query (Velocidex
Query Language - a simplified SQL dialect) allowing the user to specify
arbirarily complex filter expressions. For example:
arbitrarily complex filter expressions. For example:

SELECT file from glob(pattern=["*.go", "*.py"]) where file.Size < 5000
and file.Mtime < now() - "5 days"
Expand Down Expand Up @@ -74,7 +74,7 @@ package to add an interface to an existing type without creating a new
type which embeds it. Clients who need to handle the original third
party types must have a way to attach new protocols to existing types
defined outside their own codebase. Velocifilter achieves this by
implementing a registration systen in the Scope{} object.
implementing a registration system in the Scope{} object.

For example, consider a client of the library wishing to pass custom
types in queries:
Expand Down
2 changes: 1 addition & 1 deletion api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func GetResponseChannel(
Payload: s,
}

// We dont know the columns but we have at
// We don't know the columns but we have at
// least one row. Set the columns from this
// row.
if len(rows) > 0 {
Expand Down
8 changes: 4 additions & 4 deletions docs/destructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fd.Close()
```

However, our query above will just throw away Y and Z because only the
X property is neded: `SELECT X FROM plugin()`.
X property is needed: `SELECT X FROM plugin()`.

How can we produce lazy objects?

Expand Down Expand Up @@ -80,7 +80,7 @@ output_chan <- row

This solves the problem of evaluating Y and Z unnecessarily, but now
it is not clear when we should close the file? We must do so only
*after* the lazy function is evaulated but we do not know when that
*after* the lazy function is evaluated but we do not know when that
will be.

If we immediately close the file after pushing the lazy row to the
Expand Down Expand Up @@ -183,7 +183,7 @@ not Y() or Z() avoiding the extra work.

This is particularly important for parsers who can spend a lot of time
and cpu parsing files - even if the query does not actually need that
information. Writing parsers in a lazy fasion helps make them more
information. Writing parsers in a lazy fashion helps make them more
efficient.

## Alternative 2 - ordereddict based rows
Expand All @@ -193,7 +193,7 @@ plugin to forward an ordereddict based row with callables as values

```golang
output_chan <- ordereddict.NewDict().
Set("X", func() {CalculateX(fd)}). <-- lazy functions evaulated on access.
Set("X", func() {CalculateX(fd)}). <-- lazy functions evaluated on access.
Set("Y", func() {CalculateY(fd)}).
Set("Z", func() {CalculateZ(fd)})
```
4 changes: 2 additions & 2 deletions functions/aggregates.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
// 1. Each aggregate function instance in the AST carries a unique
// ID. This allows the function to store its own state in the
// aggregate context without interference from other instances of
// the same function (e.g. having two count() instaces is OK)
// the same function (e.g. having two count() instances is OK)

// 2. The scope may contain a reference to an AggregatorCtx
// object. This object manages access to the aggregate
// context. The main method that should be used is Modify() which
// mofidies the context under lock.
// modifies the context under lock.

// 3. When the scope spawns a child scope, the child scope does not
// have its own AggregatorCtx, instead chasing its parent to find
Expand Down
2 changes: 1 addition & 1 deletion functions/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type _EncodeFunction struct{}
func (self _EncodeFunction) Info(scope types.Scope, type_map *types.TypeMap) *types.FunctionInfo {
return &types.FunctionInfo{
Name: "encode",
Doc: "Encodes a string as as different type. Currently supported types include 'hex', 'base64'.",
Doc: "Encodes a string as a different type. Currently supported types include 'hex', 'base64'.",
ArgType: type_map.AddType(scope, _EncodeFunctionArgs{}),
}
}
Expand Down
2 changes: 1 addition & 1 deletion grouper/grouper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Immplements group by operation
// Implements group by operation

package grouper

Expand Down
2 changes: 1 addition & 1 deletion marshal/marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func Marshal(scope types.Scope, item interface{}) (*types.MarshalItem, error) {

// The default marshaller is to just convert it into
// JSON and hope for the best - but we let the user
// know we dont know how to handle it.
// know we don't know how to handle it.
default:
serialized, err := json.Marshal(item)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions materializer/in_memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (self InMemoryMatrializer) Applicable(a types.Any, b types.Any) bool {
return true
}

// Just deletegate to our contained rows array.
// Just delegate to our contained rows array.
func (self InMemoryMatrializer) GetMembers(scope types.Scope, a types.Any) []string {
a_materializer, ok := a.(*InMemoryMatrializer)
if !ok {
Expand Down Expand Up @@ -78,10 +78,10 @@ func (self *InMemoryMatrializer) MarshalJSON() ([]byte, error) {
}

// An object implementing the ScopeMaterializer interface. This is the
// default meterializer used in VQL to expand a LET query into the
// default materializer used in VQL to expand a LET query into the
// scope. It returns wrapper that contains the list of rows in
// memory. Library users may register a more sophisticated
// meterializer that backs data in more scalable storage to avoid
// materializer that backs data in more scalable storage to avoid
// memory costs.
type DefaultMaterializer struct{}

Expand Down
2 changes: 1 addition & 1 deletion ordereddict_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type dictSerializationTest struct {
var dictSerializationTests = []dictSerializationTest{
{ordereddict.NewDict().Set("Foo", "Bar"), `{"Foo":"Bar"}`},

// Test an unserilizable member - This should not prevent the
// Test an unserializable member - This should not prevent the
// entire dict from serializing - only that member should be
// ignored.
{ordereddict.NewDict().Set("Foo", "Bar").
Expand Down
4 changes: 2 additions & 2 deletions protocols/protocol_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (self AddDispatcher) Copy() AddDispatcher {
// float int -> lhs + float(rhs)
// float float -> lhs + rhs

// We dont handle any other additions with ints here.
// We don't handle any other additions with ints here.
func intAdd(lhs int64, b types.Any) (types.Any, bool) {
switch b.(type) {
case int, int8, int16, int32, int64, uint8, uint16, uint32, uint64:
Expand All @@ -43,7 +43,7 @@ func intAdd(lhs int64, b types.Any) (types.Any, bool) {
return float64(lhs) + rhs, true
}

// We dont handle any other additions here
// We don't handle any other additions here
return &types.Null{}, false
}

Expand Down
2 changes: 1 addition & 1 deletion protocols/protocol_associative.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (self *AssociativeDispatcher) Associative(
case types.LazyRow:
return t.Get(b_str)

// Dereferencing a stroed query expands all
// Dereferencing a stored query expands all
// fields and extracts a single column
case types.StoredQuery:
result := []types.Row{}
Expand Down
2 changes: 1 addition & 1 deletion protocols/protocol_div.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (self DivDispatcher) Div(scope types.Scope, a types.Any, b types.Any) types
}
}

// Always convert to float to not lose preceision.
// Always convert to float to not lose precision.
a_int, ok := utils.ToFloat(a)
if ok {
b_int, ok := utils.ToFloat(b)
Expand Down
6 changes: 3 additions & 3 deletions scope/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,15 +531,15 @@ func (self *Scope) Close() {
// the order the destructors are called on the same scope, we
// sometimes need to retry the destructors. This means the
// destructors will reschedule themselves to be called again. At
// the end of this function we prevent new detructors from being
// the end of this function we prevent new destructors from being
// added to this scope.

// Stop new destructors from appearing on this scope, once this
// function returns.
defer self.destructors.SetDestroyed()

// Destructors are called in reverse order to their
// declerations.
// declarations.
for try := 0; try < 10; try++ {
// Remove destructors from list so they are not run again.
ds := self.destructors.RemoveDestructors()
Expand Down Expand Up @@ -578,7 +578,7 @@ func NewScope() *Scope {
id: NextId(),
}

// Add Builtin protocols, functions, and plugins
// Add Built-in protocols, functions, and plugins
dispatcher.AddProtocolImpl(protocols.GetBuiltinTypes()...)
dispatcher.AppendFunctions(result, functions.GetBuiltinFunctions()...)
dispatcher.AppendPlugins(result, plugins.GetBuiltinPlugins()...)
Expand Down
4 changes: 2 additions & 2 deletions types/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type PluginInfo struct {
// versions of this plugin if needed.
Version int

// Arbitrary metadata attched to the plugin info
// Arbitrary metadata attached to the plugin info
Metadata *ordereddict.Dict

// Set to true if the plugin accepts free form args (i.e. any
Expand All @@ -58,7 +58,7 @@ type FunctionInfo struct {
// versions of this function if needed.
Version int

// Arbitrary metadata attched to the function info
// Arbitrary metadata attached to the function info
Metadata *ordereddict.Dict

// Set to true if the plugin accepts free form args (i.e. any
Expand Down
2 changes: 1 addition & 1 deletion types/grouper.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// grouper.
type GroupbyActor interface {
// Just receive new rows. Return EOF when no more rows exist. Returns
// 1. The next trasformed row to group.
// 1. The next transformed row to group.
// 2. The original untransformed row (that can from the plugin).
// 3. The group by bin index
// 4. The scope over which the query is materialized.
Expand Down
2 changes: 1 addition & 1 deletion types/introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (self *TypeMap) Get(scope Scope, name string) (*TypeDescription, bool) {
// Introspect the type of the parameter. Add type descriptor to the
// type map and return the type name.
func (self *TypeMap) AddType(scope Scope, a Any) string {
// Dont do anything if the caller does not care about a type
// don't do anything if the caller does not care about a type
// map.
if self == nil || scope == nil {
return ""
Expand Down
4 changes: 2 additions & 2 deletions utils/unquote.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
// unquote either a " or ' delimited string.
func Unquote(s string) string {
// If we start with ''' this is a literal string - do not
// interfer at all.
// interfere at all.
if strings.HasPrefix(s, "'''") {
if strings.HasSuffix(s, "'''") {
return s[3 : len(s)-3]
}
}

// This should not happen but in case it does do not interfer at all.
// This should not happen but in case it does do not interfere at all.
quote := s[0]
if quote != '"' && quote != '\'' {
return s
Expand Down
8 changes: 4 additions & 4 deletions vfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use.
This is where velocifilter comes in. By using the library we can
provide a single flag where the user may specify a flexible VQL query
(Velocidex Query Language - a simplified SQL dialect) allowing the
user to specify arbirarily complex filter expressions. For example:
user to specify arbitrarily complex filter expressions. For example:

SELECT file from glob(pattern=["*.go", "*.py"]) where file.Size < 5000
and file.Mtime < now() - "5 days"
Expand Down Expand Up @@ -81,7 +81,7 @@ package to add an interface to an existing type without creating a new
type which embeds it. Clients who need to handle the original third
party types must have a way to attach new protocols to existing types
defined outside their own codebase. Velocifilter achieves this by
implementing a registration systen in the Scope{} object.
implementing a registration system in the Scope{} object.

For example, consider a client of the library wishing to pass custom
types in queries:
Expand Down Expand Up @@ -331,7 +331,7 @@ type _ParameterListTerm struct {

// Returns the type of statement it is:
// LAZY_LET - A lazy stored query
// MATERIALIZED_LET - A stored meterialized query.
// MATERIALIZED_LET - A stored materialized query.
// SELECT - A query
func (self *VQL) Type() string {
if self.LetOperator == "=" {
Expand Down Expand Up @@ -966,7 +966,7 @@ func (self *_SelectExpression) Transform(

// If there is a * expression in addition to the column
// expressions, this is equivalent to adding all the columns as
// defined by the * as if they were explicitely defined.
// defined by the * as if they were explicitly defined.
if self.All {
for _, member := range scope.GetMembers(row) {
value, pres := scope.Associative(row, member)
Expand Down
2 changes: 1 addition & 1 deletion vfilter_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (self *GroupbyActor) GetNextRow(ctx context.Context, scope types.Scope) (
}

// Materialize the group by value as much as possible - we
// dont want a lazy item here.
// don't want a lazy item here.
gb_element := types.ToString(ctx, new_scope,
self.delegate.GroupBy.Reduce(ctx, new_scope))

Expand Down
4 changes: 2 additions & 2 deletions vfilter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ var execTestsSerialization = []execTest{
{"'Hello'[-2:300]", "lo"},
{"'Hello'[-3:]", "llo"},

// Rgexp operator
// Regexp operator
{"'Hello' =~ '.'", true},

// . matches anything including the empty string (it is optimized away).
Expand Down Expand Up @@ -564,7 +564,7 @@ var vqlTests = []vqlTest{

// The below query demonstrates that the query() function is
// run on every row returned from the filter, and then the
// output is filtered by the the where clause. Be aware that
// output is filtered by the where clause. Be aware that
// this may be expensive if test() returns many rows.
{"Subselect functions in filter.",
`select bar, {select * from dict(column=bar)} as Query
Expand Down
16 changes: 8 additions & 8 deletions visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
IndentWidthThreshold: 50,
MaxWidthThreshold: 80,

// If false we dont break lines at all - all tokens are
// If false we don't break lines at all - all tokens are
// written on the same line.
BreakLines: true,
}
Expand All @@ -43,7 +43,7 @@ var (
)

type FormatOptions struct {
// Threshold above which we indent more aggresively on new
// Threshold above which we indent more aggressively on new
// lines. Below the threshold we try to keep lines together.
IndentWidthThreshold int
MaxWidthThreshold int
Expand Down Expand Up @@ -197,7 +197,7 @@ func (self *Visitor) line_break() {
last_fragment = self.Fragments[len(self.Fragments)-1]
}

// Format all on the same line. Strictly we dont actually need
// Format all on the same line. Strictly we don't actually need
// spaces but we add them for readability.
if !self.opts.BreakLines {
switch last_fragment {
Expand Down Expand Up @@ -474,7 +474,7 @@ func (self *Visitor) visitAliasedExpression(node *_AliasedExpression) {
} else if node.SubSelect != nil {
self.push("{", " ")

// We prefer the subquery to start at the begining of the line
// We prefer the subquery to start at the beginning of the line
// with a little indent.
if self.opts.BreakLines {
self.new_line(2)
Expand Down Expand Up @@ -814,7 +814,7 @@ func (self *Visitor) visitArgs(node *_Args) {
} else if node.SubSelect != nil {
self.push(node.Left, "={")

// We prefer subquery to start at the begining of the line
// We prefer subquery to start at the beginning of the line
// with a small indent.
if self.opts.BreakLines {
self.new_line(2)
Expand Down Expand Up @@ -1195,7 +1195,7 @@ func (self *Visitor) abTest(
}
}

// When not in reformat mode we really dont care which option
// When not in reformat mode we really don't care which option
// we choose.
if !self.opts.BreakLines {
self.merge(test_visitor)
Expand All @@ -1221,7 +1221,7 @@ func (self *Visitor) abTest(

// Is the other visitor better than this one?
func (self *Visitor) is_better(other *Visitor) bool {
// Most important priority is to ensure we dont exceed the max
// Most important priority is to ensure we don't exceed the max
// width by much.
/*
fmt.Printf("self %v (%v lines)\n%v\n - other %v (%v lines)\n%v\n",
Expand All @@ -1230,7 +1230,7 @@ func (self *Visitor) is_better(other *Visitor) bool {
*/
max_width := self.opts.MaxWidthThreshold

// If the other formatting exceeds the max line number but we dont
// If the other formatting exceeds the max line number but we don't
// then reject it.
if other.max_width > max_width && self.max_width < max_width {
return false
Expand Down
Loading