Skip to content
Draft
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions java-bigquery/google-cloud-bigquery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@
<artifactId>arrow-memory-netty</artifactId>
</dependency>

<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax-grpc</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
</dependency>

<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ private static class AllocatorHolder {
private static final BufferAllocator ALLOCATOR = new RootAllocator(Long.MAX_VALUE);
}

/**
* Creates a new child buffer allocator with the given name.
*
* @param name the child allocator name
* @return a new child buffer allocator
*/
static BufferAllocator createChildAllocator(String name) {
return AllocatorHolder.ALLOCATOR.newChildAllocator(name, 0, Long.MAX_VALUE);
}

/**
* Instantiates a new {@link VectorSchemaRoot} for the given Arrow schema using vectors allocated
* from the provided child allocator, ensuring LIFO cleanup if an error occurs during
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.bigquery;

import com.google.api.core.BetaApi;
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.types.pojo.Schema;

/**
* <b>[Beta]</b> A query result container providing zero-copy access to Apache Arrow {@link
* VectorSchemaRoot} batches.
*
* <p>Implementations manage direct off-heap native memory buffers. Callers must invoke {@link
* #close()} (idiomatically via a {@code try-with-resources} block) to ensure native allocations and
* underlying gRPC streaming channels are deterministically released.
*/
@BetaApi
public interface ArrowQueryResult extends AutoCloseable, Iterable<VectorSchemaRoot> {

/** Returns the Apache Arrow schema of the result vectors. */
Schema getArrowSchema();

/**
* Returns the job ID associated with the query execution, or {@code null} if no job was created
* (e.g. when optional job creation was used).
*/
JobId getJobId();

/** Returns the query ID associated with the query execution, or {@code null} if unavailable. */
String getQueryId();

/**
* Returns the reason a job was created when optional job creation was requested, or {@code null}
* if no job was created or if the query ran via the fallback path.
*/
JobCreationReason getJobCreationReason();

/** Returns the total number of rows across all batches if known, or {@code -1} if unknown. */
long getTotalRows();

/**
* Releases underlying direct off-heap memory allocations and closes any active stream channels.
*/
@Override
void close();
}
Loading
Loading