Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Jan 5, 2025
1 parent aa0e786 commit 2f23263
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ public class TextEmbeddingProcessor extends ProcessorBase
@Nullable
private final Integer batchSize;

@Nullable
private final String description;

@Nonnull
private final Map<String, String> fieldMap;

Expand All @@ -79,7 +76,6 @@ public class TextEmbeddingProcessor extends ProcessorBase
private TextEmbeddingProcessor(Builder builder) {
super(builder);
this.batchSize = builder.batchSize;
this.description = builder.description;
this.fieldMap = ApiTypeHelper.unmodifiableRequired(builder.fieldMap, this, "fieldMap");
this.modelId = ApiTypeHelper.requireNonNull(builder.modelId, this, "modelId");
}
Expand All @@ -104,17 +100,6 @@ public final Integer batchSize() {
return this.batchSize;
}

/**
* A brief description of the processor.
* <p>
* API name: {@code description}
* </p>
*/
@Nullable
public final String description() {
return this.description;
}

/**
* Required - Contains key-value pairs that specify the mapping of a text field to a vector field.
* <p>
Expand All @@ -141,11 +126,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.write(this.batchSize);
}

if (this.description != null) {
generator.writeKey("description");
generator.write(this.description);
}

generator.writeKey("field_map");
generator.writeStartObject();
for (Map.Entry<String, String> item0 : this.fieldMap.entrySet()) {
Expand Down Expand Up @@ -177,8 +157,6 @@ public static Builder builder() {
public static class Builder extends ProcessorBase.AbstractBuilder<Builder> implements CopyableBuilder<Builder, TextEmbeddingProcessor> {
@Nullable
private Integer batchSize;
@Nullable
private String description;
private Map<String, String> fieldMap;
private String modelId;

Expand All @@ -187,15 +165,13 @@ public Builder() {}
private Builder(TextEmbeddingProcessor o) {
super(o);
this.batchSize = o.batchSize;
this.description = o.description;
this.fieldMap = _mapCopy(o.fieldMap);
this.modelId = o.modelId;
}

private Builder(Builder o) {
super(o);
this.batchSize = o.batchSize;
this.description = o.description;
this.fieldMap = _mapCopy(o.fieldMap);
this.modelId = o.modelId;
}
Expand All @@ -221,18 +197,6 @@ public final Builder batchSize(@Nullable Integer value) {
return this;
}

/**
* A brief description of the processor.
* <p>
* API name: {@code description}
* </p>
*/
@Nonnull
public final Builder description(@Nullable String value) {
this.description = value;
return this;
}

/**
* Required - Contains key-value pairs that specify the mapping of a text field to a vector field.
* <p>
Expand Down Expand Up @@ -301,7 +265,6 @@ public TextEmbeddingProcessor build() {
protected static void setupTextEmbeddingProcessorDeserializer(ObjectDeserializer<TextEmbeddingProcessor.Builder> op) {
setupProcessorBaseDeserializer(op);
op.add(Builder::batchSize, JsonpDeserializer.integerDeserializer(), "batch_size");
op.add(Builder::description, JsonpDeserializer.stringDeserializer(), "description");
op.add(Builder::fieldMap, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "field_map");
op.add(Builder::modelId, JsonpDeserializer.stringDeserializer(), "model_id");
}
Expand All @@ -310,7 +273,6 @@ protected static void setupTextEmbeddingProcessorDeserializer(ObjectDeserializer
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(this.batchSize);
result = 31 * result + Objects.hashCode(this.description);
result = 31 * result + this.fieldMap.hashCode();
result = 31 * result + this.modelId.hashCode();
return result;
Expand All @@ -325,7 +287,6 @@ public boolean equals(Object o) {
if (o == null || this.getClass() != o.getClass()) return false;
TextEmbeddingProcessor other = (TextEmbeddingProcessor) o;
return Objects.equals(this.batchSize, other.batchSize)
&& Objects.equals(this.description, other.description)
&& this.fieldMap.equals(other.fieldMap)
&& this.modelId.equals(other.modelId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void testJsonRoundtripWithDescriptionAndBatchSize() {
baseTextEmbeddingProcessor().description("processor-description").batchSize(1).build()
).build();
String json =
"{\"text_embedding\":{\"tag\":\"some-tag\",\"model_id\":\"modelId\",\"field_map\":{\"input_field\":\"vector_field\"},\"description\":\"processor-description\",\"batch_size\":1}}";
"{\"text_embedding\":{\"description\":\"processor-description\",\"tag\":\"some-tag\",\"batch_size\":1,\"field_map\":{\"input_field\":\"vector_field\"},\"model_id\":\"modelId\"}}";
TextEmbeddingProcessor deserialized = checkJsonRoundtrip(processor, json).textEmbedding();

assertEquals("modelId", deserialized.modelId());
Expand All @@ -45,7 +45,7 @@ public void testJsonRoundtripWithDescriptionAndBatchSize() {
public void testJsonRoundtripWithoutDescription() {
Processor processor = new Processor.Builder().textEmbedding(baseTextEmbeddingProcessor().batchSize(1).build()).build();
String json =
"{\"text_embedding\":{\"tag\":\"some-tag\",\"model_id\":\"modelId\",\"field_map\":{\"input_field\":\"vector_field\"},\"batch_size\":1}}";
"{\"text_embedding\":{\"tag\":\"some-tag\",\"batch_size\":1,\"field_map\":{\"input_field\":\"vector_field\"},\"model_id\":\"modelId\"}}";
TextEmbeddingProcessor deserialized = checkJsonRoundtrip(processor, json).textEmbedding();

assertEquals("modelId", deserialized.modelId());
Expand All @@ -62,7 +62,7 @@ public void testJsonRoundtripWithoutBatchSize() {
baseTextEmbeddingProcessor().description("processor-description").build()
).build();
String json =
"{\"text_embedding\":{\"tag\":\"some-tag\",\"model_id\":\"modelId\",\"field_map\":{\"input_field\":\"vector_field\"},\"description\":\"processor-description\"}}";
"{\"text_embedding\":{\"description\":\"processor-description\",\"tag\":\"some-tag\",\"field_map\":{\"input_field\":\"vector_field\"},\"model_id\":\"modelId\"}}";
TextEmbeddingProcessor deserialized = checkJsonRoundtrip(processor, json).textEmbedding();

assertEquals("modelId", deserialized.modelId());
Expand All @@ -71,17 +71,4 @@ public void testJsonRoundtripWithoutBatchSize() {
assertEquals("some-tag", deserialized.tag());
assertNull(deserialized.batchSize());
}

@Test
public void testInvalidBatchSizeThrowsException() {
IllegalArgumentException exceptionWhenBatchSizeIsZero = assertThrows(IllegalArgumentException.class, () -> {
new Processor.Builder().textEmbedding(baseTextEmbeddingProcessor().batchSize(0).build()).build();
});
assertEquals("batchSize must be a positive integer", exceptionWhenBatchSizeIsZero.getMessage());

IllegalArgumentException exceptionWhenBatchSizeIsNegative = assertThrows(IllegalArgumentException.class, () -> {
new Processor.Builder().textEmbedding(baseTextEmbeddingProcessor().batchSize(-1).build()).build();
});
assertEquals("batchSize must be a positive integer", exceptionWhenBatchSizeIsNegative.getMessage());
}
}

0 comments on commit 2f23263

Please sign in to comment.