public class PineconeConnection
extends java.lang.Object
implements java.lang.AutoCloseable
PineconeConnection class handles communication with a Pinecone service or router. One PineconeConnection
can be shared and used concurrently by multiple threads.
import io.pinecone.clients.AsyncIndex;
import io.pinecone.clients.Index;
import io.pinecone.configs.PineconeConnection;
...
// Construct the connection object
PineconeConnection connection = new PineconeConnection(config);
// Construct the index object for synchronous data plane operations
Index index = new Index(connection, "example-index");
index.describeIndexStats();
// Construct the async index object for asynchronous data plane operations
AsyncIndex asyncIndex = new AsyncIndex(connection, "example-index");
asyncIndex.describeIndexStats();
| Constructor and Description |
|---|
PineconeConnection(PineconeConfig config)
Constructs a
PineconeConnection instance with the specified PineconeConfig. |
| Modifier and Type | Method and Description |
|---|---|
static io.grpc.ManagedChannel |
buildChannel(java.lang.String host) |
void |
close()
Close the connection and release all resources.
|
static java.lang.String |
formatEndpoint(java.lang.String host) |
VectorServiceGrpc.VectorServiceFutureStub |
getAsyncStub()
Return the gRPC async stub to allow clients to do ListenableFuture-style rpc calls to Pinecone.
|
VectorServiceGrpc.VectorServiceBlockingStub |
getBlockingStub()
Return the gRPC stub used for sending requests to Pinecone.
|
io.grpc.ManagedChannel |
getChannel()
Returns the gRPC channel.
|
public PineconeConnection(PineconeConfig config)
PineconeConnection instance with the specified PineconeConfig.
If a custom gRPC ManagedChannel is provided in the PineconeConfig, it will be used.
Otherwise, a new gRPC ManagedChannel will be built using the host specified in the PineconeConfig.
config - The PineconeConfig containing configuration settings for the PineconeConnection.PineconeValidationException - If index name or host is not provided for data plane operations.public void close()
close in interface java.lang.AutoCloseablepublic io.grpc.ManagedChannel getChannel()
public VectorServiceGrpc.VectorServiceBlockingStub getBlockingStub()
public VectorServiceGrpc.VectorServiceFutureStub getAsyncStub()
public static io.grpc.ManagedChannel buildChannel(java.lang.String host)
public static java.lang.String formatEndpoint(java.lang.String host)