-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.go
77 lines (64 loc) · 1.7 KB
/
interface.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package benchtop
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsontype"
)
type FieldFilter struct {
Field string
Operator string // supported operators "==", "!=", ">", "<", ">=", "<=", "contains", "startswith", "endswith"
Value any
}
type TableInfo struct {
Id uint32 `json:"id"`
FileName string `json:"fileName"`
Columns []ColumnDef `json:"columns"`
}
type ColumnDef struct {
Key string `json:"key"`
Type FieldType `json:"type"`
}
type TableDriver interface {
New(name string, columns []ColumnDef) (TableStore, error)
Get(name string) (TableStore, error)
GetAllColNames() chan string
GetLabels(edges bool) chan string
List() []string
Delete(name string) error
Close()
}
type Row struct {
Id []byte
TableName string
Data map[string]any
}
type Index struct {
Key []byte
Position uint64
Size uint64
}
type BulkResponse struct {
Key []byte
Data map[string]any
Err string
}
type TableStore interface {
GetColumnDefs() []ColumnDef
AddRow(elem Row) error
GetRow(key []byte, fields ...string) (map[string]any, error)
DeleteRow(key []byte) error
Fetch(inputs chan Index, workers int) <-chan BulkResponse
Remove(inputs chan Index, workers int) <-chan BulkResponse
Scan(key bool, filter []FieldFilter, fields ...string) (chan map[string]any, error)
Load(chan Row) error
Keys() (chan Index, error)
Compact() error
Close()
}
type FieldType bsontype.Type
const (
Double FieldType = FieldType(bson.TypeDouble)
Int64 FieldType = FieldType(bson.TypeInt64)
String FieldType = FieldType(bson.TypeString)
Bytes FieldType = FieldType(bson.TypeBinary)
VectorArray FieldType = FieldType(bson.TypeArray)
)