Skip to content

Commit b516757

Browse files
authored
Updates the client to use the new proto configs, and strips down some abstractions (#4)
* Updates the client to use the new proto configs, and strips down some abstractions
1 parent 243d722 commit b516757

21 files changed

+597
-1362
lines changed

README.md

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,73 +15,28 @@ Maven:
1515
<dependency>
1616
<groupId>io.pinecone</groupId>
1717
<artifactId>pinecone-client</artifactId>
18-
<version>0.1.3</version>
18+
<version>0.2.0</version>
1919
</dependency>
2020
```
2121

2222
[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])
2323

2424
Gradle:
2525
```
26-
implementation "io.pinecone:pinecone-client:0.1.3"
26+
implementation "io.pinecone:pinecone-client:0.2.0"
2727
```
2828

2929
[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])
3030

31-
Alternatively, you can use our standalone uberjar [pinecone-client-0.1.3-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.1.3/pinecone-client-0.1.3-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately.
31+
Alternatively, you can use our standalone uberjar [pinecone-client-0.2.0-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.2.0/pinecone-client-0.2.0-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately.
3232

3333
[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])
3434

3535
## Features
3636

37-
The Java client doesn't support managing Pinecone services, only reading and writing from an existing service. To create or delete a service, use the Python client.
37+
The Java client doesn't support managing Pinecone services, only reading and writing from existing indices. To create or delete an index, use the Python client.
3838

39-
The read and write operations currently supported by the java client are `upsert` and `query`. Support for other operations is coming soon.
40-
41-
## Usage
42-
43-
Initialize the client:
44-
```
45-
PineconeClientConfig configuration = new PineconeClientConfig()
46-
.withApiKey("example-api-key");
47-
48-
PineconeClient pineconeClient = new PineconeClient(configuration);
49-
```
50-
51-
Connect to a service:
52-
```
53-
PineconeConnectionConfig connectionConfig = new PineconeConnectionConfig()
54-
.withServiceAuthority("")
55-
.withServiceName("example-service");
56-
57-
PineconeConnection connection = pineconeClient.connect(connectionConfig);
58-
```
59-
60-
A `PineconeConnection` manages underlying gRPC resources used for submitting operations to a particular service. The `PineconeConnection` can be shared and used concurrently by multiple threads.
61-
62-
Read and write data to the service:
63-
```
64-
// upsert vectors <1,2> and <3,4>
65-
UpsertResponse upsertResponse =
66-
connection.send(pineconeClient.upsertRequest()
67-
.ids(Arrays.asList("v1", "v2"))
68-
.data(new float[][]{{1F, 2F},{3F, 4F}}));
69-
70-
// query the 1 most similar vector to <1, 2>
71-
QueryResponse queryResponse = connection.send(pineconeClient.queryRequest()
72-
.topK(1)
73-
.data(new float[][]{{1F, 2F}}));
74-
```
75-
76-
When finished with a `PineconeConnection`, release its resources:
77-
```
78-
connection.close()
79-
```
8039

8140
## Examples
82-
See the *examples* directory for an example
83-
application using *pinecone-client*.
8441

85-
[java-basic-mvn](examples/java-basic-mvn/src/main/java/pineconeexamples):
86-
- The most basic example usage is in *MinimalUpsertAndQueryExample.java*
87-
- A more involved example with multiple threads is in *UpsertsAndQueriesConcurrentExample.java*.
42+
- The most basic example usage is in `src/test/java/io/pinecone/PineconeClientLiveIntegTest.java`, covering most basic operations.

build.gradle

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
plugins {
22
id 'com.github.johnrengelman.shadow' version '6.1.0'
33
id 'java-library'
4-
id 'com.google.protobuf' version '0.8.14'
4+
id 'com.google.protobuf' version '0.8.18'
55
id 'maven-publish'
66
id 'signing'
77
id 'idea'
88
id "io.github.gradle-nexus.publish-plugin" version '1.1.0'
99
}
1010

1111
group = 'io.pinecone'
12-
version = '0.1.4' // [pc:VERSION_NEXT]
12+
version = '0.2.0' // [pc:VERSION_NEXT]
1313
description = 'The Pinecone.io Java Client'
1414

15-
sourceCompatibility = 1.8
15+
sourceCompatibility = JavaVersion.VERSION_1_8
1616

1717
repositories {
1818
mavenCentral()
1919
jcenter()
2020
}
2121

22-
def grpcVersion = '1.35.0'
22+
def grpcVersion = '1.44.1'
2323

2424
dependencies {
2525
api "io.grpc:grpc-protobuf:${grpcVersion}"
2626
api "io.grpc:grpc-stub:${grpcVersion}"
2727
api "io.grpc:grpc-netty:${grpcVersion}"
28-
runtime "io.netty:netty-tcnative-boringssl-static:2.0.35.Final"
29-
implementation "org.slf4j:slf4j-api:1.7.30"
28+
runtime 'io.netty:netty-tcnative-boringssl-static:2.0.48.Final'
29+
implementation 'org.slf4j:slf4j-api:1.7.36'
3030
compileOnly "org.apache.tomcat:annotations-api:6.0.53" // necessary for Java 9+
3131

3232
testImplementation "io.grpc:grpc-testing:${grpcVersion}"
33-
testImplementation "junit:junit:4.13"
33+
testImplementation 'junit:junit:4.13.2'
3434
testImplementation "org.hamcrest:hamcrest:2.2"
35-
testImplementation "org.mockito:mockito-core:3.4.0"
36-
testImplementation "org.slf4j:slf4j-simple:1.7.30"
37-
testImplementation "com.fasterxml.jackson.core:jackson-databind:2.12.2"
35+
testImplementation 'org.mockito:mockito-core:4.3.1'
36+
testImplementation 'org.slf4j:slf4j-simple:1.7.36'
37+
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.13.1'
3838
}
3939

4040
java {
@@ -66,7 +66,7 @@ tasks.shadowJar.dependsOn tasks.relocateShadowJar
6666

6767
protobuf {
6868
protoc {
69-
artifact = "com.google.protobuf:protoc:3.12.0"
69+
artifact = "com.google.protobuf:protoc:3.19.4"
7070
}
7171
plugins {
7272
grpc {

src/main/java/io/pinecone/DeleteRequest.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/main/java/io/pinecone/FetchRequest.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/main/java/io/pinecone/InfoRequest.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/main/java/io/pinecone/PineconeClient.java

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ public PineconeClient(PineconeClientConfig config) {
2020
/**
2121
* Create a new connection to the specified Pinecone service or router. Throws {@link PineconeValidationException} if configuration is invalid.
2222
*
23-
* @param serviceAuthority URL authority of the Pinecone service or router to access. E.g. "10.1.2.3:3456".
24-
* @param serviceName Service or router name to connect to.
23+
* @param indexName The name of your pinecone Index.
2524
* @return A {@link PineconeConnection} for the service or router.
2625
*/
27-
public PineconeConnection connect(String serviceAuthority, String serviceName) {
26+
public PineconeConnection connect(String indexName) {
2827
return connect(new PineconeConnectionConfig()
29-
.withServiceAuthority(serviceAuthority)
30-
.withServiceName(serviceName));
28+
.withIndexName(indexName));
3129
}
3230

3331
/**
@@ -38,49 +36,4 @@ public PineconeConnection connect(String serviceAuthority, String serviceName) {
3836
public PineconeConnection connect(PineconeConnectionConfig connectionConfig) {
3937
return new PineconeConnection(config, connectionConfig);
4038
}
41-
42-
/**
43-
* Create a new info request. TODO: make this public when ready.
44-
* @return An InfoRequest.
45-
*/
46-
private InfoRequest infoRequest() {
47-
InfoRequest request = PineconeRequest.usingTranslator(config.getTranslator(), new InfoRequest());
48-
return PineconeRequest.usingServerSideTimeout(config.getServerSideTimeoutSec(), request);
49-
}
50-
51-
/**
52-
* Create a new upsert request.
53-
* @return An UpsertRequest.
54-
*/
55-
public UpsertRequest upsertRequest() {
56-
UpsertRequest request = PineconeRequest.usingTranslator(config.getTranslator(), new UpsertRequest());
57-
return PineconeRequest.usingServerSideTimeout(config.getServerSideTimeoutSec(), request);
58-
}
59-
60-
/**
61-
* Create a new fetch request. TODO: make this public when ready.
62-
* @return A FetchRequest.
63-
*/
64-
private FetchRequest fetchRequest() {
65-
FetchRequest request = PineconeRequest.usingTranslator(config.getTranslator(), new FetchRequest());
66-
return PineconeRequest.usingServerSideTimeout(config.getServerSideTimeoutSec(), request);
67-
}
68-
69-
/**
70-
* Create a new query request.
71-
* @return A QueryRequest
72-
*/
73-
public QueryRequest queryRequest() {
74-
QueryRequest request = PineconeRequest.usingTranslator(config.getTranslator(), new QueryRequest());
75-
return PineconeRequest.usingServerSideTimeout(config.getServerSideTimeoutSec(), request);
76-
}
77-
78-
/**
79-
* Create a new delete request.TODO: make this public when ready.
80-
* @return A DeleteRequest.
81-
*/
82-
private DeleteRequest deleteRequest() {
83-
DeleteRequest request = PineconeRequest.usingTranslator(config.getTranslator(), new DeleteRequest());
84-
return PineconeRequest.usingServerSideTimeout(config.getServerSideTimeoutSec(), request);
85-
}
8639
}

0 commit comments

Comments
 (0)