Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
80a8936
feat: apply default consistencyLevel to queries
bevzzz Aug 18, 2025
ede84ab
fix: set consistencyLevel for pre-built QueryOperators
bevzzz Aug 18, 2025
ca05c31
test: dry test setup
bevzzz Aug 18, 2025
4c881a5
refactor: apply defaults at marshal
bevzzz Aug 19, 2025
239837c
feat: make delete/insertMany consistencyLevel-aware
bevzzz Aug 19, 2025
c352330
feat: add default consistencyLevel to all methods in 'data' namespace
bevzzz Aug 20, 2025
fae8088
feat: set default consistency in all 'query' requests
bevzzz Aug 20, 2025
1a4aa2b
chore: remove unused imports
bevzzz Aug 20, 2025
423268c
chore: format test cases
bevzzz Aug 20, 2025
39a60aa
refactor: add consistencyLevel via defaults::rpc utility
bevzzz Aug 20, 2025
9396504
feat: add default tenant to aggregations
bevzzz Aug 20, 2025
0e8b422
feat: add default tenant to queries
bevzzz Aug 20, 2025
e197cde
feat: add default tenant to 'data' operations
bevzzz Aug 20, 2025
b1a15f3
refactor: simplify the logic for adding default request parameters
bevzzz Aug 21, 2025
68978c8
refactor: remove unnecessary abstraction
bevzzz Aug 21, 2025
4b52821
feat: filter out invalid (null/blank) query parameters
bevzzz Aug 21, 2025
904bac2
feat: add withTenant and withDefaults to CollectionHandleAsync
bevzzz Aug 21, 2025
452ffc0
chore: delete unused variables
bevzzz Aug 21, 2025
9d35d74
feat: add tenants API
bevzzz Aug 22, 2025
c4b424a
feat: add tenants to async handle
bevzzz Aug 22, 2025
6948c9c
feat: add default tenant to get-shards endpoint
bevzzz Aug 22, 2025
2e874a8
fix: pass new defaults to aggregate client
bevzzz Aug 22, 2025
047fc20
chore: update javadoc
bevzzz Aug 22, 2025
b9765b2
test: add test case for get-shards
bevzzz Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,50 @@
import io.weaviate.client6.v1.api.collections.config.WeaviateConfigClient;
import io.weaviate.client6.v1.api.collections.data.WeaviateDataClient;
import io.weaviate.client6.v1.api.collections.pagination.Paginator;
import io.weaviate.client6.v1.api.collections.query.ConsistencyLevel;
import io.weaviate.client6.v1.api.collections.query.WeaviateQueryClient;
import io.weaviate.client6.v1.internal.ObjectBuilder;
import io.weaviate.client6.v1.internal.grpc.GrpcTransport;
import io.weaviate.client6.v1.internal.orm.CollectionDescriptor;
import io.weaviate.client6.v1.internal.rest.RestTransport;

