Search in sources :

Example 1 with ExistenceFilter

use of com.google.firebase.firestore.remote.ExistenceFilter in project firebase-android-sdk by firebase.

the class SpecTestCase method doWatchFilter.

private void doWatchFilter(JSONArray watchFilter) throws Exception {
    List<Integer> targets = parseIntList(watchFilter.getJSONArray(0));
    Assert.hardAssert(targets.size() == 1, "ExistenceFilters currently support exactly one target only.");
    int keyCount = watchFilter.length() == 0 ? 0 : watchFilter.length() - 1;
    // TODO: extend this with different existence filters over time.
    ExistenceFilter filter = new ExistenceFilter(keyCount);
    ExistenceFilterWatchChange change = new ExistenceFilterWatchChange(targets.get(0), filter);
    writeWatchChange(change, SnapshotVersion.NONE);
}
Also used : ExistenceFilter(com.google.firebase.firestore.remote.ExistenceFilter) ExistenceFilterWatchChange(com.google.firebase.firestore.remote.WatchChange.ExistenceFilterWatchChange)

Example 2 with ExistenceFilter

use of com.google.firebase.firestore.remote.ExistenceFilter in project firebase-android-sdk by firebase.

the class TestUtil method existenceFilterEvent.

public static RemoteEvent existenceFilterEvent(int targetId, ImmutableSortedSet<DocumentKey> syncedKeys, int remoteCount, int version) {
    TargetData targetData = TestUtil.targetData(targetId, QueryPurpose.LISTEN, "foo");
    TestTargetMetadataProvider testTargetMetadataProvider = new TestTargetMetadataProvider();
    testTargetMetadataProvider.setSyncedKeys(targetData, syncedKeys);
    ExistenceFilter existenceFilter = new ExistenceFilter(remoteCount);
    WatchChangeAggregator aggregator = new WatchChangeAggregator(testTargetMetadataProvider);
    WatchChange.ExistenceFilterWatchChange existenceFilterWatchChange = new WatchChange.ExistenceFilterWatchChange(targetId, existenceFilter);
    aggregator.handleExistenceFilter(existenceFilterWatchChange);
    return aggregator.createRemoteEvent(version(version));
}
Also used : TargetData(com.google.firebase.firestore.local.TargetData) WatchChangeAggregator(com.google.firebase.firestore.remote.WatchChangeAggregator) ExistenceFilter(com.google.firebase.firestore.remote.ExistenceFilter) WatchChange(com.google.firebase.firestore.remote.WatchChange)

Aggregations

ExistenceFilter (com.google.firebase.firestore.remote.ExistenceFilter)2 TargetData (com.google.firebase.firestore.local.TargetData)1 WatchChange (com.google.firebase.firestore.remote.WatchChange)1 ExistenceFilterWatchChange (com.google.firebase.firestore.remote.WatchChange.ExistenceFilterWatchChange)1 WatchChangeAggregator (com.google.firebase.firestore.remote.WatchChangeAggregator)1