# EmbeddingVector.QuantizedData

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/EmbeddingVector.java+class:androidx.appsearch.app.EmbeddingVector.QuantizedData) Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

*** ** * ** ***


```
@ExperimentalAppSearchApi
public final class EmbeddingVector.QuantizedData
```

<br />

*** ** * ** ***

Holds the pre-quantized embedding values along with the quantization parameters.

The original float values can be reconstructed from the quantized byte values using the formula: `originalValue = (quantizedValue / scale) + minValue`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData#QuantizedData(float,float,byte[])( float minValue, float scale, @https://developer.android.com/reference/androidx/annotation/NonNull byte[] quantizedValues )` Creates a new `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData`. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html o)` |
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData` | `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData#fromUnquantizedValues(float[])(@https://developer.android.com/reference/androidx/annotation/NonNull float[] values)` Creates a new `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData` by quantizing the provided float values to 8-bit integers. |
| `float` | `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData#getMinValue()()` Returns the minimum float value across all dimensions before quantization. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull byte[]` | `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData#getQuantizedValues()()` Returns the pre-quantized int8 vector data. |
| `float` | `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData#getScale()()` Returns the scaling factor used to quantize the vector. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData#hashCode()()` |

## Public constructors

### QuantizedData

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
public QuantizedData(
    float minValue,
    float scale,
    @NonNull byte[] quantizedValues
)
```

Creates a new `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData`.

The original float values can be reconstructed from the quantized byte values using the formula: `originalValue = (quantizedValue / scale) + minValue`.

| Parameters |
|---|---|
| `float minValue` | The minimum float value across all dimensions before quantization. |
| `float scale` | The scaling factor used to quantize the vector. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull byte[] quantizedValues` | The pre-quantized int8 vector data. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `quantizedValues` is empty. |

## Public methods

### equals

```
public boolean equals(@Nullable Object o)
```

### fromUnquantizedValues

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
public static @NonNull EmbeddingVector.QuantizedData fromUnquantizedValues(@NonNull float[] values)
```

Creates a new `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData` by quantizing the provided float values to 8-bit integers.

Storing 8-bit quantized values directly helps reduce memory and disk space usage by approximately 75% compared to storing full 32-bit floats.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] values` | The float values to quantize. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData` | The `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector.QuantizedData` created by quantizing the float values. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if `values` is empty. |

### getMinValue

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
public float getMinValue()
```

Returns the minimum float value across all dimensions before quantization.

### getQuantizedValues

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
public @NonNull byte[] getQuantizedValues()
```

Returns the pre-quantized int8 vector data.

### getScale

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
public float getScale()
```

Returns the scaling factor used to quantize the vector.

### hashCode

```
public int hashCode()
```