Skip to content

Commit 7ccf3da

Browse files
committed
Add missing features for public preview
1 parent fd8c75d commit 7ccf3da

File tree

11 files changed

+1831
-69
lines changed

11 files changed

+1831
-69
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/model/Values.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,19 @@ object Values {
761761
return Timestamp.newBuilder().setSeconds(seconds).setNanos(truncatedNanoseconds).build()
762762
}
763763

764+
@JvmStatic
765+
fun getVectorValue(value: Value): DoubleArray? {
766+
if (value.valueTypeCase != ValueTypeCase.MAP_VALUE || !isVectorValue(value)) {
767+
return null
768+
}
769+
770+
return value.mapValue.fieldsMap[VECTOR_MAP_VECTORS_KEY]
771+
?.arrayValue
772+
?.valuesList
773+
?.map { it.doubleValue }
774+
?.toDoubleArray()
775+
}
776+
764777
/**
765778
* Ensures that the date and time are within what we consider valid ranges.
766779
*

firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/EvaluateResult.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import com.google.firebase.firestore.model.Values.encodeValue
1919
import com.google.firestore.v1.Value
2020
import com.google.protobuf.Timestamp
2121

22-
internal sealed class EvaluateResult(val value: Value?) {
22+
internal sealed class EvaluateResult {
23+
abstract val value: Value?
2324
abstract val isError: Boolean
2425
abstract val isSuccess: Boolean
2526
abstract val isUnset: Boolean
@@ -49,19 +50,21 @@ internal sealed class EvaluateResult(val value: Value?) {
4950
}
5051
}
5152

52-
internal class EvaluateResultValue(value: Value) : EvaluateResult(value) {
53+
internal data class EvaluateResultValue(override val value: Value) : EvaluateResult() {
5354
override val isSuccess: Boolean = true
5455
override val isError: Boolean = false
5556
override val isUnset: Boolean = false
5657
}
5758

58-
internal object EvaluateResultError : EvaluateResult(null) {
59+
internal object EvaluateResultError : EvaluateResult() {
60+
override val value: Value? = null
5961
override val isSuccess: Boolean = false
6062
override val isError: Boolean = true
6163
override val isUnset: Boolean = false
6264
}
6365

64-
internal object EvaluateResultUnset : EvaluateResult(null) {
66+
internal object EvaluateResultUnset : EvaluateResult() {
67+
override val value: Value? = null
6568
override val isSuccess: Boolean = false
6669
override val isError: Boolean = false
6770
override val isUnset: Boolean = true

firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/FunctionRegistry.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ internal object FunctionRegistry {
7777
"array_contains" to evaluateArrayContains,
7878
"array_contains_any" to evaluateArrayContainsAny,
7979
"array_contains_all" to evaluateArrayContainsAll,
80+
"array_get" to evaluateArrayGet,
8081
"array_length" to evaluateArrayLength,
8182
"timestamp_add" to evaluateTimestampAdd,
8283
"timestamp_sub" to evaluateTimestampSub,
@@ -104,7 +105,6 @@ internal object FunctionRegistry {
104105
"split" to evaluateSplit,
105106
"substring" to evaluateSubstring,
106107
"ltrim" to evaluateLTrim,
107-
"rtrim" to evaluateRTrim,
108-
"str_join" to evaluateStrJoin
108+
"rtrim" to evaluateRTrim
109109
)
110110
}

0 commit comments

Comments
 (0)