Skip to content

Commit

Permalink
Add uncompressDoubleArray that takes offset and length (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-taylor authored Jan 28, 2023
1 parent 2bc841b commit 34fa6e9
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/java/org/xerial/snappy/Snappy.java
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,24 @@ public static char[] uncompressCharArray(byte[] input, int offset, int length)
public static double[] uncompressDoubleArray(byte[] input)
throws IOException
{
int uncompressedLength = Snappy.uncompressedLength(input, 0, input.length);
return uncompressDoubleArray(input, 0, input.length);
}

/**
* Uncompress the input as a double array
*
* @param input
* @param offset
* @param length
* @return the uncompressed data
* @throws IOException
*/
public static double[] uncompressDoubleArray(byte[] input, int offset, int length)
throws IOException
{
int uncompressedLength = Snappy.uncompressedLength(input, offset, length);
double[] result = new double[uncompressedLength / 8];
impl.rawUncompress(input, 0, input.length, result, 0);
impl.rawUncompress(input, offset, length, result, 0);
return result;
}

Expand Down

0 comments on commit 34fa6e9

Please sign in to comment.