You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@parquet.apache.org by zi...@apache.org on 2018/09/18 11:39:02 UTC
[parquet-mr] branch master updated: PARQUET-1353: Fix random data
generator. (#504)
This is an automated email from the ASF dual-hosted git repository.
zivanfi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-mr.git
The following commit(s) were added to refs/heads/master by this push:
new 1f79f9b PARQUET-1353: Fix random data generator. (#504)
1f79f9b is described below
commit 1f79f9bd0ba61b8ec0bae1dec71ef7249d41eacd
Author: Zoltan Ivanfi <zi...@apache.org>
AuthorDate: Tue Sep 18 13:38:56 2018 +0200
PARQUET-1353: Fix random data generator. (#504)
The random data generator used for tests used to repeat the same value
over and over again.
---
.../src/test/java/org/apache/parquet/statistics/RandomValues.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/parquet-hadoop/src/test/java/org/apache/parquet/statistics/RandomValues.java b/parquet-hadoop/src/test/java/org/apache/parquet/statistics/RandomValues.java
index 16db5cb..a3f41e9 100644
--- a/parquet-hadoop/src/test/java/org/apache/parquet/statistics/RandomValues.java
+++ b/parquet-hadoop/src/test/java/org/apache/parquet/statistics/RandomValues.java
@@ -84,19 +84,18 @@ public class RandomValues {
static abstract class RandomBinaryBase<T extends Comparable<T>> extends RandomValueGenerator<T> {
protected final int bufferLength;
- protected final byte[] buffer;
public RandomBinaryBase(long seed, int bufferLength) {
super(seed);
this.bufferLength = bufferLength;
- this.buffer = new byte[bufferLength];
}
public abstract Binary nextBinaryValue();
public Binary asReusedBinary(byte[] data) {
int length = Math.min(data.length, bufferLength);
+ byte[] buffer = new byte[length];
System.arraycopy(data, 0, buffer, 0, length);
return Binary.fromReusedByteArray(data, 0, length);
}
@@ -287,7 +286,8 @@ public class RandomValues {
@Override
public Binary nextValue() {
// use a random length, but ensure it is at least a few bytes
- int length = 5 + randomPositiveInt(buffer.length - 5);
+ int length = 5 + randomPositiveInt(bufferLength - 5);
+ byte[] buffer = new byte[length];
for (int index = 0; index < length; index++) {
buffer[index] = (byte) randomInt();
}
@@ -308,6 +308,7 @@ public class RandomValues {
@Override
public Binary nextValue() {
+ byte[] buffer = new byte[bufferLength];
for (int index = 0; index < buffer.length; index++) {
buffer[index] = (byte) randomInt();
}