Skip to content

Commit ce15aa1

Browse files
committed
chore: rename Vectorizer -> VectorConfig and move static factories under the new namespace
1 parent 47b21dd commit ce15aa1

16 files changed

Lines changed: 371 additions & 402 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import io.weaviate.ConcurrentTest;
1515
import io.weaviate.client6.v1.api.WeaviateClient;
1616
import io.weaviate.client6.v1.api.collections.Property;
17-
import io.weaviate.client6.v1.api.collections.Vectorizers;
17+
import io.weaviate.client6.v1.api.collections.VectorConfig;
1818
import io.weaviate.client6.v1.api.collections.Vectors;
1919
import io.weaviate.client6.v1.api.collections.aggregate.Aggregate;
2020
import io.weaviate.client6.v1.api.collections.aggregate.AggregateResponseGroup;
@@ -35,7 +35,7 @@ public static void beforeAll() throws IOException {
3535
.properties(
3636
Property.text("category"),
3737
Property.integer("price"))
38-
.vectorConfig(Vectorizers.selfProvided()));
38+
.vectorConfig(VectorConfig.selfProvided()));
3939

4040
var things = client.collections.use(COLLECTION);
4141
for (var category : List.of("Shoes", "Hat", "Jacket")) {

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import io.weaviate.client6.v1.api.collections.Property;
1515
import io.weaviate.client6.v1.api.collections.ReferenceProperty;
1616
import io.weaviate.client6.v1.api.collections.Replication;
17-
import io.weaviate.client6.v1.api.collections.Vectorizer;
18-
import io.weaviate.client6.v1.api.collections.Vectorizers;
17+
import io.weaviate.client6.v1.api.collections.VectorConfig;
1918
import io.weaviate.client6.v1.api.collections.config.Shard;
2019
import io.weaviate.client6.v1.api.collections.config.ShardStatus;
2120
import io.weaviate.client6.v1.api.collections.vectorindex.Hnsw;
@@ -31,18 +30,18 @@ public void testCreateGetDelete() throws IOException {
3130
client.collections.create(collectionName,
3231
col -> col
3332
.properties(Property.text("username"), Property.integer("age"))
34-
.vectorConfig(Vectorizers.selfProvided()));
33+
.vectorConfig(VectorConfig.selfProvided()));
3534

3635
var thingsCollection = client.collections.getConfig(collectionName);
3736

3837
Assertions.assertThat(thingsCollection).get()
3938
.hasFieldOrPropertyWithValue("collectionName", collectionName)
40-
.extracting(CollectionConfig::vectors, InstanceOfAssertFactories.map(String.class, Vectorizer.class))
39+
.extracting(CollectionConfig::vectors, InstanceOfAssertFactories.map(String.class, VectorConfig.class))
4140
.as("default vector").extractingByKey("default")
4241
.satisfies(defaultVector -> {
4342
Assertions.assertThat(defaultVector)
4443
.as("has none vectorizer").isInstanceOf(SelfProvidedVectorizer.class);
45-
Assertions.assertThat(defaultVector).extracting(Vectorizer::vectorIndex)
44+
Assertions.assertThat(defaultVector).extracting(VectorConfig::vectorIndex)
4645
.isInstanceOf(Hnsw.class);
4746
});
4847

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import io.weaviate.client6.v1.api.WeaviateClient;
1717
import io.weaviate.client6.v1.api.collections.Property;
1818
import io.weaviate.client6.v1.api.collections.ReferenceProperty;
19-
import io.weaviate.client6.v1.api.collections.Vectorizers;
19+
import io.weaviate.client6.v1.api.collections.VectorConfig;
2020
import io.weaviate.client6.v1.api.collections.Vectors;
2121
import io.weaviate.client6.v1.api.collections.WeaviateObject;
2222
import io.weaviate.client6.v1.api.collections.data.BatchReference;
@@ -118,7 +118,7 @@ private static void createTestCollections() throws IOException {
118118
Property.integer("age"))
119119
.references(
120120
ReferenceProperty.to("hasAwards", awardsGrammy, awardsOscar))
121-
.vectorConfig(Vectorizers.selfProvided(VECTOR_INDEX)));
121+
.vectorConfig(VectorConfig.selfProvided(VECTOR_INDEX)));
122122
}
123123

124124
@Test
@@ -234,7 +234,7 @@ public void testUpdate() throws IOException {
234234
collection -> collection
235235
.properties(Property.text("title"), Property.integer("year"))
236236
.references(ReferenceProperty.to("writtenBy", nsAuthors))
237-
.vectorConfig(Vectorizers.selfProvided()));
237+
.vectorConfig(VectorConfig.selfProvided()));
238238

239239
var authors = client.collections.use(nsAuthors);
240240
var walter = authors.data.insert(Map.of("name", "walter scott"));

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import io.weaviate.client6.v1.api.WeaviateClient;
2222
import io.weaviate.client6.v1.api.collections.Property;
2323
import io.weaviate.client6.v1.api.collections.ReferenceProperty;
24-
import io.weaviate.client6.v1.api.collections.Vectorizers;
24+
import io.weaviate.client6.v1.api.collections.VectorConfig;
2525
import io.weaviate.client6.v1.api.collections.Vectors;
2626
import io.weaviate.client6.v1.api.collections.WeaviateMetadata;
2727
import io.weaviate.client6.v1.api.collections.WeaviateObject;
@@ -134,7 +134,7 @@ private static Map<String, float[]> populateTest(int n) throws IOException {
134134
private static void createTestCollection() throws IOException {
135135
client.collections.create(COLLECTION, cfg -> cfg
136136
.properties(Property.text("category"))
137-
.vectorConfig(Vectorizers.selfProvided(VECTOR_INDEX)));
137+
.vectorConfig(VectorConfig.selfProvided(VECTOR_INDEX)));
138138
}
139139

