Skip to content

Commit

Permalink
Support Java 8 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush008 committed Dec 5, 2023
1 parent 07c2a6c commit e138d22
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: "17"
java-version: "8"
distribution: "oracle"
- name: Set execute permission
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
uses: dev-vince/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
java-version: "17"
java-version: "8"
java-distribution: "adopt" # The distributor of the target JDK. See https://github.com/actions/setup-java for more information.
project: maven # The project type.
branch: "gh-pages" # The branch for the javadoc contents.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: "17"
java-version: "8"
distribution: "oracle"
- name: Set execute permission
run: |
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ Java client library with handy utility methods and overloads for interfacing wit

> Not yet published.
To install the library, add the following lines to your build config file. Requires JDK 17 or above.
> [!IMPORTANT]
> Requires Java 8 or above.
To install the library, add the following lines to your build config file.

#### Maven
```xml
<dependency>
Expand Down
12 changes: 2 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,12 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.2</version>
</plugin>
<plugin>
<groupId>com.spotify.fmt</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.21.1</version>
<goals>
<goal>format</goal>
</goals>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/qdrant/client/TokenInterceptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class TokenInterceptor implements ClientInterceptor {
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) {
return new SimpleForwardingClientCall<>(next.newCall(method, callOptions)) {
return new SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
headers.put(API_KEY, apiKey);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/io/qdrant/client/utils/PointUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import java.util.Arrays;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/** Utility class for working with Points. */
public class PointUtil {
Expand All @@ -30,7 +32,7 @@ public static PointsSelector createPointsSelector(long... pointIds) {

PointsIdsList pointsIdsList =
PointsIdsList.newBuilder()
.addAllIds(Arrays.stream(pointIds).mapToObj(PointUtil::pointId).toList())
.addAllIds(Arrays.stream(pointIds).mapToObj(PointUtil::pointId).collect(Collectors.toList()))
.build();

return PointsSelector.newBuilder().setPoints(pointsIdsList).build();
Expand All @@ -51,7 +53,7 @@ public static PointsSelector createPointsSelector(String... pointIds) {
// Using map() instead
PointsIdsList pointsIdsList =
PointsIdsList.newBuilder()
.addAllIds(Arrays.stream(pointIds).map((String id) -> PointUtil.pointId(id)).toList())
.addAllIds(Arrays.stream(pointIds).map((String id) -> PointUtil.pointId(id)).collect(Collectors.toList()))
.build();

return PointsSelector.newBuilder().setPoints(pointsIdsList).build();
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/io/qdrant/client/utils/SelectorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import io.qdrant.client.grpc.Points.VectorsSelector;
import io.qdrant.client.grpc.Points.WithPayloadSelector;
import io.qdrant.client.grpc.Points.WithVectorsSelector;

import java.util.Arrays;
import java.util.List;

/** Utility class for working with Selectors. */
Expand Down Expand Up @@ -39,7 +41,7 @@ public static WithVectorsSelector withVectors() {
*/
public static WithPayloadSelector withPayload(String... fields) {
PayloadIncludeSelector include =
PayloadIncludeSelector.newBuilder().addAllFields(List.of(fields)).build();
PayloadIncludeSelector.newBuilder().addAllFields(Arrays.asList(fields)).build();
return WithPayloadSelector.newBuilder().setInclude(include).build();
}

Expand All @@ -50,7 +52,7 @@ public static WithPayloadSelector withPayload(String... fields) {
* @return The created {@link WithVectorsSelector} object.
*/
public static WithVectorsSelector withVectors(String... vectors) {
VectorsSelector include = VectorsSelector.newBuilder().addAllNames(List.of(vectors)).build();
VectorsSelector include = VectorsSelector.newBuilder().addAllNames(Arrays.asList(vectors)).build();
return WithVectorsSelector.newBuilder().setInclude(include).build();
}

Expand All @@ -74,7 +76,7 @@ public static PointsSelector idsSelector(List<PointId> ids) {
*/
public static PointsSelector idsSelector(PointId... ids) {
return PointsSelector.newBuilder()
.setPoints(PointsIdsList.newBuilder().addAllIds(List.of(ids)).build())
.setPoints(PointsIdsList.newBuilder().addAllIds(Arrays.asList(ids)).build())
.build();
}

Expand Down
17 changes: 9 additions & 8 deletions src/test/java/io/qdrant/client/QdrantClientPointsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.qdrant.client.utils.SelectorUtil;
import io.qdrant.client.utils.VectorUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -58,7 +59,7 @@ void testPointsWithPayloadFilters() {
Points.GetResponse response =
qdrantClient.getPoints(
collectionName,
List.of(pointIds),
Arrays.asList(pointIds),
SelectorUtil.withVectors(),
SelectorUtil.withPayload(),
null);
Expand All @@ -79,12 +80,12 @@ void testPointsWithPayloadFilters() {
PointUtil.point(
pointID, VectorUtil.dummyVector(EMBEDDINGS_SIZE), PayloadUtil.toPayload(data));

List<PointStruct> points = List.of(point);
List<PointStruct> points = Arrays.asList(point);
qdrantClient.upsertPointsBlocking(collectionName, points, null);
response =
qdrantClient.getPoints(
collectionName,
List.of(pointIds),
Arrays.asList(pointIds),
SelectorUtil.withVectors(),
SelectorUtil.withPayload(),
null);
Expand All @@ -101,7 +102,7 @@ void testPointsWithPayloadFilters() {
response =
qdrantClient.getPoints(
collectionName,
List.of(pointIds),
Arrays.asList(pointIds),
SelectorUtil.withVectors(),
SelectorUtil.withPayload(),
null);
Expand All @@ -122,20 +123,20 @@ void testUpsertPoints() {
Points.GetResponse response =
qdrantClient.getPoints(
collectionName,
List.of(pointIds),
Arrays.asList(pointIds),
SelectorUtil.withVectors(),
SelectorUtil.withPayload(),
null);

assertEquals(0, response.getResultCount());

PointStruct point = PointUtil.point(pointID, VectorUtil.dummyVector(EMBEDDINGS_SIZE), null);
List<PointStruct> points = List.of(point);
List<PointStruct> points = Arrays.asList(point);
qdrantClient.upsertPointsBlocking(collectionName, points, null);
response =
qdrantClient.getPoints(
collectionName,
List.of(pointIds),
Arrays.asList(pointIds),
SelectorUtil.withVectors(),
SelectorUtil.withPayload(),
null);
Expand All @@ -146,7 +147,7 @@ void testUpsertPoints() {
response =
qdrantClient.getPoints(
collectionName,
List.of(pointIds),
Arrays.asList(pointIds),
SelectorUtil.withVectors(),
SelectorUtil.withPayload(),
null);
Expand Down

0 comments on commit e138d22

Please sign in to comment.