Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 0 additions & 21 deletions firebase-firestore/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ package com.google.firebase.firestore {
method public com.google.firebase.firestore.LoadBundleTask loadBundle(java.io.InputStream);
method public com.google.firebase.firestore.LoadBundleTask loadBundle(java.nio.ByteBuffer);
method public com.google.firebase.firestore.PipelineSource pipeline();
method public com.google.firebase.firestore.RealtimePipelineSource realtimePipeline();
method public com.google.android.gms.tasks.Task<java.lang.Void!> runBatch(com.google.firebase.firestore.WriteBatch.Function);
method public <TResult> com.google.android.gms.tasks.Task<TResult!> runTransaction(com.google.firebase.firestore.Transaction.Function<TResult!>);
method public <TResult> com.google.android.gms.tasks.Task<TResult!> runTransaction(com.google.firebase.firestore.TransactionOptions, com.google.firebase.firestore.Transaction.Function<TResult!>);
Expand Down Expand Up @@ -613,19 +612,6 @@ package com.google.firebase.firestore {
method public <T> java.util.List<T!> toObjects(Class<T!>, com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior);
}

public final class RealtimePipeline {
method public com.google.firebase.firestore.ListenerRegistration addSnapshotListener(com.google.firebase.firestore.EventListener<com.google.firebase.firestore.RealtimePipelineSnapshot> listener);
method public com.google.firebase.firestore.ListenerRegistration addSnapshotListener(com.google.firebase.firestore.RealtimePipelineOptions options, com.google.firebase.firestore.EventListener<com.google.firebase.firestore.RealtimePipelineSnapshot> listener);
method public com.google.firebase.firestore.ListenerRegistration addSnapshotListener(java.util.concurrent.Executor executor, com.google.firebase.firestore.EventListener<com.google.firebase.firestore.RealtimePipelineSnapshot> listener);
method public com.google.firebase.firestore.ListenerRegistration addSnapshotListener(java.util.concurrent.Executor executor, com.google.firebase.firestore.RealtimePipelineOptions options, com.google.firebase.firestore.EventListener<com.google.firebase.firestore.RealtimePipelineSnapshot> listener);
method public String canonicalId();
method public com.google.firebase.firestore.RealtimePipeline limit(int limit);
method public kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.RealtimePipelineSnapshot> snapshots();
method public kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.RealtimePipelineSnapshot> snapshots(com.google.firebase.firestore.RealtimePipelineOptions options);
method public com.google.firebase.firestore.RealtimePipeline sort(com.google.firebase.firestore.pipeline.Ordering order, com.google.firebase.firestore.pipeline.Ordering... additionalOrders);
method public com.google.firebase.firestore.RealtimePipeline where(com.google.firebase.firestore.pipeline.BooleanExpression condition);
}

public final class RealtimePipelineOptions {
ctor public RealtimePipelineOptions();
method public com.google.firebase.firestore.RealtimePipelineOptions withMetadataChanges(com.google.firebase.firestore.MetadataChanges metadataChanges);
Expand All @@ -646,13 +632,6 @@ package com.google.firebase.firestore {
property public final java.util.List<com.google.firebase.firestore.PipelineResult> results;
}

public final class RealtimePipelineSource {
method public com.google.firebase.firestore.RealtimePipeline collection(com.google.firebase.firestore.CollectionReference ref);
method public com.google.firebase.firestore.RealtimePipeline collection(String path);
method public com.google.firebase.firestore.RealtimePipeline collectionGroup(String collectionId);
method public com.google.firebase.firestore.RealtimePipeline convertFrom(com.google.firebase.firestore.Query query);
}

@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME) @java.lang.annotation.Target({java.lang.annotation.ElementType.METHOD, java.lang.annotation.ElementType.FIELD}) public @interface ServerTimestamp {
}

Expand Down
2 changes: 1 addition & 1 deletion firebase-firestore/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=25.1.5
version=99.0.0-pipeline.preview.1
latestReleasedVersion=25.1.4
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public enum TargetBackend {

// Set this to the desired enum value to change the target backend when running tests locally.
// Note: DO NOT change this variable except for local testing.
private static final TargetBackend backendForLocalTesting = TargetBackend.EMULATOR;
private static final TargetBackend backendForLocalTesting = TargetBackend.PROD;

private static final TargetBackend backend = getTargetBackend();
private static final String EMULATOR_HOST = "10.0.2.2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ public PipelineSource pipeline() {
* @return {@code RealtimePipelineSource} for this Firestore instance.
*/
@NonNull
public RealtimePipelineSource realtimePipeline() {
RealtimePipelineSource realtimePipeline() {
clientProvider.ensureConfigured();
return new RealtimePipelineSource(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow

class RealtimePipelineSource internal constructor(private val firestore: FirebaseFirestore) {
internal class RealtimePipelineSource
internal constructor(private val firestore: FirebaseFirestore) {
/**
* Convert the given Query into an equivalent Pipeline.
*
Expand Down Expand Up @@ -127,7 +128,7 @@ class RealtimePipelineSource internal constructor(private val firestore: Firebas
)
}

class RealtimePipeline
internal class RealtimePipeline
internal constructor(
// This is nullable because RealtimePipeline is also created from deserialization from persistent
// cache. In that case, it is only used to facilitate remote store requests, and this field is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import com.google.firebase.firestore.util.Assert.hardAssert

/** A class that wraps either a Query or a RealtimePipeline. */
sealed class QueryOrPipeline {
data class QueryWrapper(val query: Query) : QueryOrPipeline()
data class PipelineWrapper(val pipeline: RealtimePipeline) : QueryOrPipeline()
internal data class QueryWrapper(internal val query: Query) : QueryOrPipeline()
internal data class PipelineWrapper(internal val pipeline: RealtimePipeline) : QueryOrPipeline()

val isQuery: Boolean
get() = this is QueryWrapper
Expand All @@ -45,7 +45,7 @@ sealed class QueryOrPipeline {
return (this as QueryWrapper).query
}

fun pipeline(): RealtimePipeline {
internal fun pipeline(): RealtimePipeline {
return (this as PipelineWrapper).pipeline
}

Expand Down Expand Up @@ -102,7 +102,7 @@ sealed class QueryOrPipeline {
/** A class that wraps either a Target or a RealtimePipeline. */
sealed class TargetOrPipeline {
data class TargetWrapper(val target: Target) : TargetOrPipeline()
data class PipelineWrapper(val pipeline: RealtimePipeline) : TargetOrPipeline()
internal data class PipelineWrapper(val pipeline: RealtimePipeline) : TargetOrPipeline()

val isTarget: Boolean
get() = this is TargetWrapper
Expand All @@ -114,7 +114,7 @@ sealed class TargetOrPipeline {
return (this as TargetWrapper).target
}

fun pipeline(): RealtimePipeline {
internal fun pipeline(): RealtimePipeline {
return (this as PipelineWrapper).pipeline
}

Expand Down Expand Up @@ -178,15 +178,15 @@ enum class PipelineSourceType {
}

// Determines the flavor of the given pipeline based on its stages.
fun getPipelineFlavor(pipeline: RealtimePipeline): PipelineFlavor {
internal fun getPipelineFlavor(pipeline: RealtimePipeline): PipelineFlavor {
// For now, it is only possible to construct RealtimePipeline that is kExact.
// PORTING NOTE: the typescript implementation support other flavors already,
// despite not being used. We can port that later.
return PipelineFlavor.EXACT
}

// Determines the source type of the given pipeline based on its first stage.
fun getPipelineSourceType(pipeline: RealtimePipeline): PipelineSourceType {
internal fun getPipelineSourceType(pipeline: RealtimePipeline): PipelineSourceType {
hardAssert(
!pipeline.stages.isEmpty(),
"Pipeline must have at least one stage to determine its source.",
Expand All @@ -202,7 +202,7 @@ fun getPipelineSourceType(pipeline: RealtimePipeline): PipelineSourceType {

// Retrieves the collection group ID if the pipeline's source is a collection
// group.
fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
internal fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
if (getPipelineSourceType(pipeline) == PipelineSourceType.COLLECTION_GROUP) {
hardAssert(
!pipeline.stages.isEmpty(),
Expand All @@ -217,7 +217,7 @@ fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
}

// Retrieves the collection path if the pipeline's source is a collection.
fun getPipelineCollection(pipeline: RealtimePipeline): String? {
internal fun getPipelineCollection(pipeline: RealtimePipeline): String? {
if (getPipelineSourceType(pipeline) == PipelineSourceType.COLLECTION) {
hardAssert(
!pipeline.stages.isEmpty(),
Expand All @@ -232,7 +232,7 @@ fun getPipelineCollection(pipeline: RealtimePipeline): String? {
}

// Retrieves the document pathes if the pipeline's source is a document source.
fun getPipelineDocuments(pipeline: RealtimePipeline): Array<out String>? {
internal fun getPipelineDocuments(pipeline: RealtimePipeline): Array<out String>? {
if (getPipelineSourceType(pipeline) == PipelineSourceType.DOCUMENTS) {
hardAssert(
!pipeline.stages.isEmpty(),
Expand All @@ -248,7 +248,7 @@ fun getPipelineDocuments(pipeline: RealtimePipeline): Array<out String>? {

// Creates a new pipeline by replacing CollectionGroupSource stages with
// CollectionSource stages using the provided path.
fun asCollectionPipelineAtPath(
internal fun asCollectionPipelineAtPath(
pipeline: RealtimePipeline,
path: ResourcePath,
): RealtimePipeline {
Expand All @@ -271,7 +271,7 @@ fun asCollectionPipelineAtPath(
)
}

fun getLastEffectiveLimit(pipeline: RealtimePipeline): Int? {
internal fun getLastEffectiveLimit(pipeline: RealtimePipeline): Int? {
for (stagePtr in pipeline.rewrittenStages.asReversed()) {
// Check if the stage is a LimitStage
if (stagePtr is LimitStage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public QueryListener(
if (query.isPipeline()) {
this.query =
new QueryOrPipeline.PipelineWrapper(
query.pipeline().withListenOptions$com_google_firebase_firebase_firestore(options));
query
.pipeline$com_google_firebase_firebase_firestore()
.withListenOptions$com_google_firebase_firebase_firestore(options));
} else {
this.query = query;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ public DocumentChanges computeDocChanges(
candidates.add((MutableDocument) doc);
}
List<MutableDocument> results =
this.query.pipeline().evaluate$com_google_firebase_firebase_firestore(candidates);
this.query
.pipeline$com_google_firebase_firebase_firestore()
.evaluate$com_google_firebase_firebase_firestore(candidates);
DocumentSet newResults = DocumentSet.emptySet(query.comparator());
for (MutableDocument doc : results) {
newResults = newResults.add(doc);
Expand Down Expand Up @@ -501,7 +503,8 @@ private static int changeTypeOrder(DocumentViewChange change) {
@Nullable
private static Long getLimit(QueryOrPipeline query) {
if (query.isPipeline()) {
Integer limit = getLastEffectiveLimit(query.pipeline());
Integer limit =
getLastEffectiveLimit(query.pipeline$com_google_firebase_firebase_firestore());
if (limit == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingCollection

private ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingPipeline(
QueryOrPipeline queryOrPipeline, IndexOffset offset, @Nullable QueryContext context) {
RealtimePipeline pipeline = queryOrPipeline.pipeline();
RealtimePipeline pipeline = queryOrPipeline.pipeline$com_google_firebase_firebase_firestore();
if (getPipelineSourceType(pipeline) == PipelineSourceType.COLLECTION_GROUP) {
String collectionGroup = getPipelineCollectionGroup(pipeline);
hardAssert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ com.google.firebase.firestore.proto.Target encodeTargetData(TargetData targetDat
com.google.firestore.v1.Target.PipelineQueryTarget.newBuilder()
.setStructuredPipeline(
target
.pipeline()
.pipeline$com_google_firebase_firebase_firestore()
.toStructurePipelineProto$com_google_firebase_firebase_firestore()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ public Map<DocumentKey, MutableDocument> getDocumentsMatchingQuery(
if (query.isQuery()) {
path = query.query().getPath();
} else {
path = ResourcePath.fromString(getPipelineCollection(query.pipeline()));
path =
ResourcePath.fromString(
getPipelineCollection(query.pipeline$com_google_firebase_firebase_firestore()));
}
DocumentKey prefix = DocumentKey.fromPath(path.append(""));
Iterator<Map.Entry<DocumentKey, Document>> iterator = docs.iteratorFrom(prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ public Map<DocumentKey, MutableDocument> getDocumentsMatchingQuery(
if (query.isQuery()) {
path = query.query().getPath();
} else {
String pathString = getPipelineCollection(query.pipeline());
String pathString =
getPipelineCollection(query.pipeline$com_google_firebase_firebase_firestore());
hardAssert(
pathString != null,
"SQLiteRemoteDocumentCache.getDocumentsMatchingQuery receives pipeline without collection source.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,9 @@ public com.google.firestore.v1.Target encodeTarget(TargetData targetData) {
PipelineQueryTarget.Builder pipelineBuilder = PipelineQueryTarget.newBuilder();
builder.setPipelineQuery(
pipelineBuilder.setStructuredPipeline(
target.pipeline().toStructurePipelineProto$com_google_firebase_firebase_firestore()));
target
.pipeline$com_google_firebase_firebase_firestore()
.toStructurePipelineProto$com_google_firebase_firebase_firestore()));
} else if (target.target().isDocumentQuery()) {
builder.setDocuments(encodeDocumentsTarget(target.target()));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.google.firebase.Timestamp;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.RealtimePipeline;
import com.google.firebase.firestore.RealtimePipelineSource;
import com.google.firebase.firestore.bundle.BundledQuery;
import com.google.firebase.firestore.core.Query;
import com.google.firebase.firestore.core.Target;
Expand Down Expand Up @@ -494,7 +495,7 @@ public void testEncodesLimitToLastQuery() {
public void encodesTargetDataWithPipeline() {
FirebaseFirestore db = com.google.firebase.firestore.TestUtil.firestore();
RealtimePipeline pipeline =
db.realtimePipeline()
new RealtimePipelineSource(db)
.collection("rooms")
.where(Expression.field("name").equal("test room"))
.sort(Expression.field("age").descending())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,11 @@ public void rewritesCanonicalIds() {
String expectedCanonicalId =
targetData.getTarget().isTarget()
? targetData.getTarget().target().getCanonicalId()
: targetData.getTarget().pipeline().toString();
: targetData
.getTarget()
.pipeline$com_google_firebase_firebase_firestore()
.canonicalId$com_google_firebase_firebase_firestore()
.toString();
assertEquals(expectedCanonicalId, actualCanonicalId);
} catch (InvalidProtocolBufferException e) {
fail("Failed to decode Target data");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ private void assertEventMatches(JSONObject expected, QueryEvent actual) throws J
if (usePipelineMode) {
assertEquals(
expectedQuery.toRealtimePipeline(db, new UserDataReader(databaseInfo.getDatabaseId())),
actual.queryOrPipeline.pipeline());
actual.queryOrPipeline.pipeline$com_google_firebase_firebase_firestore());
} else {
assertEquals(expectedQuery, actual.queryOrPipeline.query());
}
Expand Down
Loading