File tree Expand file tree Collapse file tree 14 files changed +42
-50
lines changed Expand file tree Collapse file tree 14 files changed +42
-50
lines changed Original file line number Diff line number Diff line change 26
26
)
27
27
28
28
type blobsTable struct {
29
+ partitioned
29
30
filters []sql.Expression
30
31
projection []string
31
32
index sql.IndexLookup
@@ -83,10 +84,6 @@ func (r *blobsTable) IndexLookup() sql.IndexLookup { return r.index }
83
84
func (r * blobsTable ) Filters () []sql.Expression { return r .filters }
84
85
func (r * blobsTable ) Projection () []string { return r .projection }
85
86
86
- func (r * blobsTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
87
- return newRepositoryPartitionIter (ctx )
88
- }
89
-
90
87
func (r * blobsTable ) PartitionRows (
91
88
ctx * sql.Context ,
92
89
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
)
11
11
12
12
type commitBlobsTable struct {
13
+ partitioned
13
14
filters []sql.Expression
14
15
index sql.IndexLookup
15
16
}
@@ -55,10 +56,6 @@ func (t *commitBlobsTable) WithIndexLookup(idx sql.IndexLookup) sql.Table {
55
56
func (t * commitBlobsTable ) IndexLookup () sql.IndexLookup { return t .index }
56
57
func (t * commitBlobsTable ) Filters () []sql.Expression { return t .filters }
57
58
58
- func (t * commitBlobsTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
59
- return newRepositoryPartitionIter (ctx )
60
- }
61
-
62
59
func (t * commitBlobsTable ) PartitionRows (
63
60
ctx * sql.Context ,
64
61
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
)
15
15
16
16
type commitFilesTable struct {
17
+ partitioned
17
18
filters []sql.Expression
18
19
index sql.IndexLookup
19
20
}
@@ -60,10 +61,6 @@ func (t *commitFilesTable) WithIndexLookup(idx sql.IndexLookup) sql.Table {
60
61
func (t * commitFilesTable ) IndexLookup () sql.IndexLookup { return t .index }
61
62
func (t * commitFilesTable ) Filters () []sql.Expression { return t .filters }
62
63
63
- func (t * commitFilesTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
64
- return newRepositoryPartitionIter (ctx )
65
- }
66
-
67
64
func (t * commitFilesTable ) PartitionRows (
68
65
ctx * sql.Context ,
69
66
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
12
12
)
13
13
14
14
type commitTreesTable struct {
15
+ partitioned
15
16
filters []sql.Expression
16
17
index sql.IndexLookup
17
18
}
@@ -56,10 +57,6 @@ func (t *commitTreesTable) WithIndexLookup(idx sql.IndexLookup) sql.Table {
56
57
func (t * commitTreesTable ) IndexLookup () sql.IndexLookup { return t .index }
57
58
func (t * commitTreesTable ) Filters () []sql.Expression { return t .filters }
58
59
59
- func (t * commitTreesTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
60
- return newRepositoryPartitionIter (ctx )
61
- }
62
-
63
60
func (t * commitTreesTable ) PartitionRows (
64
61
ctx * sql.Context ,
65
62
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
)
11
11
12
12
type commitsTable struct {
13
+ partitioned
13
14
filters []sql.Expression
14
15
index sql.IndexLookup
15
16
}
@@ -66,10 +67,6 @@ func (r *commitsTable) WithIndexLookup(idx sql.IndexLookup) sql.Table {
66
67
func (r * commitsTable ) IndexLookup () sql.IndexLookup { return r .index }
67
68
func (r * commitsTable ) Filters () []sql.Expression { return r .filters }
68
69
69
- func (r * commitsTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
70
- return newRepositoryPartitionIter (ctx )
71
- }
72
-
73
70
func (r * commitsTable ) PartitionRows (
74
71
ctx * sql.Context ,
75
72
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
11
11
)
12
12
13
13
type filesTable struct {
14
+ partitioned
14
15
filters []sql.Expression
15
16
projection []string
16
17
index sql.IndexLookup
@@ -61,10 +62,6 @@ func (r *filesTable) IndexLookup() sql.IndexLookup { return r.index }
61
62
func (r * filesTable ) Filters () []sql.Expression { return r .filters }
62
63
func (r * filesTable ) Projection () []string { return r .projection }
63
64
64
- func (r * filesTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
65
- return newRepositoryPartitionIter (ctx )
66
- }
67
-
68
65
func (r * filesTable ) PartitionRows (
69
66
ctx * sql.Context ,
70
67
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -7,8 +7,27 @@ import (
7
7
"gopkg.in/src-d/go-mysql-server.v0/sql"
8
8
)
9
9
10
+ // partitioned is an embeddable helper that contains the methods for a table
11
+ // that is partitioned by repository.
12
+ type partitioned struct {}
13
+
14
+ func (partitioned ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
15
+ return newRepositoryPartitionIter (ctx )
16
+ }
17
+
18
+ func (partitioned ) PartitionCount (ctx * sql.Context ) (int64 , error ) {
19
+ s , err := getSession (ctx )
20
+ if err != nil {
21
+ return 0 , err
22
+ }
23
+
24
+ return int64 (len (s .Pool .repositories )), nil
25
+ }
26
+
27
+ // RepositoryPartition represents a partition which is a repository id.
10
28
type RepositoryPartition string
11
29
30
+ // Key implements the sql.Partition interface.
12
31
func (p RepositoryPartition ) Key () []byte {
13
32
return []byte (p )
14
33
}
@@ -41,6 +60,8 @@ func (i *repositoryPartitionIter) Close() error {
41
60
return nil
42
61
}
43
62
63
+ // ErrNoRepositoryPartition is returned when the partition is not a valid
64
+ // repository partition.
44
65
var ErrNoRepositoryPartition = errors .NewKind ("%T not a valid repository partition" )
45
66
46
67
func getPartitionRepo (ctx * sql.Context , p sql.Partition ) (* Repository , error ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import (
13
13
)
14
14
15
15
type refCommitsTable struct {
16
+ partitioned
16
17
filters []sql.Expression
17
18
index sql.IndexLookup
18
19
}
@@ -59,10 +60,6 @@ func (t *refCommitsTable) WithIndexLookup(idx sql.IndexLookup) sql.Table {
59
60
func (t * refCommitsTable ) IndexLookup () sql.IndexLookup { return t .index }
60
61
func (t * refCommitsTable ) Filters () []sql.Expression { return t .filters }
61
62
62
- func (t * refCommitsTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
63
- return newRepositoryPartitionIter (ctx )
64
- }
65
-
66
63
func (t * refCommitsTable ) PartitionRows (
67
64
ctx * sql.Context ,
68
65
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import (
14
14
)
15
15
16
16
type referencesTable struct {
17
+ partitioned
17
18
filters []sql.Expression
18
19
index sql.IndexLookup
19
20
}
@@ -62,10 +63,6 @@ func (r *referencesTable) WithIndexLookup(idx sql.IndexLookup) sql.Table {
62
63
func (r * referencesTable ) IndexLookup () sql.IndexLookup { return r .index }
63
64
func (r * referencesTable ) Filters () []sql.Expression { return r .filters }
64
65
65
- func (r * referencesTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
66
- return newRepositoryPartitionIter (ctx )
67
- }
68
-
69
66
func (r * referencesTable ) PartitionRows (
70
67
ctx * sql.Context ,
71
68
p sql.Partition ,
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
)
11
11
12
12
type remotesTable struct {
13
+ partitioned
13
14
filters []sql.Expression
14
15
index sql.IndexLookup
15
16
}
@@ -61,10 +62,6 @@ func (r *remotesTable) WithIndexLookup(idx sql.IndexLookup) sql.Table {
61
62
func (r * remotesTable ) IndexLookup () sql.IndexLookup { return r .index }
62
63
func (r * remotesTable ) Filters () []sql.Expression { return r .filters }
63
64
64
- func (r * remotesTable ) Partitions (ctx * sql.Context ) (sql.PartitionIter , error ) {
65
- return newRepositoryPartitionIter (ctx )
66
- }
67
-
68
65
func (r * remotesTable ) PartitionRows (
69
66
ctx * sql.Context ,
70
67
p sql.Partition ,
You can’t perform that action at this time.
0 commit comments