Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -15,6 +15,7 @@

import io.weaviate.client6.v1.api.collections.vectorindex.Dynamic;
import io.weaviate.client6.v1.api.collections.vectorindex.Flat;
import io.weaviate.client6.v1.api.collections.vectorindex.HFresh;
import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw;
import io.weaviate.client6.v1.internal.TaggedUnion;
import io.weaviate.client6.v1.internal.json.JsonEnum;
Expand All @@ -26,7 +27,8 @@ public interface VectorIndex extends TaggedUnion<VectorIndex.Kind, Object> {
enum Kind implements JsonEnum<Kind> {
HNSW("hnsw"),
FLAT("flat"),
DYNAMIC("dynamic");
DYNAMIC("dynamic"),
HFRESH("hfresh");

private static final Map<String, Kind> jsonValueMap = JsonEnum.collectNames(Kind.values());
private final String jsonValue;
Expand Down Expand Up @@ -75,6 +77,16 @@ default Dynamic asDynamic() {
return _as(VectorIndex.Kind.DYNAMIC);
}

/** Is this vector index of type HFRESH? */
default boolean isHFresh() {
return _is(VectorIndex.Kind.HFRESH);
}

/** Get as {@link HFresh} instance. */
default HFresh asHFresh() {
return _as(VectorIndex.Kind.HFRESH);
}

static enum CustomTypeAdapterFactory implements TypeAdapterFactory {
INSTANCE;

Expand All @@ -89,6 +101,7 @@ private final void init(Gson gson) {
addAdapter(gson, VectorIndex.Kind.HNSW, Hnsw.class);
addAdapter(gson, VectorIndex.Kind.FLAT, Flat.class);
addAdapter(gson, VectorIndex.Kind.DYNAMIC, Dynamic.class);
addAdapter(gson, VectorIndex.Kind.HFRESH, HFresh.class);
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package io.weaviate.client6.v1.api.collections.vectorindex;

import java.util.function.Function;

import com.google.gson.annotations.SerializedName;

import io.weaviate.client6.v1.api.collections.VectorIndex;
import io.weaviate.client6.v1.internal.ObjectBuilder;

public record HFresh(
@SerializedName("distance") Distance distance,
@SerializedName("maxPostingSizeKB") Integer maxPostingSizeKb,
@SerializedName("replicas") Integer replicaCount,
@SerializedName("searchProbe") Integer searchProbe) implements VectorIndex {

@Override
public VectorIndex.Kind _kind() {
return VectorIndex.Kind.HFRESH;
}

@Override
public Object _self() {
return this;
}

public static HFresh of() {
return of(ObjectBuilder.identity());
}

public static HFresh of(Function<Builder, ObjectBuilder<HFresh>> fn) {
return fn.apply(new Builder()).build();
}

public HFresh(Builder builder) {
this(
builder.distance,
builder.maxPostingSizeKb,
builder.replicaCount,
builder.searchProbe);
}

public static class Builder implements ObjectBuilder<HFresh> {
private Distance distance;
private Integer maxPostingSizeKb;
private Integer replicaCount;
private Integer searchProbe;

public Builder distance(Distance distance) {
this.distance = distance;
return this;
}

public final Builder maxPostingSizeKb(int maxPostingSizeKb) {
this.maxPostingSizeKb = maxPostingSizeKb;
return this;
}

public final Builder replicaCount(int replicaCount) {
this.replicaCount = replicaCount;
return this;
}

public final Builder searchProbe(int searchProbe) {
this.searchProbe = searchProbe;
return this;
}

@Override
public HFresh build() {
return new HFresh(this);
}
}
}
Loading