Skip to content

Commit

Permalink
refactor: Make vectors optional (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anush008 authored Sep 17, 2024
1 parent 669866a commit f986a7d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = 'io.qdrant'
version = '1.1.0'
version = '1.1.1'
description = 'Kafka Sink Connector for Qdrant.'
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/io/qdrant/kafka/ValueExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ValueExtractor {
private static final String COLLECTION_NAME_KEY = "collection_name";
private static final String VECTOR_KEY = "vector";
private static final String PAYLOAD_KEY = "payload";
private static final String[] REQUIRED_FIELDS = {"collection_name", "id", "vector"};
private static final String[] REQUIRED_FIELDS = {"collection_name", "id"};

private final Map<String, Value> valueMap;

Expand Down Expand Up @@ -76,6 +76,10 @@ public Map<String, Value> getPayload() {
public Vectors getVector() {
Value vectorValue = this.valueMap.get(VECTOR_KEY);

if (vectorValue == null) {
return Vectors.getDefaultInstance();
}

return VectorsFactory.vectors(vectorValue);
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/qdrant/kafka/ExtractorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void testValidateOptionsMissingField()
valueMap.put("id", 12345L);

ValueExtractor extractor = new ValueExtractor(valueMap);
assertThrows(DataException.class, extractor::validateOptions);
assertDoesNotThrow(extractor::validateOptions);
}

@Test
Expand Down

0 comments on commit f986a7d

Please sign in to comment.