Skip to content

Commit b74d4eb

Browse files
authored
Merge pull request #541 from weaviate/feat/hfresh
Add HFresh index configuration
2 parents 4f3dcc5 + a15ad1f commit b74d4eb

3 files changed

Lines changed: 792 additions & 691 deletions

File tree

src/main/java/io/weaviate/client6/v1/api/collections/VectorIndex.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import io.weaviate.client6.v1.api.collections.vectorindex.Dynamic;
1717
import io.weaviate.client6.v1.api.collections.vectorindex.Flat;
18+
import io.weaviate.client6.v1.api.collections.vectorindex.HFresh;
1819
import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw;
1920
import io.weaviate.client6.v1.internal.TaggedUnion;
2021
import io.weaviate.client6.v1.internal.json.JsonEnum;
@@ -26,7 +27,8 @@ public interface VectorIndex extends TaggedUnion<VectorIndex.Kind, Object> {
2627
enum Kind implements JsonEnum<Kind> {
2728
HNSW("hnsw"),
2829
FLAT("flat"),
29-
DYNAMIC("dynamic");
30+
DYNAMIC("dynamic"),
31+
HFRESH("hfresh");
3032

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

80+
/** Is this vector index of type HFRESH? */
81+
default boolean isHFresh() {
82+
return _is(VectorIndex.Kind.HFRESH);
83+
}
84+
85+
/** Get as {@link HFresh} instance. */
86+
default HFresh asHFresh() {
87+
return _as(VectorIndex.Kind.HFRESH);
88+
}
89+
7890
static enum CustomTypeAdapterFactory implements TypeAdapterFactory {
7991
INSTANCE;
8092

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

94107
@SuppressWarnings("unchecked")
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package io.weaviate.client6.v1.api.collections.vectorindex;
2+
3+
import java.util.function.Function;
4+
5+
import com.google.gson.annotations.SerializedName;
6+
7+
import io.weaviate.client6.v1.api.collections.VectorIndex;
8+
import io.weaviate.client6.v1.internal.ObjectBuilder;
9+
10+
public record HFresh(
11+
@SerializedName("distance") Distance distance,
12+
@SerializedName("maxPostingSizeKB") Integer maxPostingSizeKb,
13+
@SerializedName("replicas") Integer replicaCount,
14+
@SerializedName("searchProbe") Integer searchProbe) implements VectorIndex {
15+
16+
@Override
17+
public VectorIndex.Kind _kind() {
18+
return VectorIndex.Kind.HFRESH;
19+
}
20+
21+
@Override
22+
public Object _self() {
23+
return this;
24+
}
25+
26+
public static HFresh of() {
27+
return of(ObjectBuilder.identity());
28+
}
29+
30+
public static HFresh of(Function<Builder, ObjectBuilder<HFresh>> fn) {
31+
return fn.apply(new Builder()).build();
32+
}
33+
34+
public HFresh(Builder builder) {
35+
this(
36+
builder.distance,
37+
builder.maxPostingSizeKb,
38+
builder.replicaCount,
39+
builder.searchProbe);
40+
}
41+
42+
public static class Builder implements ObjectBuilder<HFresh> {
43+
private Distance distance;
44+
private Integer maxPostingSizeKb;
45+
private Integer replicaCount;
46+
private Integer searchProbe;
47+
48+
public Builder distance(Distance distance) {
49+
this.distance = distance;
50+
return this;
51+
}
52+
53+
public final Builder maxPostingSizeKb(int maxPostingSizeKb) {
54+
this.maxPostingSizeKb = maxPostingSizeKb;
55+
return this;
56+
}
57+
58+
public final Builder replicaCount(int replicaCount) {
59+
this.replicaCount = replicaCount;
60+
return this;
61+
}
62+
63+
public final Builder searchProbe(int searchProbe) {
64+
this.searchProbe = searchProbe;
65+
return this;
66+
}
67+
68+
@Override
69+
public HFresh build() {
70+
return new HFresh(this);
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)