Skip to main content



      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 05:37 Go to next message
Eclipse UserFriend
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 05:42] by Moderator

Re: Obtain blob size efficiently [message #1837563 is a reply to message #1837259] Tue, 02 February 2021 08:29 Go to previous message
Eclipse UserFriend
Asked here.
Previous Topic:Unable to add subproject to commit
Next Topic:git-upload-pack: not found
Goto Forum:
  


Current Time: Wed May 07 05:27:56 EDT 2025

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

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

Back to the top