Skip to content

Commit

Permalink
Merge pull request #25 from wkalt/task/statistical-filtering
Browse files Browse the repository at this point in the history
Leverage statistics in querying
  • Loading branch information
wkalt committed May 20, 2024
2 parents 0f19847 + 42154eb commit c91e0e6
Show file tree
Hide file tree
Showing 15 changed files with 1,016 additions and 96 deletions.
15 changes: 14 additions & 1 deletion executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

fmcap "github.com/foxglove/mcap/go/mcap"
"github.com/wkalt/dp3/mcap"
"github.com/wkalt/dp3/nodestore"
"github.com/wkalt/dp3/plan"
"github.com/wkalt/dp3/tree"
"github.com/wkalt/dp3/util"
Expand Down Expand Up @@ -96,6 +97,7 @@ type ScanFactory func(
table string,
descending bool,
start, end uint64,
childFilter func(*nodestore.Child) (bool, error),
) (*tree.Iterator, error)

// CompilePlan compiles a "plan tree" -- a tree of plan nodes -- to a tree of
Expand Down Expand Up @@ -231,10 +233,21 @@ func compileScan(ctx context.Context, node *plan.Node, sf ScanFactory) (Node, er
return nil, fmt.Errorf("expected uint64 end time, got %T", node.Args[5])
}
}
it, err := sf(ctx, database, producer, table, node.Descending, start, end)

var childFilter func(*nodestore.Child) (bool, error)
if len(node.Children) > 0 {
childFilter, err = NewStatFilter(node.Children[0])
if err != nil {
return nil, err
}
}

// pass expression right here!
it, err := sf(ctx, database, producer, table, node.Descending, start, end, childFilter)
if err != nil {
return nil, err
}

scan := NewScanNode(table, it)
if len(node.Children) > 0 {
expr := newExpression(util.When(alias != "", alias, table), node.Children[0])
Expand Down
Loading

0 comments on commit c91e0e6

Please sign in to comment.