Skip to content

Commit 01e4017

Browse files
authored
Merge branch 'v6' into v6-oidc
2 parents f5ef775 + 5fc538a commit 01e4017

87 files changed

Lines changed: 2972 additions & 458 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/create-release.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
name: Create Release
22
on:
33
push:
4-
# run only on tags
54
tags:
65
- '**'
6+
pull_request:
7+
# Release a new SNAPSHOT version every time a PR is merged to v6.
8+
types: [closed]
9+
branches: ['v6']
710

811
jobs:
912
release:
1013
name: Deploy
11-
if: startsWith(github.ref, 'refs/tags')
14+
if: >
15+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags'))
16+
|| (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
1217
runs-on: ubuntu-latest
1318
steps:
1419
- uses: actions/checkout@v4
@@ -39,7 +44,7 @@ jobs:
3944
retention-days: 1
4045
gh-release:
4146
name: Create a GitHub Release
42-
if: startsWith(github.ref, 'refs/tags')
47+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
4348
runs-on: ubuntu-latest
4449
needs: [ release ]
4550
steps:

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To start using Weaviate Java Client add the dependency to `pom.xml`:
1818

1919
### Uber JAR🫙
2020

21-
If you're building a uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`.
21+
If you're building an uber-JAR with something like `maven-assembly-plugin`, use a shaded version with classifier `all`.
2222
This ensures that all dynamically-loaded dependecies of `io.grpc` are resolved correctly.
2323

2424
```xml
@@ -30,6 +30,25 @@ This ensures that all dynamically-loaded dependecies of `io.grpc` are resolved c
3030
</dependency>
3131
```
3232

33+
### SNAPSHOT releases
34+
35+
The latest development version of `client6` is released after every merged pull request. To include it in you project set the version to `6.0.0-SNAPSHOT` and [configure your `<repositories>` section accordingly](https://central.sonatype.org/publish/publish-portal-snapshots/#consuming-snapshot-releases-for-your-project).
36+
Please be mindful of the fact that this is not a stable release and breaking changes may be introduced.
37+
38+
Snapshot releases overwrite each other, so no two releases are alike. If you find a bug in one of the `SNAPSHOT` versions that you'd like to report, please include the output of `Debug.printBuildInfo()` in the ticket's description.
39+
40+
```java
41+
import io.weaviate.client6.v1.internal.Debug;
42+
43+
public class App {
44+
public static void main(String[] args) {
45+
Debug.printBuildInfo();
46+
47+
// ...the rest of your application code...
48+
}
49+
}
50+
```
51+
3352
### Gson and reflective access to internal JDK classes
3453

3554
The client uses Google's [`gson`](https://github.com/google/gson) for JSON de-/serialization which does reflection on internal `java.lang` classes. This is _not allowed by default_ in Java 9 and above.
@@ -48,14 +67,11 @@ applicationDefaultJvmArgs += listOf(
4867
)
4968
```
5069

51-
## Documentation
70+
## Useful resources
5271

5372
- [Documentation](https://weaviate.io/developers/weaviate/current/client-libraries/java.html).
54-
55-
## Support
56-
57-
- [Stackoverflow for questions](https://stackoverflow.com/questions/tagged/weaviate).
58-
- [Github for issues](https://github.com/weaviate/java-client/issues).
73+
- [StackOverflow for questions about Weaviate](https://stackoverflow.com/questions/tagged/weaviate).
74+
- [Github for issues in client6](https://github.com/weaviate/java-client/issues).
5975

6076
## Contributing
6177

pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,28 @@
361361
</execution>
362362
</executions>
363363
</plugin>
364+
<plugin>
365+
<groupId>pl.project13.maven</groupId>
366+
<artifactId>git-commit-id-plugin</artifactId>
367+
<version>4.9.10</version>
368+
<executions>
369+
<execution>
370+
<id>get-the-git-infos</id>
371+
<goals>
372+
<goal>revision</goal>
373+
</goals>
374+
<phase>initialize</phase>
375+
</execution>
376+
</executions>
377+
<configuration>
378+
<useNativeGit>true</useNativeGit>
379+
<generateGitPropertiesFile>true</generateGitPropertiesFile>
380+
<generateGitPropertiesFilename>${project.build.outputDirectory}/client6-git.properties</generateGitPropertiesFilename>
381+
<commitIdGenerationMode>full</commitIdGenerationMode>
382+
<failOnNoGitDirectory>false</failOnNoGitDirectory>
383+
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
384+
</configuration>
385+
</plugin>
364386
<plugin>
365387
<groupId>org.apache.maven.plugins</groupId>
366388
<artifactId>maven-javadoc-plugin</artifactId>
@@ -523,6 +545,10 @@
523545
<groupId>org.apache.maven.plugins</groupId>
524546
<artifactId>maven-javadoc-plugin</artifactId>
525547
</plugin>
548+
<plugin>
549+
<groupId>pl.project13.maven</groupId>
550+
<artifactId>git-commit-id-plugin</artifactId>
551+
</plugin>
526552
<plugin>
527553
<groupId>org.apache.maven.plugins</groupId>
528554
<artifactId>maven-gpg-plugin</artifactId>

src/it/java/io/weaviate/ConcurrentTest.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22

33
import java.util.Random;
44
import java.util.UUID;
5+
import java.util.concurrent.Callable;
6+
import java.util.concurrent.CompletableFuture;
7+
import java.util.concurrent.ExecutionException;
8+
import java.util.concurrent.TimeUnit;
9+
import java.util.concurrent.TimeoutException;
510

611
import org.apache.commons.lang3.RandomStringUtils;
12+
import org.assertj.core.api.Assertions;
713
import org.junit.Rule;
814
import org.junit.rules.TestName;
915

@@ -62,4 +68,46 @@ protected static float[] randomVector(int length, float origin, float bound) {
6268
}
6369
return vector;
6470
}
71+
72+
/**
73+
* Check that a condition is eventually met.
74+
*
75+
* @param cond Arbitrary code that evaluates the test condition..
76+
* @param intervalMillis Polling interval.
77+
* @param timeoutSeconds Maximum waiting time.
78+
* @param message Optional failure message.
79+
*
80+
* @throws AssertionError if the condition does not evaluate to true
81+
* within {@code timeoutSeconds} or a thread
82+
* was interrupted in the meantime.
83+
* @throws RuntimeException if an exception occurred when envalating condition.
84+
*/
85+
public static void eventually(Callable<Boolean> cond, int intervalMillis, int timeoutSeconds, String... message) {
86+
var check = CompletableFuture.runAsync(() -> {
87+
try {
88+
while (!Thread.currentThread().isInterrupted() && !cond.call()) {
89+
try {
90+
Thread.sleep(intervalMillis);
91+
} catch (InterruptedException ex) {
92+
Thread.currentThread().interrupt();
93+
}
94+
}
95+
} catch (Exception e) {
96+
// Propagate to callee
97+
throw new RuntimeException(e);
98+
}
99+
});
100+
101+
try {
102+
check.get(timeoutSeconds, TimeUnit.SECONDS);
103+
} catch (TimeoutException ex) {
104+
check.cancel(true);
105+
Assertions.fail(message.length >= 0 ? message[0] : null, ex);
106+
} catch (InterruptedException ex) {
107+
Thread.currentThread().interrupt();
108+
Assertions.fail(ex);
109+
} catch (ExecutionException ex) {
110+
throw new RuntimeException(ex);
111+
}
112+
}
65113
}

src/it/java/io/weaviate/containers/Container.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class Container {
1616
public static final Weaviate WEAVIATE = Weaviate.createDefault();
1717
public static final Contextionary CONTEXTIONARY = Contextionary.createDefault();
1818
public static final Img2VecNeural IMG2VEC_NEURAL = Img2VecNeural.createDefault();
19+
public static final MinIo MINIO = MinIo.createDefault();
1920

2021
/**
2122
* Stop all shared Testcontainers created in {@link #startAll}.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package io.weaviate.containers;
2+
3+
import org.testcontainers.containers.MinIOContainer;
4+
5+
public class MinIo extends MinIOContainer {
6+
private static final String DOCKER_IMAGE = "minio/minio";
7+
public static final String ACCESS_KEY = "minioadmin";
8+
public static final String SECRET_KEY = "minioadmin";
9+
10+
static MinIo createDefault() {
11+
return new MinIo();
12+
}
13+
14+
private MinIo() {
15+
super(DOCKER_IMAGE);
16+
withUserName(ACCESS_KEY);
17+
withPassword(SECRET_KEY);
18+
withCreateContainerCmdModifier(cmd -> cmd.withHostName("minio"));
19+
}
20+
}

src/it/java/io/weaviate/containers/Weaviate.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,15 @@ public Builder withImageInference(String url, String module) {
129129
return this;
130130
}
131131

132+
public Builder withOffloadS3(String accessKey, String secretKey) {
133+
addModules("offload-s3");
134+
environment.put("OFFLOAD_S3_ENDPOINT", "http://minio:9000");
135+
environment.put("OFFLOAD_S3_BUCKET_AUTO_CREATE", "true");
136+
environment.put("AWS_ACCESS_KEY_ID", accessKey);
137+
environment.put("AWS_SECRET_KEY", secretKey);
138+
return this;
139+
}
140+
132141
public Builder enableTelemetry(boolean enable) {
133142
environment.put("DISABLE_TELEMETRY", Boolean.toString(!enable));
134143
return this;

src/it/java/io/weaviate/integration/AggregationITest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
import io.weaviate.client6.v1.api.collections.Property;
1717
import io.weaviate.client6.v1.api.collections.Vectorizers;
1818
import io.weaviate.client6.v1.api.collections.Vectors;
19+
import io.weaviate.client6.v1.api.collections.aggregate.Aggregate;
1920
import io.weaviate.client6.v1.api.collections.aggregate.AggregateResponseGroup;
2021
import io.weaviate.client6.v1.api.collections.aggregate.AggregateResponseGrouped;
21-
import io.weaviate.client6.v1.api.collections.aggregate.Aggregation;
2222
import io.weaviate.client6.v1.api.collections.aggregate.GroupBy;
2323
import io.weaviate.client6.v1.api.collections.aggregate.GroupedBy;
2424
import io.weaviate.client6.v1.api.collections.aggregate.IntegerAggregation;
@@ -57,7 +57,7 @@ public void testOverAll() {
5757
var result = things.aggregate.overAll(
5858
with -> with
5959
.metrics(
60-
Aggregation.integer("price",
60+
Aggregate.integer("price",
6161
calculate -> calculate.median().max().count()))
6262
.includeTotalCount(true));
6363

@@ -77,7 +77,7 @@ public void testOverAll_groupBy_category() {
7777
var result = things.aggregate.overAll(
7878
with -> with
7979
.metrics(
80-
Aggregation.integer("price",
80+
Aggregate.integer("price",
8181
calculate -> calculate.min().max().count()))
8282
.includeTotalCount(true),
8383
GroupBy.property("category"));
@@ -115,7 +115,7 @@ public void testNearVector() {
115115
near -> near.limit(5),
116116
with -> with
117117
.metrics(
118-
Aggregation.integer("price",
118+
Aggregate.integer("price",
119119
calculate -> calculate.min().max().count()))
120120
.objectLimit(4)
121121
.includeTotalCount(true));
@@ -135,7 +135,7 @@ public void testNearVector_groupBy_category() {
135135
near -> near.distance(2f),
136136
with -> with
137137
.metrics(
138-
Aggregation.integer("price",
138+
Aggregate.integer("price",
139139
calculate -> calculate.min().max().median()))
140140
.objectLimit(9)
141141
.includeTotalCount(true),

src/it/java/io/weaviate/integration/DataITest.java

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package io.weaviate.integration;
22

33
import java.io.IOException;
4+
import java.time.OffsetDateTime;
5+
import java.util.List;
46
import java.util.Map;
7+
import java.util.UUID;
58

69
import org.assertj.core.api.Assertions;
710
import org.assertj.core.api.InstanceOfAssertFactories;
@@ -407,4 +410,61 @@ public void testDuplicateUuid() throws IOException {
407410
// Act
408411
things.data.insert(Map.of(), thing -> thing.uuid(thing_1.uuid()));
409412
}
413+
414+
@Test
415+
public void testDataTypes() throws IOException {
416+
// Arrange
417+
var nsDataTypes = ns("DataTypes");
418+
419+
// BLOB type is omitted because a base64-encoded image
420+
// isn't doing the failure message any favours.
421+
// It's tested in other test cases above.
422+
client.collections.create(
423+
nsDataTypes, c -> c
424+
.properties(
425+
Property.text("prop_text"),
426+
Property.integer("prop_integer"),
427+
Property.number("prop_number"),
428+
Property.bool("prop_bool"),
429+
Property.date("prop_date"),
430+
Property.uuid("prop_uuid"),
431+
Property.integerArray("prop_integer_array"),
432+
Property.numberArray("prop_number_array"),
433+
Property.boolArray("prop_bool_array"),
434+
Property.dateArray("prop_date_array"),
435+
Property.uuidArray("prop_uuid_array"),
436+
Property.textArray("prop_text_array")));
437+
438+
var types = client.collections.use(nsDataTypes);
439+
440+
var now = OffsetDateTime.now();
441+
var uuid = UUID.randomUUID();
442+
443+
Map<String, Object> want = Map.ofEntries(
444+
Map.entry("prop_text", "Hello, World!"),
445+
Map.entry("prop_integer", 1L),
446+
Map.entry("prop_number", 1D),
447+
Map.entry("prop_bool", true),
448+
Map.entry("prop_date", now),
449+
Map.entry("prop_uuid", uuid),
450+
Map.entry("prop_integer_array", List.of(1L, 2L, 3L)),
451+
Map.entry("prop_number_array", List.of(1D, 2D, 3D)),
452+
Map.entry("prop_bool_array", List.of(true, false)),
453+
Map.entry("prop_date_array", List.of(now, now)),
454+
Map.entry("prop_uuid_array", List.of(uuid, uuid)),
455+
Map.entry("prop_text_array", List.of("a", "b", "c")));
456+
var returnProperties = want.keySet().toArray(String[]::new);
457+
458+
// Act
459+
var object = types.data.insert(want);
460+
var got = types.query.byId(object.uuid(),
461+
q -> q.returnProperties(returnProperties));
462+
463+
// Assert
464+
Assertions.assertThat(got).get()
465+
.extracting(WeaviateObject::properties)
466+
.asInstanceOf(InstanceOfAssertFactories.map(String.class, Object.class))
467+
.containsAllEntriesOf(want);
468+
469+
}
410470
}

0 commit comments

Comments
 (0)