# 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
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/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData#QuantizedData(float,float,byte[])( minValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, scale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, quantizedValues: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html> )` Creates a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `java-static https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData#fromUnquantizedValues(float[])(values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>)` Creates a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData` by quantizing the provided float values to 8-bit integers. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData#getMinValue()()` Returns the minimum float value across all dimensions before quantization. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData#getQuantizedValues()()` Returns the pre-quantized int8 vector data. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData#getScale()()` Returns the scaling factor used to quantize the vector. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/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)

```
QuantizedData(
    minValue: Float,
    scale: Float,
    quantizedValues: ByteArray<Byte>
)
```

Creates a new `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `minValue: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The minimum float value across all dimensions before quantization. |
| `scale: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The scaling factor used to quantize the vector. |
| `quantizedValues: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>` | The pre-quantized int8 vector data. |

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

## Public functions

### equals

```
fun equals(o: Any?): Boolean
```

### fromUnquantizedValues

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

```
java-static fun fromUnquantizedValues(values: FloatArray<Float>): EmbeddingVector.QuantizedData
```

Creates a new `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>` | The float values to quantize. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector.QuantizedData` | The `https://developer.android.com/reference/kotlin/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)

```
fun getMinValue(): Float
```

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)

```
fun getQuantizedValues(): Array<Byte>
```

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)

```
fun getScale(): Float
```

Returns the scaling factor used to quantize the vector.

### hashCode

```
fun hashCode(): Int
```