Skip to content

Commit

Permalink
ARROW-6721: [JAVA] Avro adapter benchmark only runs once in JMH
Browse files Browse the repository at this point in the history
  • Loading branch information
tianchen92 authored and kszucs committed Oct 5, 2019
1 parent af097e6 commit c8d0420
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -32,6 +32,7 @@
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.io.BinaryDecoder;
import org.apache.avro.io.BinaryEncoder;
import org.apache.avro.io.DatumWriter;
import org.apache.avro.io.Decoder;
Expand Down Expand Up @@ -62,7 +63,7 @@ public class AvroAdapterBenchmarks {
private AvroToArrowConfig config;

private Schema schema;
private Decoder decoder;
private BinaryDecoder decoder;

/**
* Setup benchmarks.
Expand All @@ -85,8 +86,6 @@ public void prepare() throws Exception {
BinaryEncoder encoder = new EncoderFactory().directBinaryEncoder(out, null);
DatumWriter writer = new GenericDatumWriter(schema);

decoder = new DecoderFactory().directBinaryDecoder(new ByteArrayInputStream(out.toByteArray()), null);

for (int i = 0; i < valueCount; i++) {
GenericRecord record = new GenericData.Record(schema);
record.put(0, "test" + i);
Expand All @@ -97,6 +96,7 @@ public void prepare() throws Exception {
writer.write(record, encoder);
}

decoder = new DecoderFactory().directBinaryDecoder(new ByteArrayInputStream(out.toByteArray()), null);
}

/**
Expand All @@ -115,6 +115,7 @@ public void tearDown() {
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public int testAvroToArrow() throws Exception {
decoder.inputStream().reset();
int sum = 0;
try (AvroToArrowVectorIterator iter = AvroToArrow.avroToArrowIterator(schema, decoder, config)) {
while (iter.hasNext()) {
Expand Down

0 comments on commit c8d0420

Please sign in to comment.