public class CollectionHandle<T> {
public class CollectionHandle<PropertiesT> {
public final WeaviateConfigClient config;
public final WeaviateDataClient<T> data;
public final WeaviateQueryClient<T> query;
public final WeaviateDataClient<PropertiesT> data;
public final WeaviateQueryClient<PropertiesT> query;
public final WeaviateAggregateClient aggregate;

private final CollectionHandleDefaults defaults;

public CollectionHandle(
RestTransport restTransport,
GrpcTransport grpcTransport,
CollectionDescriptor<T> collectionDescriptor) {

CollectionDescriptor<PropertiesT> collectionDescriptor,
CollectionHandleDefaults defaults) {
this.config = new WeaviateConfigClient(collectionDescriptor, restTransport, grpcTransport);
this.data = new WeaviateDataClient<>(collectionDescriptor, restTransport, grpcTransport);
this.query = new WeaviateQueryClient<>(collectionDescriptor, grpcTransport);
this.aggregate = new WeaviateAggregateClient(collectionDescriptor, grpcTransport);
this.aggregate = new WeaviateAggregateClient(collectionDescriptor, grpcTransport, defaults);
this.query = new WeaviateQueryClient<>(collectionDescriptor, grpcTransport, defaults);
this.data = new WeaviateDataClient<>(collectionDescriptor, restTransport, grpcTransport, defaults);

this.defaults = defaults;
}

/** Copy constructor that sets new defaults. */
private CollectionHandle(CollectionHandle<PropertiesT> c, CollectionHandleDefaults defaults) {
this.config = c.config;
this.aggregate = c.aggregate;
this.query = new WeaviateQueryClient<>(c.query, defaults);
this.data = new WeaviateDataClient<>(c.data, defaults);

this.defaults = defaults;
}

public Paginator<T> paginate() {
public Paginator<PropertiesT> paginate() {
return Paginator.of(this.query);
}

public Paginator<T> paginate(Function<Paginator.Builder<T>, ObjectBuilder<Paginator<T>>> fn) {
public Paginator<PropertiesT> paginate(
Function<Paginator.Builder<PropertiesT>, ObjectBuilder<Paginator<PropertiesT>>> fn) {
return Paginator.of(this.query, fn);
}

Expand All @@ -57,4 +73,25 @@ public Paginator<T> paginate(Function<Paginator.Builder<T>, ObjectBuilder<Pagina
public long size() {
return this.aggregate.overAll(all -> all.includeTotalCount(true)).totalCount();
}

public ConsistencyLevel consistencyLevel() {
return defaults.consistencyLevel();
}

public CollectionHandle<PropertiesT> withConsistencyLevel(ConsistencyLevel consistencyLevel) {
return new CollectionHandle<>(this, CollectionHandleDefaults.of(with -> with.consistencyLevel(consistencyLevel)));
}

public String tenant() {
return defaults.tenant();
}

public CollectionHandle<PropertiesT> withTenant(String tenant) {
return new CollectionHandle<>(this, CollectionHandleDefaults.of(with -> with.tenant(tenant)));
}

public CollectionHandle<PropertiesT> withDefaults(
Function<CollectionHandleDefaults.Builder, ObjectBuilder<CollectionHandleDefaults>> fn) {
return new CollectionHandle<>(this, CollectionHandleDefaults.of(fn));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.weaviate.client6.v1.api.collections.config.WeaviateConfigClientAsync;
import io.weaviate.client6.v1.api.collections.data.WeaviateDataClientAsync;
import io.weaviate.client6.v1.api.collections.pagination.AsyncPaginator;
import io.weaviate.client6.v1.api.collections.query.ConsistencyLevel;
import io.weaviate.client6.v1.api.collections.query.WeaviateQueryClientAsync;
import io.weaviate.client6.v1.internal.ObjectBuilder;
import io.weaviate.client6.v1.internal.grpc.GrpcTransport;
Expand All @@ -21,15 +22,30 @@ public class CollectionHandleAsync<PropertiesT> {
public final WeaviateQueryClientAsync<PropertiesT> query;
public final WeaviateAggregateClientAsync aggregate;

private final CollectionHandleDefaults defaults;

public CollectionHandleAsync(
RestTransport restTransport,
GrpcTransport grpcTransport,
CollectionDescriptor<PropertiesT> collectionDescriptor) {
CollectionDescriptor<PropertiesT> collectionDescriptor,
CollectionHandleDefaults defaults) {

this.config = new WeaviateConfigClientAsync(collectionDescriptor, restTransport, grpcTransport);
this.data = new WeaviateDataClientAsync<>(collectionDescriptor, restTransport, grpcTransport);
this.query = new WeaviateQueryClientAsync<>(collectionDescriptor, grpcTransport);
this.aggregate = new WeaviateAggregateClientAsync(collectionDescriptor, grpcTransport);
this.aggregate = new WeaviateAggregateClientAsync(collectionDescriptor, grpcTransport, defaults);
this.query = new WeaviateQueryClientAsync<>(collectionDescriptor, grpcTransport, defaults);
this.data = new WeaviateDataClientAsync<>(collectionDescriptor, restTransport, grpcTransport, defaults);

this.defaults = defaults;
}

/** Copy constructor that sets new defaults. */
private CollectionHandleAsync(CollectionHandleAsync<PropertiesT> c, CollectionHandleDefaults defaults) {
this.config = c.config;
this.aggregate = c.aggregate;
this.query = new WeaviateQueryClientAsync<>(c.query, defaults);
this.data = new WeaviateDataClientAsync<>(c.data, defaults);

this.defaults = defaults;
}

public AsyncPaginator<PropertiesT> paginate() {
Expand Down Expand Up @@ -64,4 +80,13 @@ public CompletableFuture<Long> size() {
return this.aggregate.overAll(all -> all.includeTotalCount(true))
.thenApply(AggregateResponse::totalCount);
}

public ConsistencyLevel consistencyLevel() {
return defaults.consistencyLevel();
}

public CollectionHandleAsync<PropertiesT> withConsistencyLevel(ConsistencyLevel consistencyLevel) {
return new CollectionHandleAsync<>(this, CollectionHandleDefaults.of(
def -> def.consistencyLevel(consistencyLevel)));
}
}
Loading