This repository was archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 534
plumbing: cache, enforce the use of cache in packfile decoder #698
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,15 +80,20 @@ type Decoder struct { | |
// If the ObjectStorer implements storer.Transactioner, a transaction is created | ||
// during the Decode execution. If anything fails, Rollback is called | ||
func NewDecoder(s *Scanner, o storer.EncodedObjectStorer) (*Decoder, error) { | ||
return NewDecoderForType(s, o, plumbing.AnyObject) | ||
return NewDecoderForType(s, o, plumbing.AnyObject, | ||
cache.NewObjectLRUDefault()) | ||
} | ||
|
||
// NewDecoderForType returns a new Decoder but in this case for a specific object type. | ||
// When an object is read using this Decoder instance and it is not of the same type of | ||
// the specified one, nil will be returned. This is intended to avoid the content | ||
// deserialization of all the objects | ||
// deserialization of all the objects. | ||
// | ||
// cacheObject is an ObjectLRU that is used to speed up the process. If cache | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cache instance can be any implementation of cache.Object |
||
// is not needed you can pass nil. To create a cache object with the default | ||
// size you an use the helper cache.ObjectLRUDefault(). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/an/can/ |
||
func NewDecoderForType(s *Scanner, o storer.EncodedObjectStorer, | ||
t plumbing.ObjectType) (*Decoder, error) { | ||
t plumbing.ObjectType, cacheObject cache.Object) (*Decoder, error) { | ||
|
||
if t == plumbing.OFSDeltaObject || | ||
t == plumbing.REFDeltaObject || | ||
|
@@ -101,8 +106,9 @@ func NewDecoderForType(s *Scanner, o storer.EncodedObjectStorer, | |
} | ||
|
||
return &Decoder{ | ||
s: s, | ||
o: o, | ||
s: s, | ||
o: o, | ||
DeltaBaseCache: cacheObject, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make DeltaBaseCache private? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've addressed these issues in the following commits. |
||
|
||
idx: NewIndex(0), | ||
offsetToType: make(map[int64]plumbing.ObjectType), | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
no tested function
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.
Now cache tests are done twice. One with the previous cache and another time with a cache created with
NewObjectLRUDefault
.