Search in sources :

Example 6 with VectorRowBytesContainer

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);
            }
        }
    }
}
Also used : RandomByteArrayStream(org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.RandomByteArrayStream) VectorRowBytesContainer(org.apache.hadoop.hive.ql.exec.vector.rowbytescontainer.VectorRowBytesContainer) Output(org.apache.hadoop.hive.serde2.ByteStream.Output)

Aggregations

VectorRowBytesContainer (org.apache.hadoop.hive.ql.exec.vector.rowbytescontainer.VectorRowBytesContainer)6 IOException (java.io.IOException)3 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 Output (org.apache.hadoop.hive.serde2.ByteStream.Output)3 HashPartition (org.apache.hadoop.hive.ql.exec.persistence.HybridHashTableContainer.HashPartition)2 HybridHashTableContainer (org.apache.hadoop.hive.ql.exec.persistence.HybridHashTableContainer)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1 RandomByteArrayStream (org.apache.hadoop.hive.ql.exec.vector.mapjoin.fast.RandomByteArrayStream)1 SerDeException (org.apache.hadoop.hive.serde2.SerDeException)1 LazyBinaryDeserializeRead (org.apache.hadoop.hive.serde2.lazybinary.fast.LazyBinaryDeserializeRead)1 LazyBinarySerializeWrite (org.apache.hadoop.hive.serde2.lazybinary.fast.LazyBinarySerializeWrite)1