Skip to content

Commit

Permalink
Generate KnnVectorProperty
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
(cherry picked from commit 6a930ad)
  • Loading branch information
Xtansia committed Oct 31, 2024
1 parent 5e13754 commit 8384ae8
Show file tree
Hide file tree
Showing 20 changed files with 721 additions and 366 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased 2.x]
### Added
- Added support for `KnnVectorProperty`'s `compression_level`, `data_type`, `mode` & `space_type` properties ([#1255](https://github.com/opensearch-project/opensearch-java/pull/1255))

### Dependencies
- Bumps `org.apache.httpcomponents.core5:httpcore5-h2` from 5.3 to 5.3.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types.mapping;

import jakarta.json.stream.JsonGenerator;
import java.util.List;
import java.util.Objects;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
Expand All @@ -42,7 +49,10 @@

// typedef: _types.mapping.CorePropertyBase

@Generated("org.opensearch.client.codegen.CodeGenerator")
public abstract class CorePropertyBase extends PropertyBase {

@Nonnull
private final List<String> copyTo;

@Nullable
Expand All @@ -55,16 +65,15 @@ public abstract class CorePropertyBase extends PropertyBase {

protected CorePropertyBase(AbstractBuilder<?> builder) {
super(builder);

this.copyTo = ApiTypeHelper.unmodifiable(builder.copyTo);
this.similarity = builder.similarity;
this.store = builder.store;

}

/**
* API name: {@code copy_to}
*/
@Nonnull
public final List<String> copyTo() {
return this.copyTo;
}
Expand All @@ -86,46 +95,44 @@ public final Boolean store() {
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (ApiTypeHelper.isDefined(this.copyTo)) {
generator.writeKey("copy_to");
generator.writeStartArray();
for (String item0 : this.copyTo) {
generator.write(item0);

}
generator.writeEnd();

}

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

}

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

}

}

// ---------------------------------------------------------------------------------------------

protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends PropertyBase.AbstractBuilder<
BuilderT> {
@Nullable
private List<String> copyTo;

@Nullable
private String similarity;

@Nullable
private Boolean store;

/**
* API name: {@code copy_to}
*
* <p>
* Adds all elements of <code>list</code> to <code>copyTo</code>.
* </p>
*/
public final BuilderT copyTo(List<String> list) {
this.copyTo = _listAddAll(this.copyTo, list);
Expand All @@ -134,8 +141,10 @@ public final BuilderT copyTo(List<String> list) {

/**
* API name: {@code copy_to}
*
* <p>
* Adds one or more values to <code>copyTo</code>.
* </p>
*/
public final BuilderT copyTo(String value, String... values) {
this.copyTo = _listAdd(this.copyTo, value, values);
Expand All @@ -161,12 +170,33 @@ public final BuilderT store(@Nullable Boolean value) {
}

// ---------------------------------------------------------------------------------------------

protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupCorePropertyBaseDeserializer(ObjectDeserializer<BuilderT> op) {
PropertyBase.setupPropertyBaseDeserializer(op);
setupPropertyBaseDeserializer(op);
op.add(AbstractBuilder::copyTo, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "copy_to");
op.add(AbstractBuilder::similarity, JsonpDeserializer.stringDeserializer(), "similarity");
op.add(AbstractBuilder::store, JsonpDeserializer.booleanDeserializer(), "store");
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(this.copyTo);
result = 31 * result + Objects.hashCode(this.similarity);
result = 31 * result + Objects.hashCode(this.store);
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
CorePropertyBase other = (CorePropertyBase) o;
return Objects.equals(this.copyTo, other.copyTo)
&& Objects.equals(this.similarity, other.similarity)
&& Objects.equals(this.store, other.store);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,33 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types.mapping;

import jakarta.json.stream.JsonGenerator;
import java.util.Objects;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectDeserializer;

// typedef: _types.mapping.DocValuesPropertyBase

@Generated("org.opensearch.client.codegen.CodeGenerator")
public abstract class DocValuesPropertyBase extends CorePropertyBase {

@Nullable
private final Boolean docValues;

// ---------------------------------------------------------------------------------------------

protected DocValuesPropertyBase(AbstractBuilder<?> builder) {
super(builder);

this.docValues = builder.docValues;

}

/**
Expand All @@ -62,16 +68,15 @@ public final Boolean docValues() {
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (this.docValues != null) {
generator.writeKey("doc_values");
generator.write(this.docValues);

}

}

// ---------------------------------------------------------------------------------------------

protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends CorePropertyBase.AbstractBuilder<
BuilderT> {
@Nullable
Expand All @@ -88,12 +93,29 @@ public final BuilderT docValues(@Nullable Boolean value) {
}

// ---------------------------------------------------------------------------------------------

protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupDocValuesPropertyBaseDeserializer(
ObjectDeserializer<BuilderT> op
) {
setupCorePropertyBaseDeserializer(op);
op.add(AbstractBuilder::docValues, JsonpDeserializer.booleanDeserializer(), "doc_values");
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(this.docValues);
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
DocValuesPropertyBase other = (DocValuesPropertyBase) o;
return Objects.equals(this.docValues, other.docValues);
}
}
Loading

0 comments on commit 8384ae8

Please sign in to comment.