Skip to content

Commit ead6684

Browse files
committed
hide manhattanDistance()
1 parent 8e8557f commit ead6684

File tree

2 files changed

+46
-52
lines changed

2 files changed

+46
-52
lines changed

Firestore/Swift/Source/ExpressionImplementation.swift

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,52 @@ extension Expression {
225225
func bitRightShift(_ numberExpression: Expression) -> FunctionExpression {
226226
return FunctionExpression("bit_right_shift", [self, numberExpression])
227227
}
228+
229+
/// Calculates the Manhattan (L1) distance between this vector expression and another vector
230+
/// expression.
231+
/// Assumes both `self` and `other` evaluate to Vectors.
232+
///
233+
/// - Note: This API is in beta.
234+
///
235+
/// ```swift
236+
/// // Manhattan distance between "vector1" field and "vector2" field
237+
/// Field("vector1").manhattanDistance(Field("vector2"))
238+
/// ```
239+
///
240+
/// - Parameter expression: The other vector as an `Expr` to compare against.
241+
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
242+
func manhattanDistance(_ expression: Expression) -> FunctionExpression {
243+
return FunctionExpression("manhattan_distance", [self, expression])
244+
}
245+
246+
/// Calculates the Manhattan (L1) distance between this vector expression and another vector
247+
/// literal (`VectorValue`).
248+
/// Assumes `self` evaluates to a Vector.
249+
/// - Note: This API is in beta.
250+
/// ```swift
251+
/// let referencePoint = VectorValue(vector: [5.0, 10.0])
252+
/// Field("dataPoint").manhattanDistance(referencePoint)
253+
/// ```
254+
/// - Parameter vector: The other vector as a `VectorValue` to compare against.
255+
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
256+
func manhattanDistance(_ vector: VectorValue) -> FunctionExpression {
257+
return FunctionExpression("manhattan_distance", [self, Helper.sendableToExpr(vector)])
258+
}
259+
260+
/// Calculates the Manhattan (L1) distance between this vector expression and another vector
261+
/// literal (`[Double]`).
262+
/// Assumes `self` evaluates to a Vector.
263+
/// - Note: This API is in beta.
264+
///
265+
/// ```swift
266+
/// // Manhattan distance between "point" field and a target point
267+
/// Field("point").manhattanDistance([10.0, 20.0])
268+
/// ```
269+
/// - Parameter vector: The other vector as `[Double]` to compare against.
270+
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
271+
func manhattanDistance(_ vector: [Double]) -> FunctionExpression {
272+
return FunctionExpression("manhattan_distance", [self, Helper.sendableToExpr(vector)])
273+
}
228274
}
229275

230276
public extension Expression {
@@ -690,18 +736,6 @@ public extension Expression {
690736
return FunctionExpression("euclidean_distance", [self, Helper.sendableToExpr(vector)])
691737
}
692738

693-
func manhattanDistance(_ expression: Expression) -> FunctionExpression {
694-
return FunctionExpression("manhattan_distance", [self, expression])
695-
}
696-
697-
func manhattanDistance(_ vector: VectorValue) -> FunctionExpression {
698-
return FunctionExpression("manhattan_distance", [self, Helper.sendableToExpr(vector)])
699-
}
700-
701-
func manhattanDistance(_ vector: [Double]) -> FunctionExpression {
702-
return FunctionExpression("manhattan_distance", [self, Helper.sendableToExpr(vector)])
703-
}
704-
705739
// MARK: Timestamp operations
706740

707741
func unixMicrosToTimestamp() -> FunctionExpression {

Firestore/Swift/Source/SwiftAPI/Pipeline/Expressions/Expression.swift

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,46 +1328,6 @@ public protocol Expression: Sendable {
13281328
/// - Returns: A new `FunctionExpression` representing the Euclidean distance.
13291329
func euclideanDistance(_ vector: [Double]) -> FunctionExpression
13301330

1331-
/// Calculates the Manhattan (L1) distance between this vector expression and another vector
1332-
/// expression.
1333-
/// Assumes both `self` and `other` evaluate to Vectors.
1334-
///
1335-
/// - Note: This API is in beta.
1336-
///
1337-
/// ```swift
1338-
/// // Manhattan distance between "vector1" field and "vector2" field
1339-
/// Field("vector1").manhattanDistance(Field("vector2"))
1340-
/// ```
1341-
///
1342-
/// - Parameter expression: The other vector as an `Expr` to compare against.
1343-
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
1344-
func manhattanDistance(_ expression: Expression) -> FunctionExpression
1345-
1346-
/// Calculates the Manhattan (L1) distance between this vector expression and another vector
1347-
/// literal (`VectorValue`).
1348-
/// Assumes `self` evaluates to a Vector.
1349-
/// - Note: This API is in beta.
1350-
/// ```swift
1351-
/// let referencePoint = VectorValue(vector: [5.0, 10.0])
1352-
/// Field("dataPoint").manhattanDistance(referencePoint)
1353-
/// ```
1354-
/// - Parameter vector: The other vector as a `VectorValue` to compare against.
1355-
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
1356-
func manhattanDistance(_ vector: VectorValue) -> FunctionExpression
1357-
1358-
/// Calculates the Manhattan (L1) distance between this vector expression and another vector
1359-
/// literal (`[Double]`).
1360-
/// Assumes `self` evaluates to a Vector.
1361-
/// - Note: This API is in beta.
1362-
///
1363-
/// ```swift
1364-
/// // Manhattan distance between "point" field and a target point
1365-
/// Field("point").manhattanDistance([10.0, 20.0])
1366-
/// ```
1367-
/// - Parameter vector: The other vector as `[Double]` to compare against.
1368-
/// - Returns: A new `FunctionExpression` representing the Manhattan distance.
1369-
func manhattanDistance(_ vector: [Double]) -> FunctionExpression
1370-
13711331
// MARK: Timestamp operations
13721332

13731333
/// Creates an expression that interprets this expression (evaluating to a number) as microseconds

0 commit comments

Comments
 (0)