Skip to content

Commit 09ad56f

Browse files
committed
Hide realtime pipeline
1 parent 621f912 commit 09ad56f

File tree

14 files changed

+41
-47
lines changed

14 files changed

+41
-47
lines changed

firebase-firestore/api.txt

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ package com.google.firebase.firestore {
207207
method public com.google.firebase.firestore.LoadBundleTask loadBundle(java.io.InputStream);
208208
method public com.google.firebase.firestore.LoadBundleTask loadBundle(java.nio.ByteBuffer);
209209
method public com.google.firebase.firestore.PipelineSource pipeline();
210-
method public com.google.firebase.firestore.RealtimePipelineSource realtimePipeline();
211210
method public com.google.android.gms.tasks.Task<java.lang.Void!> runBatch(com.google.firebase.firestore.WriteBatch.Function);
212211
method public <TResult> com.google.android.gms.tasks.Task<TResult!> runTransaction(com.google.firebase.firestore.Transaction.Function<TResult!>);
213212
method public <TResult> com.google.android.gms.tasks.Task<TResult!> runTransaction(com.google.firebase.firestore.TransactionOptions, com.google.firebase.firestore.Transaction.Function<TResult!>);
@@ -600,19 +599,6 @@ package com.google.firebase.firestore {
600599
method public <T> java.util.List<T!> toObjects(Class<T!>, com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior);
601600
}
602601

603-
public final class RealtimePipeline {
604-
method public com.google.firebase.firestore.ListenerRegistration addSnapshotListener(com.google.firebase.firestore.EventListener<com.google.firebase.firestore.RealtimePipelineSnapshot> listener);
605-
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);
606-
method public com.google.firebase.firestore.ListenerRegistration addSnapshotListener(java.util.concurrent.Executor executor, com.google.firebase.firestore.EventListener<com.google.firebase.firestore.RealtimePipelineSnapshot> listener);
607-
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);
608-
method public String canonicalId();
609-
method public com.google.firebase.firestore.RealtimePipeline limit(int limit);
610-
method public kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.RealtimePipelineSnapshot> snapshots();
611-
method public kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.RealtimePipelineSnapshot> snapshots(com.google.firebase.firestore.RealtimePipelineOptions options);
612-
method public com.google.firebase.firestore.RealtimePipeline sort(com.google.firebase.firestore.pipeline.Ordering order, com.google.firebase.firestore.pipeline.Ordering... additionalOrders);
613-
method public com.google.firebase.firestore.RealtimePipeline where(com.google.firebase.firestore.pipeline.BooleanExpr condition);
614-
}
615-
616602
public final class RealtimePipelineOptions {
617603
ctor public RealtimePipelineOptions();
618604
method public com.google.firebase.firestore.RealtimePipelineOptions withMetadataChanges(com.google.firebase.firestore.MetadataChanges metadataChanges);
@@ -633,13 +619,6 @@ package com.google.firebase.firestore {
633619
property public final java.util.List<com.google.firebase.firestore.PipelineResult> results;
634620
}
635621

636-
public final class RealtimePipelineSource {
637-
method public com.google.firebase.firestore.RealtimePipeline collection(com.google.firebase.firestore.CollectionReference ref);
638-
method public com.google.firebase.firestore.RealtimePipeline collection(String path);
639-
method public com.google.firebase.firestore.RealtimePipeline collectionGroup(String collectionId);
640-
method public com.google.firebase.firestore.RealtimePipeline convertFrom(com.google.firebase.firestore.Query query);
641-
}
642-
643622
@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 {
644623
}
645624

firebase-firestore/src/main/java/com/google/firebase/firestore/FirebaseFirestore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ public PipelineSource pipeline() {
911911
* @return {@code RealtimePipelineSource} for this Firestore instance.
912912
*/
913913
@NonNull
914-
public RealtimePipelineSource realtimePipeline() {
914+
RealtimePipelineSource realtimePipeline() {
915915
clientProvider.ensureConfigured();
916916
return new RealtimePipelineSource(this);
917917
}

firebase-firestore/src/main/java/com/google/firebase/firestore/RealtimePipeline.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ import kotlinx.coroutines.channels.awaitClose
4949
import kotlinx.coroutines.flow.Flow
5050
import kotlinx.coroutines.flow.callbackFlow
5151

52-
class RealtimePipelineSource internal constructor(private val firestore: FirebaseFirestore) {
52+
internal class RealtimePipelineSource
53+
internal constructor(private val firestore: FirebaseFirestore) {
5354
/**
5455
* Convert the given Query into an equivalent Pipeline.
5556
*
@@ -128,7 +129,7 @@ class RealtimePipelineSource internal constructor(private val firestore: Firebas
128129
)
129130
}
130131

131-
class RealtimePipeline
132+
internal class RealtimePipeline
132133
internal constructor(
133134
// This is nullable because RealtimePipeline is also created from deserialization from persistent
134135
// cache. In that case, it is only used to facilitate remote store requests, and this field is

firebase-firestore/src/main/java/com/google/firebase/firestore/core/PipelineUtil.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import com.google.firebase.firestore.util.Assert.hardAssert
2929

3030
/** A class that wraps either a Query or a RealtimePipeline. */
3131
sealed class QueryOrPipeline {
32-
data class QueryWrapper(val query: Query) : QueryOrPipeline()
33-
data class PipelineWrapper(val pipeline: RealtimePipeline) : QueryOrPipeline()
32+
internal data class QueryWrapper(internal val query: Query) : QueryOrPipeline()
33+
internal data class PipelineWrapper(internal val pipeline: RealtimePipeline) : QueryOrPipeline()
3434

3535
val isQuery: Boolean
3636
get() = this is QueryWrapper
@@ -42,7 +42,7 @@ sealed class QueryOrPipeline {
4242
return (this as QueryWrapper).query
4343
}
4444

45-
fun pipeline(): RealtimePipeline {
45+
internal fun pipeline(): RealtimePipeline {
4646
return (this as PipelineWrapper).pipeline
4747
}
4848

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

104104
val isTarget: Boolean
105105
get() = this is TargetWrapper
@@ -111,7 +111,7 @@ sealed class TargetOrPipeline {
111111
return (this as TargetWrapper).target
112112
}
113113

114-
fun pipeline(): RealtimePipeline {
114+
internal fun pipeline(): RealtimePipeline {
115115
return (this as PipelineWrapper).pipeline
116116
}
117117

@@ -175,15 +175,15 @@ enum class PipelineSourceType {
175175
}
176176

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

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

200200
// Retrieves the collection group ID if the pipeline's source is a collection
201201
// group.
202-
fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
202+
internal fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
203203
if (getPipelineSourceType(pipeline) == PipelineSourceType.COLLECTION_GROUP) {
204204
hardAssert(
205205
!pipeline.stages.isEmpty(),
@@ -214,7 +214,7 @@ fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
214214
}
215215

216216
// Retrieves the collection path if the pipeline's source is a collection.
217-
fun getPipelineCollection(pipeline: RealtimePipeline): String? {
217+
internal fun getPipelineCollection(pipeline: RealtimePipeline): String? {
218218
if (getPipelineSourceType(pipeline) == PipelineSourceType.COLLECTION) {
219219
hardAssert(
220220
!pipeline.stages.isEmpty(),
@@ -229,7 +229,7 @@ fun getPipelineCollection(pipeline: RealtimePipeline): String? {
229229
}
230230

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

246246
// Creates a new pipeline by replacing CollectionGroupSource stages with
247247
// CollectionSource stages using the provided path.
248-
fun asCollectionPipelineAtPath(
248+
internal fun asCollectionPipelineAtPath(
249249
pipeline: RealtimePipeline,
250250
path: ResourcePath,
251251
): RealtimePipeline {
@@ -268,7 +268,7 @@ fun asCollectionPipelineAtPath(
268268
)
269269
}
270270

271-
fun getLastEffectiveLimit(pipeline: RealtimePipeline): Int? {
271+
internal fun getLastEffectiveLimit(pipeline: RealtimePipeline): Int? {
272272
for (stagePtr in pipeline.rewrittenStages.asReversed()) {
273273
// Check if the stage is a LimitStage
274274
if (stagePtr is LimitStage) {

firebase-firestore/src/main/java/com/google/firebase/firestore/core/QueryListener.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public QueryListener(
5656
if (query.isPipeline()) {
5757
this.query =
5858
new QueryOrPipeline.PipelineWrapper(
59-
query.pipeline().withListenOptions$com_google_firebase_firebase_firestore(options));
59+
query
60+
.pipeline$com_google_firebase_firebase_firestore()
61+
.withListenOptions$com_google_firebase_firebase_firestore(options));
6062
} else {
6163
this.query = query;
6264
}

firebase-firestore/src/main/java/com/google/firebase/firestore/core/View.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ public DocumentChanges computeDocChanges(
243243
candidates.add((MutableDocument) doc);
244244
}
245245
List<MutableDocument> results =
246-
this.query.pipeline().evaluate$com_google_firebase_firebase_firestore(candidates);
246+
this.query
247+
.pipeline$com_google_firebase_firebase_firestore()
248+
.evaluate$com_google_firebase_firebase_firestore(candidates);
247249
DocumentSet newResults = DocumentSet.emptySet(query.comparator());
248250
for (MutableDocument doc : results) {
249251
newResults = newResults.add(doc);
@@ -501,7 +503,8 @@ private static int changeTypeOrder(DocumentViewChange change) {
501503
@Nullable
502504
private static Long getLimit(QueryOrPipeline query) {
503505
if (query.isPipeline()) {
504-
Integer limit = getLastEffectiveLimit(query.pipeline());
506+
Integer limit =
507+
getLastEffectiveLimit(query.pipeline$com_google_firebase_firebase_firestore());
505508
if (limit == null) {
506509
return null;
507510
}

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalDocumentsView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ private ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingCollection
400400

401401
private ImmutableSortedMap<DocumentKey, Document> getDocumentsMatchingPipeline(
402402
QueryOrPipeline queryOrPipeline, IndexOffset offset, @Nullable QueryContext context) {
403-
RealtimePipeline pipeline = queryOrPipeline.pipeline();
403+
RealtimePipeline pipeline = queryOrPipeline.pipeline$com_google_firebase_firebase_firestore();
404404
if (getPipelineSourceType(pipeline) == PipelineSourceType.COLLECTION_GROUP) {
405405
String collectionGroup = getPipelineCollectionGroup(pipeline);
406406
hardAssert(

firebase-firestore/src/main/java/com/google/firebase/firestore/local/LocalSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ com.google.firebase.firestore.proto.Target encodeTargetData(TargetData targetDat
234234
com.google.firestore.v1.Target.PipelineQueryTarget.newBuilder()
235235
.setStructuredPipeline(
236236
target
237-
.pipeline()
237+
.pipeline$com_google_firebase_firebase_firestore()
238238
.toStructurePipelineProto$com_google_firebase_firebase_firestore()));
239239
}
240240

firebase-firestore/src/main/java/com/google/firebase/firestore/local/MemoryRemoteDocumentCache.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ public Map<DocumentKey, MutableDocument> getDocumentsMatchingQuery(
112112
if (query.isQuery()) {
113113
path = query.query().getPath();
114114
} else {
115-
path = ResourcePath.fromString(getPipelineCollection(query.pipeline()));
115+
path =
116+
ResourcePath.fromString(
117+
getPipelineCollection(query.pipeline$com_google_firebase_firebase_firestore()));
116118
}
117119
DocumentKey prefix = DocumentKey.fromPath(path.append(""));
118120
Iterator<Map.Entry<DocumentKey, Document>> iterator = docs.iteratorFrom(prefix);

firebase-firestore/src/main/java/com/google/firebase/firestore/local/SQLiteRemoteDocumentCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ public Map<DocumentKey, MutableDocument> getDocumentsMatchingQuery(
270270
if (query.isQuery()) {
271271
path = query.query().getPath();
272272
} else {
273-
String pathString = getPipelineCollection(query.pipeline());
273+
String pathString =
274+
getPipelineCollection(query.pipeline$com_google_firebase_firebase_firestore());
274275
hardAssert(
275276
pathString != null,
276277
"SQLiteRemoteDocumentCache.getDocumentsMatchingQuery receives pipeline without collection source.");

0 commit comments

Comments
 (0)