Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@

package com.google.cloud.bigquery;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
Expand Down Expand Up @@ -93,4 +95,73 @@ private void queryPerform(String queries, Blackhole blackhole) throws Exception
public void query(QueryParams queryParams, Blackhole blackhole) throws Exception {
queryPerform(queryParams.queries, blackhole);
}

@Benchmark
public void queryWithArrowRowBased(QueryParams queryParams, Blackhole blackhole)
throws Exception {
QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(queryParams.queries)
.setUseLegacySql(false)
.setQueryResultsFormat(QueryResultsFormat.ARROW)
.build();
TableResult result = bigquery.query(config);
for (FieldValueList row : result.iterateAll()) {
blackhole.consume(row);
}
}

@Benchmark
public void queryWithArrowZeroCopy(QueryParams queryParams, Blackhole blackhole)
Comment on lines +100 to +114

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC, both of these should trigger the job path. I think it would also be nice to have a simple path as well (e.g. handles just first batch)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. I've added simple paths as suggested.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I might be a bit confused on this. How do the two benchmark differ?

I was thinking that
One set should have queries that should be returned in a single batch
Anther set should have queries that require multiple batches

Both sets should test again arrow and non-arrow

throws Exception {
QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(queryParams.queries)
.setUseLegacySql(false)
.setQueryResultsFormat(QueryResultsFormat.ARROW)
.build();
try (ArrowQueryResult result = bigquery.queryArrow(config)) {
for (VectorSchemaRoot root : result) {
blackhole.consume(root);
}
}
}

@Benchmark
public void querySimplePath(QueryParams queryParams, Blackhole blackhole) throws Exception {
TableResult result =
bigquery.query(
QueryJobConfiguration.newBuilder(queryParams.queries).setUseLegacySql(false).build());
for (FieldValueList row : result.getValues()) {
blackhole.consume(row);
}
}

@Benchmark
public void queryWithArrowRowBasedSimplePath(QueryParams queryParams, Blackhole blackhole)
throws Exception {
QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(queryParams.queries)
.setUseLegacySql(false)
.setQueryResultsFormat(QueryResultsFormat.ARROW)
.build();
TableResult result = bigquery.query(config);
for (FieldValueList row : result.getValues()) {
blackhole.consume(row);
}
}

@Benchmark
public void queryWithArrowZeroCopySimplePath(QueryParams queryParams, Blackhole blackhole)
throws Exception {
QueryJobConfiguration config =
QueryJobConfiguration.newBuilder(queryParams.queries)
.setUseLegacySql(false)
.setQueryResultsFormat(QueryResultsFormat.ARROW)
.build();
try (ArrowQueryResult result = bigquery.queryArrow(config)) {
Iterator<VectorSchemaRoot> it = result.iterator();
if (it.hasNext()) {
blackhole.consume(it.next());
}
}
}
}
Loading