Skip to content

Commit d7ca024

Browse files
committed
Hide realtime pipeline
1 parent 7918ce5 commit d7ca024

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
@@ -32,8 +32,8 @@ import com.google.firebase.firestore.util.Assert.hardAssert
3232

3333
/** A class that wraps either a Query or a RealtimePipeline. */
3434
sealed class QueryOrPipeline {
35-
data class QueryWrapper(val query: Query) : QueryOrPipeline()
36-
data class PipelineWrapper(val pipeline: RealtimePipeline) : QueryOrPipeline()
35+
internal data class QueryWrapper(internal val query: Query) : QueryOrPipeline()
36+
internal data class PipelineWrapper(internal val pipeline: RealtimePipeline) : QueryOrPipeline()
3737

3838
val isQuery: Boolean
3939
get() = this is QueryWrapper
@@ -45,7 +45,7 @@ sealed class QueryOrPipeline {
4545
return (this as QueryWrapper).query
4646
}
4747

48-
fun pipeline(): RealtimePipeline {
48+
internal fun pipeline(): RealtimePipeline {
4949
return (this as PipelineWrapper).pipeline
5050
}
5151

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

107107
val isTarget: Boolean
108108
get() = this is TargetWrapper
@@ -114,7 +114,7 @@ sealed class TargetOrPipeline {
114114
return (this as TargetWrapper).target
115115
}
116116

117-
fun pipeline(): RealtimePipeline {
117+
internal fun pipeline(): RealtimePipeline {
118118
return (this as PipelineWrapper).pipeline
119119
}
120120

@@ -178,15 +178,15 @@ enum class PipelineSourceType {
178178
}
179179

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

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

203203
// Retrieves the collection group ID if the pipeline's source is a collection
204204
// group.
205-
fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
205+
internal fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
206206
if (getPipelineSourceType(pipeline) == PipelineSourceType.COLLECTION_GROUP) {
207207
hardAssert(
208208
!pipeline.stages.isEmpty(),
@@ -217,7 +217,7 @@ fun getPipelineCollectionGroup(pipeline: RealtimePipeline): String? {
217217
}
218218

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

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

249249
// Creates a new pipeline by replacing CollectionGroupSource stages with
250250
// CollectionSource stages using the provided path.
251-
fun asCollectionPipelineAtPath(
251+
internal fun asCollectionPipelineAtPath(
252252
pipeline: RealtimePipeline,
253253
path: ResourcePath,
254254
): RealtimePipeline {
@@ -271,7 +271,7 @@ fun asCollectionPipelineAtPath(
271271
)
272272
}
273273

274-
fun getLastEffectiveLimit(pipeline: RealtimePipeline): Int? {
274+
internal fun getLastEffectiveLimit(pipeline: RealtimePipeline): Int? {
275275
for (stagePtr in pipeline.rewrittenStages.asReversed()) {
276276
// Check if the stage is a LimitStage
277277
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)