-
Notifications
You must be signed in to change notification settings - Fork 125
gitbase: implement sql.Indexable on all tables #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gitbase: implement sql.Indexable on all tables #298
Conversation
Signed-off-by: Miguel Molina <[email protected]>
Related: src-d/go-git#854 |
commits.go
Outdated
@@ -261,3 +294,107 @@ func (i *commitsByHashIter) nextList() (*object.Commit, error) { | |||
return commit, nil | |||
} | |||
} | |||
|
|||
type commitIndexKey struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a generic ObjectIndexKey
struct for all the objects that are into the packfile?
Only commit and blob have the struct totally in common. Tree entries also needs the pos inside the tree and the rest of the tables are very different. I can make one common object for blobs and commits tho.
On Tue, 5 Jun 2018 at 18:51, Antonio Navarro Perez <[email protected]<mailto:[email protected]>> wrote:
@ajnavarro commented on this pull request.
________________________________
In commits.go<#298 (comment)>:
@@ -261,3 +294,107 @@ func (i *commitsByHashIter) nextList() (*object.Commit, error) {
return commit, nil
}
}
+
+type commitIndexKey struct {
Could we have a generic ObjectIndexKey struct for all the objects that are into the packfile?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#298 (review)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABQFFw_m3GywQHDl9yjWrDGTARu2rRCqks5t5rclgaJpZM4Ua80z>.
|
Added the tests and some fixes, along with the unification of the index keys where it was possible. It can be reviewed now. |
go-git 4.4.1 has dotgit logic outside |
@ajnavarro Since this is against a feature branch and won't go straight to master, what do you think if we review and merge this one first and then in a followup PR I update the dependency and replace the manual impl with the dotgit one? |
packfiles.go
Outdated
}, nil | ||
} | ||
} | ||
|
||
func (i *objectIter) Close() error { | ||
if i.packObjects != nil { | ||
/*if i.packObjects != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Miguel Molina <[email protected]>
Signed-off-by: Miguel Molina <[email protected]>
Fixed errors in travis |
Signed-off-by: Miguel Molina <[email protected]>
Signed-off-by: Miguel Molina <[email protected]>
cmd/gitbase/command/server.go
Outdated
User string `short:"u" long:"user" default:"root" description:"User name used for connection"` | ||
Password string `short:"P" long:"password" default:"" description:"Password used for connection"` | ||
PilosaURL string `long:"pilosa" default:"http://localhost:10101" description:"URL to your pilosa server"` | ||
IndexDir string `short:"i" long:"index" default:"/var/gitbase/index" description:"Directory where the gitbase indexes information will be persisted."` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should change the default path. What do you think @jfontan ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What path should we change it to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually software does not have var directories directly in /var
but in one of its subdirectories. MySQL has its database files in /var/lib/mysql
. /var/lib/gitbase/index
seems ok.
cmd/gitbase/command/server.go
Outdated
@@ -104,6 +110,18 @@ func (c *Server) buildDatabase() error { | |||
c.engine.Catalog.RegisterFunctions(function.Functions) | |||
logrus.Debug("registered all available functions in catalog") | |||
|
|||
if err := os.MkdirAll(c.IndexDir, 0755); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add some log on these new steps?
} | ||
} | ||
|
||
func (i *filesKeyValueIter) Close() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should call this on tests too.
|
||
var iter sql.RowIter = &rowIndexIter{index} | ||
|
||
if len(filters) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we test this with some filter?
Check codecov, appears that squash_join is not tested at all. |
Signed-off-by: Miguel Molina <[email protected]>
Signed-off-by: Miguel Molina <[email protected]>
Fixed the coverage thing of the squash tables |
Signed-off-by: Miguel Molina <[email protected]>
Changed the default index directory |
remotes.go
Outdated
columns, filters []sql.Expression, | ||
index sql.IndexValueIter, | ||
) (sql.RowIter, error) { | ||
span, ctx := ctx.Span("gitbase.ReferencesTable.WithProjectFiltersAndIndex") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be "gitbase.RemotesTable.WithProjectFiltersAndIndex"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Signed-off-by: Miguel Molina <[email protected]>
Signed-off-by: Miguel Molina <[email protected]>
Signed-off-by: Miguel Molina <[email protected]>
Signed-off-by: Miguel Molina <[email protected]>
Signed-off-by: Miguel Molina <[email protected]>
Everything is fixed now, upgraded go-mysql-server and added engine initialization to the server command. |
Most of the contents in #279 did not survive because they relied on the index being something generic for all tables when in reality, almost every table has its own logic regarding the index storage.
This implementation differs a lot from what was initially thought in #295. The way the indexes work made it impossible to work that way.
There is also a lot of code that is inside go-git, but that logic is not exposed. If it's ever exposed we might want to refactor some of that.
To sum it up, the implementation looks like this:
ref_commits
,commit_trees
andcommit_blobs
there is a common logicrowKeyValueIter
androwIndexIter
, since they are stored as is. The other tables had no obvious common logic, so instead of coming up with an abstraction that might be a PITA in the future, I preferred to have some more tedious and perhaps slightly repeating implementations on the other iterators (though there are no exact identical impls).