Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Obtain blob size efficiently(Given an object id referring to a blob, can I know its (uncompressed) size efficiently?)
Obtain blob size efficiently [message #1837259] Tue, 26 January 2021 10:37 Go to next message
Olivier Cailloux is currently offline Olivier CaillouxFriend
Messages: 37
Registered: July 2009
Member
I have a bunch of object ids referring to blobs in a given git repository.

Using JGit, I would like to obtain the sizes of these blobs. That is, the number of bytes their content represent (uncompressed, thus).

If I understand correctly, this information is stored in git in a way that permits fast access to it.

But the way I currently access it through JGit is slow. It often takes several tens of milliseconds to get a blob size. (See code below.) If I understand correctly, JGit reads the whole blob when it is small enough, a waste of time in my case as I most often only need the size. (I am ready to pay an extra access time cost if I then need to access the blob content.)

Can I get a blob size faster?

Here is my current code. Given a FileRepository repository and reader = repository.newObjectReader() (initialized only once).

long getSize(ObjectId objectId) throws IOException {
	ObjectLoader fileLoader = reader.open(objectId);
	return fileLoader.getSize();
}


Oddly enough, setting reader.setStreamFileThreshold(8); does not seem to help.

[Updated on: Tue, 26 January 2021 10:42]

Report message to a moderator

Re: Obtain blob size efficiently [message #1837563 is a reply to message #1837259] Tue, 02 February 2021 13:29 Go to previous message
Olivier Cailloux is currently offline Olivier CaillouxFriend
Messages: 37
Registered: July 2009
Member
Asked here.
Previous Topic:Unable to add subproject to commit
Next Topic:git-upload-pack: not found
Goto Forum:
  


Current Time: Sat Jun 19 10:47:58 GMT 2021

Powered by FUDForum. Page generated in 0.01821 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top