use of org.apache.hadoop.hive.ql.exec.vector.rowbytescontainer.VectorRowBytesContainer in project hive by apache.
the class TestVectorRowBytesContainer method doFillReplay.
public void doFillReplay(Random random, int maxCount) throws Exception {
RandomByteArrayStream randomByteArrayStream = new RandomByteArrayStream(random);
VectorRowBytesContainer vectorMapJoinRowBytesContainer = new VectorRowBytesContainer(null);
int count = Math.min(maxCount, random.nextInt(500));
for (int i = 0; i < count; i++) {
byte[] bytes = randomByteArrayStream.next();
Output output = vectorMapJoinRowBytesContainer.getOuputForRowBytes();
output.write(bytes);
vectorMapJoinRowBytesContainer.finishRow();
}
vectorMapJoinRowBytesContainer.prepareForReading();
for (int i = 0; i < count; i++) {
if (!vectorMapJoinRowBytesContainer.readNext()) {
assertTrue(false);
}
byte[] readBytes = vectorMapJoinRowBytesContainer.currentBytes();
int readOffset = vectorMapJoinRowBytesContainer.currentOffset();
int readLength = vectorMapJoinRowBytesContainer.currentLength();
byte[] expectedBytes = randomByteArrayStream.get(i);
if (readLength != expectedBytes.length) {
assertTrue(false);
}
for (int j = 0; j < readLength; j++) {
byte readByte = readBytes[readOffset + j];
byte expectedByte = expectedBytes[j];
if (readByte != expectedByte) {
assertTrue(false);
}
}
}
}
Aggregations