Skip to content

Commit 076f54c

Browse files
committed
feat(export): make fileFormat a required parameter
1 parent 5061a1c commit 076f54c

4 files changed

Lines changed: 22 additions & 25 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.weaviate.client6.v1.api.WeaviateClient;
1515
import io.weaviate.client6.v1.api.export.Export;
1616
import io.weaviate.client6.v1.api.export.ExportStatus;
17+
import io.weaviate.client6.v1.api.export.FileFormat;
1718
import io.weaviate.client6.v1.api.export.ShardExportProgress;
1819
import io.weaviate.containers.Weaviate;
1920

@@ -45,7 +46,7 @@ public void test_lifecycle() throws IOException, TimeoutException {
4546
}
4647

4748
// Act: start export
48-
var started = client.export.create(exportId, backend,
49+
var started = client.export.create(exportId, backend, FileFormat.PARQUET,
4950
export -> export
5051
.includeCollections(nsA, nsB));
5152

src/main/java/io/weaviate/client6/v1/api/export/CreateExportRequest.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
import io.weaviate.client6.v1.internal.rest.Endpoint;
1414
import io.weaviate.client6.v1.internal.rest.SimpleEndpoint;
1515

16-
public record CreateExportRequest(ExportCreate body, String backend) {
16+
public record CreateExportRequest(ExportCreate config, String backend) {
1717

1818
public static Endpoint<CreateExportRequest, Export> _ENDPOINT = new SimpleEndpoint<>(
1919
request -> "POST",
2020
request -> "/export/" + request.backend,
2121
request -> Collections.emptyMap(),
22-
request -> JSON.serialize(request.body),
22+
request -> JSON.serialize(request.config),
2323
(statusCode, response) -> JSON.deserialize(response, Export.class));
2424

2525
public static record ExportCreate(
@@ -28,12 +28,13 @@ public static record ExportCreate(
2828
@SerializedName("include") List<String> includeCollections,
2929
@SerializedName("exclude") List<String> excludeCollections) {
3030

31-
public static ExportCreate of(String exportId) {
32-
return of(exportId, ObjectBuilder.identity());
31+
public static ExportCreate of(String exportId, FileFormat fileFormat) {
32+
return of(exportId, fileFormat, ObjectBuilder.identity());
3333
}
3434

35-
public static ExportCreate of(String exportId, Function<Builder, ObjectBuilder<ExportCreate>> fn) {
36-
return fn.apply(new Builder(exportId)).build();
35+
public static ExportCreate of(String exportId, FileFormat fileFormat,
36+
Function<Builder, ObjectBuilder<ExportCreate>> fn) {
37+
return fn.apply(new Builder(exportId, fileFormat)).build();
3738
}
3839

3940
public ExportCreate(Builder builder) {
@@ -46,13 +47,14 @@ public ExportCreate(Builder builder) {
4647

4748
public static class Builder implements ObjectBuilder<ExportCreate> {
4849
private final String exportId;
50+
private FileFormat fileFormat;
4951

50-
private FileFormat fileFormat = FileFormat.PARQUET;
5152
private final List<String> includeCollections = new ArrayList<>();
5253
private final List<String> excludeCollections = new ArrayList<>();
5354

54-
public Builder(String exportId) {
55+
public Builder(String exportId, FileFormat fileFormat) {
5556
this.exportId = exportId;
57+
this.fileFormat = fileFormat;
5658
}
5759

5860
/** Collection that should be included in the export. */
@@ -77,12 +79,6 @@ public Builder excludeCollections(List<String> excludeCollections) {
7779
return this;
7880
}
7981

80-
/** Export file format. */
81-
public Builder fileFormat(FileFormat fileFormat) {
82-
this.fileFormat = fileFormat;
83-
return this;
84-
}
85-
8682
@Override
8783
public ExportCreate build() {
8884
return new ExportCreate(this);

src/main/java/io/weaviate/client6/v1/api/export/WeaviateExportClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public WeaviateExportClient(RestTransport restTransport) {
2626
* due to a malformed request, a networking error
2727
* or the server being unavailable.
2828
*/
29-
public Export create(String exportId, String backend) throws IOException {
30-
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId), backend));
29+
public Export create(String exportId, String backend, FileFormat fileFormat) throws IOException {
30+
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId, fileFormat), backend));
3131
}
3232

3333
/**
@@ -42,10 +42,10 @@ public Export create(String exportId, String backend) throws IOException {
4242
* due to a malformed request, a networking error
4343
* or the server being unavailable.
4444
*/
45-
public Export create(String exportId, String backend,
45+
public Export create(String exportId, String backend, FileFormat fileFormat,
4646
Function<CreateExportRequest.ExportCreate.Builder, ObjectBuilder<CreateExportRequest.ExportCreate>> fn)
4747
throws IOException {
48-
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId, fn), backend));
48+
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId, fileFormat, fn), backend));
4949
}
5050

5151
/**
@@ -58,7 +58,7 @@ public Export create(String exportId, String backend,
5858
* due to a malformed request, a networking error
5959
* or the server being unavailable.
6060
*/
61-
public Export create(CreateExportRequest request) throws IOException {
61+
private Export create(CreateExportRequest request) throws IOException {
6262
return this.restTransport.performRequest(request, CreateExportRequest._ENDPOINT);
6363
}
6464

src/main/java/io/weaviate/client6/v1/api/export/WeaviateExportClientAsync.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public WeaviateExportClientAsync(RestTransport restTransport) {
2020
* @param exportId Export ID. Must be unique for the backend.
2121
* @param backend Export storage backend.
2222
*/
23-
public CompletableFuture<Export> create(String exportId, String backend) {
24-
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId), backend));
23+
public CompletableFuture<Export> create(String exportId, String backend, FileFormat fileFormat) {
24+
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId, fileFormat), backend));
2525
}
2626

2727
/**
@@ -31,17 +31,17 @@ public CompletableFuture<Export> create(String exportId, String backend) {
3131
* @param backend Export storage backend.
3232
* @param fn Lambda expression for optional parameters.
3333
*/
34-
public CompletableFuture<Export> create(String exportId, String backend,
34+
public CompletableFuture<Export> create(String exportId, String backend, FileFormat fileFormat,
3535
Function<CreateExportRequest.ExportCreate.Builder, ObjectBuilder<CreateExportRequest.ExportCreate>> fn) {
36-
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId, fn), backend));
36+
return create(new CreateExportRequest(CreateExportRequest.ExportCreate.of(exportId, fileFormat, fn), backend));
3737
}
3838

3939
/**
4040
* Start a new export process.
4141
*
4242
* @param request Create export request.
4343
*/
44-
public CompletableFuture<Export> create(CreateExportRequest request) {
44+
private CompletableFuture<Export> create(CreateExportRequest request) {
4545
return this.restTransport.performRequestAsync(request, CreateExportRequest._ENDPOINT);
4646
}
4747

0 commit comments

Comments
 (0)