Search in sources :

Example 1 with VectorMapJoinRowBytesContainer

use of org.apache.hadoop.hive.ql.exec.vector.mapjoin.VectorMapJoinRowBytesContainer in project hive by apache.

the class TestVectorMapJoinRowBytesContainer method doFillReplay.

public void doFillReplay(Random random, int maxCount) throws Exception {
    RandomByteArrayStream randomByteArrayStream = new RandomByteArrayStream(random);
    VectorMapJoinRowBytesContainer vectorMapJoinRowBytesContainer = new VectorMapJoinRowBytesContainer(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);
            }
        }
    }
}
Also used : VectorMapJoinRowBytesContainer(org.apache.hadoop.hive.ql.exec.vector.mapjoin.VectorMapJoinRowBytesContainer) Output(org.apache.hadoop.hive.serde2.ByteStream.Output)

Aggregations

VectorMapJoinRowBytesContainer (org.apache.hadoop.hive.ql.exec.vector.mapjoin.VectorMapJoinRowBytesContainer)1 Output (org.apache.hadoop.hive.serde2.ByteStream.Output)1