Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
QueryR
Commits
67ecb276
Commit
67ecb276
authored
8 years ago
by
Mick Jordan
Browse files
Options
Downloads
Patches
Plain Diff
Use xz internal for RCompression.lzmaUncompressFromFile
parent
f222f71e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RCompression.java
+25
-1
25 additions, 1 deletion
...untime/src/com/oracle/truffle/r/runtime/RCompression.java
with
25 additions
and
1 deletion
com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RCompression.java
+
25
−
1
View file @
67ecb276
...
...
@@ -28,12 +28,15 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.lang.ProcessBuilder.Redirect
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.zip.GZIPInputStream
;
import
com.oracle.truffle.r.runtime.conn.GZIPConnections.GZIPRConnection
;
import
com.oracle.truffle.r.runtime.ffi.RFFIFactory
;
import
org.tukaani.xz.LZMA2InputStream
;
import
org.tukaani.xz.XZInputStream
;
/**
* Abstracts the implementation of the various forms of compression used in R.
...
...
@@ -180,7 +183,28 @@ public class RCompression {
* This is used by {@link GZIPRConnection}.
*/
public
static
byte
[]
lzmaUncompressFromFile
(
String
path
)
{
return
genericUncompressFromFile
(
new
String
[]{
"xz"
,
"--decompress"
,
"--lzma2"
,
"--stdout"
,
path
});
try
{
byte
[]
data
=
Files
.
readAllBytes
(
Paths
.
get
(
path
));
byte
[]
buffer
=
new
byte
[
data
.
length
*
4
];
try
(
XZInputStream
lzmaStream
=
new
XZInputStream
(
new
ByteArrayInputStream
(
data
)))
{
int
totalRead
=
0
;
int
n
;
while
((
n
=
lzmaStream
.
read
(
buffer
,
totalRead
,
buffer
.
length
-
totalRead
))
>
0
)
{
totalRead
+=
n
;
if
(
totalRead
==
buffer
.
length
)
{
byte
[]
newbuffer
=
new
byte
[
buffer
.
length
*
2
];
System
.
arraycopy
(
buffer
,
0
,
newbuffer
,
0
,
buffer
.
length
);
buffer
=
newbuffer
;
}
}
byte
[]
result
=
new
byte
[
totalRead
];
System
.
arraycopy
(
buffer
,
0
,
result
,
0
,
totalRead
);
return
result
;
}
}
catch
(
IOException
ex
)
{
throw
RInternalError
.
shouldNotReachHere
(
ex
);
}
}
public
static
byte
[]
bzipUncompressFromFile
(
String
path
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment