Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARROW-6721: [JAVA] Avro adapter benchmark only runs once in JMH #5524

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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