Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ppl API #14513

Open
wants to merge 5 commits into
base: cheryllin/ppl
Choose a base branch
from
Open

Ppl API #14513

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add stage API
  • Loading branch information
cherylEnkidu committed Feb 27, 2025
commit 84691ab976073ac08b8b7172dbbc82b7158c2318
15 changes: 15 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/AccumulatorExpr.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public protocol AccumulatorExpr: Sendable {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct AccumulatorWithAlias {
init(_ expr: some AccumulatorExpr, _ alias: String) {}
}
15 changes: 15 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Add.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct Add {}
23 changes: 23 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/AggregateOption.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct AggregateOption {
public let accumulators: [AccumulatorWithAlias]
public let groups: [SelectableOrFieldName]?

public init(accumulators: [AccumulatorWithAlias], groups: [SelectableOrFieldName]? = nil) {
self.accumulators = accumulators
self.groups = groups
}
}
15 changes: 15 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/BooleanExpr.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct BooleanExpr: FunctionExpr, Sendable {}
15 changes: 15 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Constant.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct Constant: Expr, Sendable {}
13 changes: 13 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Count.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2025 Google LLC
//
// Licensed 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.
15 changes: 15 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Eq.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct Eq {}
35 changes: 35 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Expr.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public protocol Expr: Sendable, Equatable {
func alias(_ alias: String) -> ExprWithAlias

func eq(_ expr: BooleanExpr)

func add(_ expr: some FunctionExpr)

func add(_ expr: Constant)
}

public extension Expr {
func alias(_ alias: String) -> ExprWithAlias {
return ExprWithAlias(self, alias)
}

func eq(_ expr: some Expr) {}

func add(_ expr: some Expr) {}

func add(_ expr: Constant) {}
}
17 changes: 17 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/ExprWithAlias.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct ExprWithAlias {
init(_ expr: some Expr, _ alias: String) {}
}
18 changes: 18 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Field.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct Field: Expr, Sendable {
public var alias: String
public let fieldName: String
}
63 changes: 63 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/FindNearestOptions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

#if SWIFT_PACKAGE
@_exported import FirebaseFirestoreInternalWrapper
#else
@_exported import FirebaseFirestoreInternal
#endif // SWIFT_PACKAGE

import Foundation

public struct FindNearestOptions {
let field: Field
let vectorValue: [VectorValue]
let distanceMeasure: DistanceMeasure
let limit: Int?
let distanceField: String?
}

public struct DistanceMeasure: Sendable, Equatable, Hashable {
enum Kind: String {
case euclidean
case cosine
case dotProduct = "dot_product"
}

public static var euclidean: DistanceMeasure {
return self.init(kind: .euclidean)
}

public static var cosine: DistanceMeasure {
return self.init(kind: .cosine)
}

public static var dotProduct: DistanceMeasure {
return self.init(kind: .dotProduct)
}

/// Returns the raw string representation of the `DistanceMeasure` value.
public let rawValue: String

init(kind: Kind) {
rawValue = kind.rawValue
}

public init(rawValue: String) {
if Kind(rawValue: rawValue) == nil {
// impl
}
self.rawValue = rawValue
}
}
15 changes: 15 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/FunctionExpr.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public protocol FunctionExpr: Expr, Sendable {}
15 changes: 15 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/LogicalMin.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2025 Google LLC
//
// Licensed 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.

public struct LogicalMin: FunctionExpr, Sendable, Equatable {}
13 changes: 13 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Min.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2025 Google LLC
//
// Licensed 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.
47 changes: 47 additions & 0 deletions Firestore/Swift/Source/SwiftAPI/Pipeline/Ordering.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2024 Google LLC
*
* Licensed 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.
*/

public struct Ordering {
let direction: Direction
}

public struct Direction: Sendable, Equatable, Hashable {
enum Kind: String {
case ascending
case descending
}

public static var ascending: Direction {
return self.init(kind: .ascending)
}

public static var descending: Direction {
return self.init(kind: .descending)
}

public let rawValue: String

init(kind: Kind) {
rawValue = kind.rawValue
}

public init(rawValue: String) {
if Kind(rawValue: rawValue) == nil {
// impl
}
self.rawValue = rawValue
}
}
Loading
Loading