Maximum sliceable file size

39 views
Skip to first unread message

Trogdan

unread,
Apr 3, 2012, 10:36:41 PM4/3/12
to lib-gwt-file
So currently lib-gwt-file Blob.java and associated FileSlice classes
use a java int for the file sizes and offsets. This limits the
maximum file size to be approximately 2 GB ( -2,147,483,648 to
2,147,483,647)

I tried to play around with native long, Long object, and native long
with annotated with the mysterious "UnsafeNativeLong" provided by
gwt. I couldn't get either of those methods without an
UmbrellaException popping up.

I modified my snapshot of Blob.java and FileSlice(s).java to use
double, this seemed to be the only type to work, since Javascript
stores all it's numerical representations as a 8 byte float. It's not
how I like to represent file offsets, but it will have to do for now.

Lukas Laag

unread,
Apr 4, 2012, 4:44:14 PM4/4/12
to lib-gw...@googlegroups.com
Hi Trogdan,

I believe there are different limitations which need to be taken into account:
+ The JavaScript Number type, which can represent integers up to 2^53
+ The Java long type, which can represent integers up to 2^64
+ The actual implementation of slice (I do not know what C type they
use internally. Hopefully that would be a size_t or something like
that, but one would have to look at the actual code to be sure).

Then there is the question of conversions. GWT represents java long as
some kind of struct containing two 32-bits numbers and they have a
library to deal with that.

I believe we could raise the bar a bit a allow for file size and
offsets up to 2^53, by doing the following:
+ use the long type in the GWT API everywhere a file size or a file
offset is required.
+ use strings to pass the parameters between Java and JavaScript

I have created a new branch on github to prototype this (called
big-files). Let me know what you think about it. Notably if you have a
way to test that against truly big files (> 2GB), I'd be glad to hear
if it actually solves the problem.

Regards

Lukas

Greve Dan

unread,
Apr 4, 2012, 8:19:45 PM4/4/12
to lib-gw...@googlegroups.com
Lukas,

Current trunk on webkit uses a long long...

Moz is using unsigned long long

 I'll try to get some code up this weekend, that will make use of the new branch and provide some feedback.

Dan
Reply all
Reply to author
Forward
0 new messages