/
plan.go
45 lines (40 loc) · 1.62 KB
/
plan.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package plan
import (
"github.com/Dong-Chan/alloydb/context"
"github.com/Dong-Chan/alloydb/expression"
"github.com/Dong-Chan/alloydb/field"
"github.com/Dong-Chan/alloydb/util/format"
)
// RowIterFunc is the callback for iterating records.
type RowIterFunc func(id interface{}, data []interface{}) (more bool, err error)
// Plan is the interface of query execution plan.
type Plan interface {
// Do iterates records and applies plan logic to the result set.
// TODO: only get id or some fields.
Do(ctx context.Context, f RowIterFunc) error
// Explain the plan.
Explain(w format.Formatter)
// GetFields returns the result field list for a plan.
GetFields() []*field.ResultField
// Filter try to use index plan to reduce the result set.
// If index can be used, a new index plan is returned, 'filtered' is true.
// If no index can be used, the original plan is returned and 'filtered' return false.
Filter(ctx context.Context, expr expression.Expression) (p Plan, filtered bool, err error)
}
// Planner is implemented by any structure that has a Plan method.
type Planner interface {
// Plan function returns Plan.
Plan(ctx context.Context) (Plan, error)
}