140140
@Test
@@ -143,7 +143,7 @@ public void testNearText() throws IOException {
143143
client.collections.create(nsSongs,
144144
col -> col
145145
.properties(Property.text("title"))
146-
.vectorConfig(Vectorizers.text2vecContextionary()));
146+
.vectorConfig(VectorConfig.text2vecContextionary()));
147147

148148
var songs = client.collections.use(nsSongs);
149149
var submarine = songs.data.insert(Map.of("title", "Yellow Submarine"));
@@ -165,7 +165,7 @@ public void testNearText() throws IOException {
165165

166166
@Test
167167
public void testNearText_groupBy() throws IOException {
168-
var vectorizer = Vectorizers.text2vecContextionary();
168+
var vectorizer = VectorConfig.text2vecContextionary();
169169

170170
var nsArtists = ns("Artists");
171171
client.collections.create(nsArtists,
@@ -209,7 +209,7 @@ public void testNearImage() throws IOException {
209209
.properties(
210210
Property.text("breed"),
211211
Property.blob("img"))
212-
.vectorConfig(Vectorizers.img2vecNeural(
212+
.vectorConfig(VectorConfig.img2vecNeural(
213213
i2v -> i2v.imageFields("img"))));
214214

215215
var cats = client.collections.use(nsCats);
@@ -391,7 +391,7 @@ public void testNearObject() throws IOException {
391391
client.collections.create(nsAnimals,
392392
collection -> collection
393393
.properties(Property.text("kind"))
394-
.vectorConfig(Vectorizers.text2vecContextionary()));
394+
.vectorConfig(VectorConfig.text2vecContextionary()));
395395

396396
var animals = client.collections.use(nsAnimals);
397397

@@ -420,7 +420,7 @@ public void testHybrid() throws IOException {
420420
client.collections.create(nsHobbies,
421421
collection -> collection
422422
.properties(Property.text("name"), Property.text("description"))
423-
.vectorConfig(Vectorizers.text2vecContextionary()));
423+
.vectorConfig(VectorConfig.text2vecContextionary()));
424424

425425
var hobbies = client.collections.use(nsHobbies);
426426

@@ -453,7 +453,7 @@ public void testBadRequest() throws IOException {
453453
client.collections.create(nsThings,
454454
collection -> collection
455455
.properties(Property.text("name"))
456-
.vectorConfig(Vectorizers.text2vecContextionary()));
456+
.vectorConfig(VectorConfig.text2vecContextionary()));
457457

458458
var things = client.collections.use(nsThings);
459459
var balloon = things.data.insert(Map.of("name", "balloon"));
@@ -470,7 +470,7 @@ public void testBadRequest_async() throws Throwable {
470470
async.collections.create(nsThings,
471471
collection -> collection
472472
.properties(Property.text("name"))
473-
.vectorConfig(Vectorizers.text2vecContextionary()))
473+
.vectorConfig(VectorConfig.text2vecContextionary()))
474474
.join();
475475

476476
var things = async.collections.use(nsThings);

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public record CollectionConfig(
2727
@SerializedName("description") String description,
2828
@SerializedName("properties") List<Property> properties,
2929
List<ReferenceProperty> references,
30-
@SerializedName("vectorConfig") Map<String, Vectorizer> vectors,
30+
@SerializedName("vectorConfig") Map<String, VectorConfig> vectors,
3131
@SerializedName("multiTenancyConfig") MultiTenancy multiTenancy,
3232
@SerializedName("shardingConfig") Sharding sharding,
3333
@SerializedName("replicationConfig") Replication replication,
@@ -88,7 +88,7 @@ public static class Builder implements ObjectBuilder<CollectionConfig> {
8888
private String description;
8989
private Map<String, Property> properties = new HashMap<>();
9090
private Map<String, ReferenceProperty> references = new HashMap<>();
91-
private Map<String, Vectorizer> vectors = new HashMap<>();
91+
private Map<String, VectorConfig> vectors = new HashMap<>();
9292
private MultiTenancy multiTenancy;
9393
private Sharding sharding;
9494
private Replication replication;
@@ -131,31 +131,17 @@ private List<ReferenceProperty> referenceList() {
131131
return this.references.values().stream().toList();
132132
}
133133

134-
public final Builder vectorConfig(Map<String, Vectorizer> vectors) {
134+
public final Builder vectorConfig(Map<String, VectorConfig> vectors) {
135135
this.vectors.putAll(vectors);
136136
return this;
137137
}
138138

139139
@SafeVarargs
140-
public final Builder vectorConfig(Map.Entry<String, Vectorizer>... vectors) {
140+
public final Builder vectorConfig(Map.Entry<String, VectorConfig>... vectors) {
141141
this.vectors.putAll(Map.ofEntries(vectors));
142142
return this;
143143
}
144144

145-
public static class VectorsBuilder implements ObjectBuilder<Map<String, VectorIndex>> {
146-
private Map<String, VectorIndex> vectors = new HashMap<>();
147-
148-
public VectorsBuilder vector(String name, VectorIndex vector) {
149-
vectors.put(name, vector);
150-
return this;
151-
}
152-
153-
@Override
154-
public Map<String, VectorIndex> build() {
155-
return this.vectors;
156-
}
157-
}
158-
159145
public Builder sharding(Sharding sharding) {
160146
this.sharding = sharding;
161147
return this;

0 commit comments

Comments
 (0)