Skip to content

Commit

Permalink
Merge branch 'main' into json-deser-exc
Browse files Browse the repository at this point in the history
  • Loading branch information
l-trotta authored Oct 17, 2024
2 parents d416490 + c757d18 commit a7b422e
Show file tree
Hide file tree
Showing 18 changed files with 1,228 additions and 353 deletions.
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

allprojects {
group = "co.elastic.clients"
version = (File(project.rootDir, "config/version.txt").readText().trim() + "-SNAPSHOT")

// Release manager provides a $VERSION. If not present, it's a local or CI snapshot build.
version = System.getenv("VERSION") ?:
(File(project.rootDir, "config/version.txt").readText().trim() + "-SNAPSHOT")
repositories {
maven {
name = "Elastic-Snapshots"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package co.elastic.clients.elasticsearch._types.mapping;

import co.elastic.clients.json.JsonEnum;
import co.elastic.clients.json.JsonpDeserializable;
import co.elastic.clients.json.JsonpDeserializer;

//----------------------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------------------
//
// This code is generated from the Elasticsearch API specification
// at /~https://github.com/elastic/elasticsearch-specification
//
// Manual updates to this file will be lost when the code is
// re-generated.
//
// If you find a property that is missing or wrongly typed, please
// open an issue or a PR on the API specification repository.
//
//----------------------------------------------------------------

/**
*
* @see <a href=
* "../../doc-files/api-spec.html#_types.mapping.DenseVectorElementType">API
* specification</a>
*/
@JsonpDeserializable
public enum DenseVectorElementType implements JsonEnum {
/**
* Indexes a single bit per dimension. Useful for very high-dimensional vectors
* or models that specifically support bit vectors.
* <p>
* NOTE: when using <code>bit</code>, the number of dimensions must be a
* multiple of <code>8</code> and must represent the number of bits.
*/
Bit("bit"),

/**
* Indexes a 1-byte integer value per dimension.
*/
Byte("byte"),

/**
* Indexes a 4-byte floating-point value per dimension.
*/
Float("float"),

;

private final String jsonValue;

DenseVectorElementType(String jsonValue) {
this.jsonValue = jsonValue;
}

public String jsonValue() {
return this.jsonValue;
}

public static final JsonEnum.Deserializer<DenseVectorElementType> _DESERIALIZER = new JsonEnum.Deserializer<>(
DenseVectorElementType.values());
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import jakarta.json.stream.JsonGenerator;
import java.lang.Float;
import java.lang.Integer;
import java.lang.String;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -62,25 +61,25 @@
*/
@JsonpDeserializable
public class DenseVectorIndexOptions implements JsonpSerializable {
private final String type;

@Nullable
private final Integer m;
private final Float confidenceInterval;

@Nullable
private final Integer efConstruction;

@Nullable
private final Float confidenceInterval;
private final Integer m;

private final DenseVectorIndexOptionsType type;

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

private DenseVectorIndexOptions(Builder builder) {

this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type");
this.m = builder.m;
this.efConstruction = builder.efConstruction;
this.confidenceInterval = builder.confidenceInterval;
this.efConstruction = builder.efConstruction;
this.m = builder.m;
this.type = ApiTypeHelper.requireNonNull(builder.type, this, "type");

}

Expand All @@ -89,21 +88,37 @@ public static DenseVectorIndexOptions of(Function<Builder, ObjectBuilder<DenseVe
}

/**
* Required - API name: {@code type}
*/
public final String type() {
return this.type;
}

/**
* API name: {@code m}
* The confidence interval to use when quantizing the vectors. Can be any value
* between and including <code>0.90</code> and <code>1.0</code> or exactly
* <code>0</code>. When the value is <code>0</code>, this indicates that dynamic
* quantiles should be calculated for optimized quantization. When between
* <code>0.90</code> and <code>1.0</code>, this value restricts the values used
* when calculating the quantization thresholds.
* <p>
* For example, a value of <code>0.95</code> will only use the middle
* <code>95%</code> of the values when calculating the quantization thresholds
* (e.g. the highest and lowest <code>2.5%</code> of values will be ignored).
* <p>
* Defaults to <code>1/(dims + 1)</code> for <code>int8</code> quantized vectors
* and <code>0</code> for <code>int4</code> for dynamic quantile calculation.
* <p>
* Only applicable to <code>int8_hnsw</code>, <code>int4_hnsw</code>,
* <code>int8_flat</code>, and <code>int4_flat</code> index types.
* <p>
* API name: {@code confidence_interval}
*/
@Nullable
public final Integer m() {
return this.m;
public final Float confidenceInterval() {
return this.confidenceInterval;
}

/**
* The number of candidates to track while assembling the list of nearest
* neighbors for each new node.
* <p>
* Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
* <code>int4_hnsw</code> index types.
* <p>
* API name: {@code ef_construction}
*/
@Nullable
Expand All @@ -112,11 +127,25 @@ public final Integer efConstruction() {
}

/**
* API name: {@code confidence_interval}
* The number of neighbors each node will be connected to in the HNSW graph.
* <p>
* Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
* <code>int4_hnsw</code> index types.
* <p>
* API name: {@code m}
*/
@Nullable
public final Float confidenceInterval() {
return this.confidenceInterval;
public final Integer m() {
return this.m;
}

/**
* Required - The type of kNN algorithm to use.
* <p>
* API name: {@code type}
*/
public final DenseVectorIndexOptionsType type() {
return this.type;
}

/**
Expand All @@ -130,24 +159,23 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.writeKey("type");
generator.write(this.type);

if (this.m != null) {
generator.writeKey("m");
generator.write(this.m);
if (this.confidenceInterval != null) {
generator.writeKey("confidence_interval");
generator.write(this.confidenceInterval);

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

}
if (this.confidenceInterval != null) {
generator.writeKey("confidence_interval");
generator.write(this.confidenceInterval);
if (this.m != null) {
generator.writeKey("m");
generator.write(this.m);

}
generator.writeKey("type");
this.type.serialize(generator, mapper);

}

Expand All @@ -165,46 +193,76 @@ public String toString() {
public static class Builder extends WithJsonObjectBuilderBase<Builder>
implements
ObjectBuilder<DenseVectorIndexOptions> {
private String type;

@Nullable
private Integer m;
private Float confidenceInterval;

@Nullable
private Integer efConstruction;

@Nullable
private Float confidenceInterval;
private Integer m;

private DenseVectorIndexOptionsType type;

/**
* Required - API name: {@code type}
* The confidence interval to use when quantizing the vectors. Can be any value
* between and including <code>0.90</code> and <code>1.0</code> or exactly
* <code>0</code>. When the value is <code>0</code>, this indicates that dynamic
* quantiles should be calculated for optimized quantization. When between
* <code>0.90</code> and <code>1.0</code>, this value restricts the values used
* when calculating the quantization thresholds.
* <p>
* For example, a value of <code>0.95</code> will only use the middle
* <code>95%</code> of the values when calculating the quantization thresholds
* (e.g. the highest and lowest <code>2.5%</code> of values will be ignored).
* <p>
* Defaults to <code>1/(dims + 1)</code> for <code>int8</code> quantized vectors
* and <code>0</code> for <code>int4</code> for dynamic quantile calculation.
* <p>
* Only applicable to <code>int8_hnsw</code>, <code>int4_hnsw</code>,
* <code>int8_flat</code>, and <code>int4_flat</code> index types.
* <p>
* API name: {@code confidence_interval}
*/
public final Builder type(String value) {
this.type = value;
public final Builder confidenceInterval(@Nullable Float value) {
this.confidenceInterval = value;
return this;
}

/**
* API name: {@code m}
* The number of candidates to track while assembling the list of nearest
* neighbors for each new node.
* <p>
* Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
* <code>int4_hnsw</code> index types.
* <p>
* API name: {@code ef_construction}
*/
public final Builder m(@Nullable Integer value) {
this.m = value;
public final Builder efConstruction(@Nullable Integer value) {
this.efConstruction = value;
return this;
}

/**
* API name: {@code ef_construction}
* The number of neighbors each node will be connected to in the HNSW graph.
* <p>
* Only applicable to <code>hnsw</code>, <code>int8_hnsw</code>, and
* <code>int4_hnsw</code> index types.
* <p>
* API name: {@code m}
*/
public final Builder efConstruction(@Nullable Integer value) {
this.efConstruction = value;
public final Builder m(@Nullable Integer value) {
this.m = value;
return this;
}

/**
* API name: {@code confidence_interval}
* Required - The type of kNN algorithm to use.
* <p>
* API name: {@code type}
*/
public final Builder confidenceInterval(@Nullable Float value) {
this.confidenceInterval = value;
public final Builder type(DenseVectorIndexOptionsType value) {
this.type = value;
return this;
}

Expand Down Expand Up @@ -237,10 +295,10 @@ public DenseVectorIndexOptions build() {
protected static void setupDenseVectorIndexOptionsDeserializer(
ObjectDeserializer<DenseVectorIndexOptions.Builder> op) {

op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type");
op.add(Builder::m, JsonpDeserializer.integerDeserializer(), "m");
op.add(Builder::efConstruction, JsonpDeserializer.integerDeserializer(), "ef_construction");
op.add(Builder::confidenceInterval, JsonpDeserializer.floatDeserializer(), "confidence_interval");
op.add(Builder::efConstruction, JsonpDeserializer.integerDeserializer(), "ef_construction");
op.add(Builder::m, JsonpDeserializer.integerDeserializer(), "m");
op.add(Builder::type, DenseVectorIndexOptionsType._DESERIALIZER, "type");

}

Expand Down
Loading

0 comments on commit a7b422e

Please sign in to comment.