@@ -1073,49 +1073,31 @@ public void testUsesTargetMappingToExecuteQueries() {
1073
1073
1074
1074
@ Test
1075
1075
public void testLastLimboFreeSnapshotIsAdvancedDuringViewProcessing () {
1076
- assumeFalse (garbageCollectorIsEager ());
1077
- assumeTrue (queryEngine instanceof IndexFreeQueryEngine );
1078
-
1079
1076
// This test verifies that the `lastLimboFreeSnapshot` version for QueryData is advanced when
1080
1077
// we compute a limbo-free free view and that the mapping is persisted when we release a query.
1081
1078
1082
- writeMutation (setMutation ("foo/ignored" , map ("matches" , false )));
1083
- acknowledgeMutation (10 );
1084
-
1085
- Query query =
1086
- Query .atPath (ResourcePath .fromString ("foo" )).filter (filter ("matches" , "==" , true ));
1079
+ Query query = Query .atPath (ResourcePath .fromString ("foo" ));
1087
1080
int targetId = allocateQuery (query );
1088
1081
1089
- // Mark the query as current.
1090
- applyRemoteEvent (
1091
- addedRemoteEvent (
1092
- asList (doc ("foo/a" , 10 , map ("matches" , true )), doc ("foo/b" , 10 , map ("matches" , true ))),
1093
- asList (targetId ),
1094
- emptyList ()));
1082
+ // Advance the query snapshot.
1095
1083
applyRemoteEvent (noChangeEvent (targetId , 10 ));
1096
1084
1097
1085
// At this point, we have not yet confirmed that the query is limbo free.
1098
- Assert . assertEquals (
1099
- SnapshotVersion .NONE , localStore . getQueryData ( query ) .getLastLimboFreeSnapshotVersion ());
1086
+ QueryData cachedQueryData = localStore . getQueryData ( query );
1087
+ Assert . assertEquals ( SnapshotVersion .NONE , cachedQueryData .getLastLimboFreeSnapshotVersion ());
1100
1088
1101
- // Update the view, but don't mark the view synced.
1102
- Assert .assertEquals (
1103
- SnapshotVersion .NONE , localStore .getQueryData (query ).getLastLimboFreeSnapshotVersion ());
1089
+ // Mark the view synced, which updates the last limbo free snapshot version.
1104
1090
udpateViews (targetId , /* fromCache=*/ false );
1105
-
1106
- // The query is marked limbo-free only when we mark the view synced.
1107
- udpateViews (targetId , /* fromCache=*/ false );
1108
- Assert .assertNotEquals (
1109
- SnapshotVersion .NONE , localStore .getQueryData (query ).getLastLimboFreeSnapshotVersion ());
1091
+ cachedQueryData = localStore .getQueryData (query );
1092
+ Assert .assertEquals (version (10 ), cachedQueryData .getLastLimboFreeSnapshotVersion ());
1110
1093
1111
1094
// The last limbo free snapshot version is persisted even if we release the query.
1112
1095
releaseQuery (query );
1113
- allocateQuery (query );
1114
1096
1115
- // Verify that we only read the two documents that match the query.
1116
- executeQuery (query );
1117
- assertRemoteDocumentsRead ( 2 );
1118
- assertQueryReturned ( "foo/a" , "foo/b" );
1097
+ if (! garbageCollectorIsEager ()) {
1098
+ cachedQueryData = localStore . getQueryData (query );
1099
+ Assert . assertEquals ( version ( 10 ), cachedQueryData . getLastLimboFreeSnapshotVersion () );
1100
+ }
1119
1101
}
1120
1102
1121
1103
@ Test
@@ -1130,28 +1112,26 @@ public void testQueriesIncludeLocallyModifiedDocuments() {
1130
1112
1131
1113
applyRemoteEvent (
1132
1114
addedRemoteEvent (
1133
- asList (doc ("foo/a" , 10 , map ("matches" , true )), doc ("foo/b" , 10 , map ("matches" , true ))),
1134
- asList (targetId ),
1135
- emptyList ()));
1115
+ asList (doc ("foo/a" , 10 , map ("matches" , true ))), asList (targetId ), emptyList ()));
1136
1116
applyRemoteEvent (noChangeEvent (targetId , 10 ));
1137
1117
udpateViews (targetId , /* fromCache= */ false );
1138
1118
1139
1119
// Execute the query based on the RemoteEvent.
1140
1120
executeQuery (query );
1141
- assertQueryReturned ("foo/a" , "foo/b" );
1121
+ assertQueryReturned ("foo/a" );
1142
1122
1143
1123
// Write a document.
1144
- writeMutation (setMutation ("foo/c " , map ("matches" , true )));
1124
+ writeMutation (setMutation ("foo/b " , map ("matches" , true )));
1145
1125
1146
1126
// Execute the query and make sure that the pending mutation is included in the result.
1147
1127
executeQuery (query );
1148
- assertQueryReturned ("foo/a" , "foo/b" , "foo/c" );
1128
+ assertQueryReturned ("foo/a" , "foo/b" );
1149
1129
1150
1130
acknowledgeMutation (11 );
1151
1131
1152
1132
// Execute the query and make sure that the acknowledged mutation is included in the result.
1153
1133
executeQuery (query );
1154
- assertQueryReturned ("foo/a" , "foo/b" , "foo/c" );
1134
+ assertQueryReturned ("foo/a" , "foo/b" );
1155
1135
}
1156
1136
1157
1137
@ Test
@@ -1167,23 +1147,17 @@ public void testQueriesIncludeDocumentsFromOtherQueries() {
1167
1147
1168
1148
applyRemoteEvent (
1169
1149
addedRemoteEvent (
1170
- asList (doc ("foo/a" , 10 , map ("matches" , true )), doc ("foo/b" , 10 , map ("matches" , true ))),
1171
- asList (targetId ),
1172
- emptyList ()));
1150
+ asList (doc ("foo/a" , 10 , map ("matches" , true ))), asList (targetId ), emptyList ()));
1173
1151
applyRemoteEvent (noChangeEvent (targetId , 10 ));
1174
1152
udpateViews (targetId , /* fromCache=*/ false );
1175
1153
releaseQuery (filteredQuery );
1176
1154
1177
1155
// Start another query and add more matching documents to the collection.
1178
- Query fullQuery =
1179
- Query .atPath (ResourcePath .fromString ("foo" )).filter (filter ("matches" , "==" , true ));
1180
- targetId = allocateQuery (filteredQuery );
1156
+ Query fullQuery = Query .atPath (ResourcePath .fromString ("foo" ));
1157
+ targetId = allocateQuery (fullQuery );
1181
1158
applyRemoteEvent (
1182
1159
addedRemoteEvent (
1183
- asList (
1184
- doc ("foo/a" , 10 , map ("matches" , true )),
1185
- doc ("foo/b" , 10 , map ("matches" , true )),
1186
- doc ("foo/c" , 20 , map ("matches" , true ))),
1160
+ asList (doc ("foo/a" , 10 , map ("matches" , true )), doc ("foo/b" , 20 , map ("matches" , true ))),
1187
1161
asList (targetId ),
1188
1162
emptyList ()));
1189
1163
releaseQuery (fullQuery );
@@ -1192,7 +1166,7 @@ public void testQueriesIncludeDocumentsFromOtherQueries() {
1192
1166
// matches are included in the result set.
1193
1167
allocateQuery (filteredQuery );
1194
1168
executeQuery (filteredQuery );
1195
- assertQueryReturned ("foo/a" , "foo/b" , "foo/c" );
1169
+ assertQueryReturned ("foo/a" , "foo/b" );
1196
1170
}
1197
1171
1198
1172
@ Test
@@ -1217,9 +1191,8 @@ public void testQueriesFilterDocumentsThatNoLongerMatch() {
1217
1191
releaseQuery (filteredQuery );
1218
1192
1219
1193
// Modify one of the documents to no longer match while the filtered query is inactive.
1220
- Query fullQuery =
1221
- Query .atPath (ResourcePath .fromString ("foo" )).filter (filter ("matches" , "==" , true ));
1222
- targetId = allocateQuery (filteredQuery );
1194
+ Query fullQuery = Query .atPath (ResourcePath .fromString ("foo" ));
1195
+ targetId = allocateQuery (fullQuery );
1223
1196
applyRemoteEvent (
1224
1197
addedRemoteEvent (
1225
1198
asList (doc ("foo/a" , 10 , map ("matches" , true )), doc ("foo/b" , 20 , map ("matches" , false ))),
0 commit comments