Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

packfile: delta selection logic #182

Merged
merged 3 commits into from
Dec 16, 2016
Merged

packfile: delta selection logic #182

merged 3 commits into from
Dec 16, 2016

Conversation

ajnavarro
Copy link
Contributor

  • Implemented logic to assign deltas to objects

@ajnavarro ajnavarro changed the title Feature/delta selection packfile: delta selection logic Dec 13, 2016
@ajnavarro
Copy link
Contributor Author

Please, merge #172 first

. "gopkg.in/check.v1"
)

type DeltaSelectorSuite struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smola @mcuadros @alcortesm Some ideas for testing deltaSelector more deeply?

)

const (
// deltas based on deltas, how much steps we can do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"how much" -> "how many"
clarify that it is 50 as implemented in jgit


type deltaSelector struct {
storer storer.ObjectStorer
depths map[plumbing.Hash]int
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"depths" not used?

)

// set of object types that we should apply deltas
var applyDelta = map[plumbing.ObjectType]bool{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"set of object types that we should apply deltas" -> "applyDelta is the set of object types that we should apply deltas"

}

func newDeltaSelector(s storer.ObjectStorer) *deltaSelector {
return &deltaSelector{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

single line

}
}

func (dw *deltaSelector) getObjectsToPack(hashes []plumbing.Hash) ([]*plumbing.ObjectToPack, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getObjectsToPack -> objectsToPack


// GetObjectsToPack creates a list of ObjectToPack from the hashes provided,
// creating deltas if it's suitable, using an specific internal logic
func (dw *deltaSelector) GetObjectsToPack(hashes []plumbing.Hash) ([]*plumbing.ObjectToPack, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetObjectsToPack -> ObjectsToPack

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put public methods first in the file.

}
}

return deltaToPack, nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of returning a new ObjectToPack, you could just set the base, delta and depth. Maybe something like:
target.SetBase(*ObjectToPack)

s.ds = newDeltaSelector(s.store)
}

func (s *DeltaSelectorSuite) TestTryOrder(c *C) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TestTryOrder -> Testsort

c.Assert(toSort, DeepEquals, expected)
}

func (s *DeltaSelectorSuite) TestTryToDeltify(c *C) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test ObjectstoPack method, instead of the internal tryToDeltify?

// Delta Size Limit with no best delta yet
bestDelta, err = s.ds.tryToDeltify(base, target)
c.Assert(err, IsNil)
//c.Assert(bestDelta, IsNil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code?

@codecov-io
Copy link

codecov-io commented Dec 13, 2016

Current coverage is 77.51% (diff: 87.37%)

Merging #182 into master will decrease coverage by 0.27%

@@             master       #182   diff @@
==========================================
  Files            93         94     +1   
  Lines          5953       6017    +64   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           4631       4664    +33   
- Misses          836        879    +43   
+ Partials        486        474    -12   

Powered by Codecov. Last update 63c66c9...0f0e278

@mcuadros
Copy link
Contributor

@ajnavarro rebase

@ajnavarro
Copy link
Contributor Author

@mcuadros rebased

@@ -0,0 +1,28 @@
package packfile

import "gopkg.in/src-d/go-git.v4/plumbing"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you put a common_test.go, put the "testing" hook here.

break
}

err := dw.tryToDeltify(base, target)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if err := ...

return err
}

// if delta better than target
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should go inside an if block.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mcuadros mcuadros merged commit 8346705 into src-d:master Dec 16, 2016
mcuadros pushed a commit that referenced this pull request Jan 31, 2017
* packfile: delta selection logic

- Implemented logic to assign deltas to objects

* Requested changes

* Improved tests and fix errors
gsalingu-ovhus pushed a commit to gsalingu-ovhus/go-git that referenced this pull request Mar 28, 2019
Disable HTTP caching when the upload is OneShot
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants