Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 38a1ff1

Browse files
committed
pipeline snippets and docs fix
1 parent a407627 commit 38a1ff1

2 files changed

Lines changed: 55 additions & 16 deletions

File tree

  • google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions
  • samples/preview-snippets/src/main/java/com/example/firestore

google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ public static Expression mapSet(
19901990
* a key entirely, use {@code mapRemove}.
19911991
* </ul>
19921992
*
1993-
* @param mapField The map field to set entries in.
1993+
* @param mapExpr The map field to set entries in.
19941994
* @param key The key to set.
19951995
* @param value The value to set.
19961996
* @param moreKeyValues Additional key-value pairs to set.
@@ -2051,7 +2051,7 @@ public static Expression mapSet(
20512051
/**
20522052
* Creates an expression that returns the keys of a map.
20532053
*
2054-
* @param mapExpr The map expression to get the keys of.
2054+
* @param mapExpr The expression representing the map to get the keys of.
20552055
* @return A new {@link Expression} representing the keys of the map.
20562056
*/
20572057
@BetaApi

samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,26 +1167,65 @@ void minLogicalFunction() throws ExecutionException, InterruptedException {
11671167
void mapGetFunction() throws ExecutionException, InterruptedException {
11681168
// [START map_get]
11691169
Pipeline.Snapshot result =
1170-
firestore
1171-
.pipeline()
1172-
.collection("books")
1173-
.select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward"))
1174-
.execute()
1175-
.get();
1170+
firestore
1171+
.pipeline()
1172+
.collection("books")
1173+
.select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward"))
1174+
.execute()
1175+
.get();
11761176
// [END map_get]
11771177
System.out.println(result.getResults());
11781178
}
11791179

11801180
void mapSetFunction() throws ExecutionException, InterruptedException {
1181-
// [START map_get]
1181+
// [START map_set]
11821182
Pipeline.Snapshot result =
1183-
firestore
1184-
.pipeline()
1185-
.collection("books")
1186-
.select(mapSet(field("awards"), "pulitzer").as("awards"))
1187-
.execute()
1188-
.get();
1189-
// [END map_get]
1183+
firestore
1184+
.pipeline()
1185+
.collection("books")
1186+
.select(mapSet(field("awards"), "pulitzer", true).as("awards"))
1187+
.execute()
1188+
.get();
1189+
// [END map_set]
1190+
System.out.println(result.getResults());
1191+
}
1192+
1193+
void mapKeysFunction() throws ExecutionException, InterruptedException {
1194+
// [START map_keys]
1195+
Pipeline.Snapshot result =
1196+
firestore
1197+
.pipeline()
1198+
.collection("books")
1199+
.select(mapKeys(field("awards")).as("award_categories"))
1200+
.execute()
1201+
.get();
1202+
// [END map_keys]
1203+
System.out.println(result.getResults());
1204+
}
1205+
1206+
void mapValuesFunction() throws ExecutionException, InterruptedException {
1207+
// [START map_values]
1208+
Pipeline.Snapshot result =
1209+
firestore
1210+
.pipeline()
1211+
.collection("books")
1212+
.select(mapValues(field("awards")).as("award_details"))
1213+
.execute()
1214+
.get();
1215+
// [END map_values]
1216+
System.out.println(result.getResults());
1217+
}
1218+
1219+
void mapEntriesFunction() throws ExecutionException, InterruptedException {
1220+
// [START map_entries]
1221+
Pipeline.Snapshot result =
1222+
firestore
1223+
.pipeline()
1224+
.collection("books")
1225+
.select(mapEntries(field("awards")).as("awards_list"))
1226+
.execute()
1227+
.get();
1228+
// [END map_entries]
11901229
System.out.println(result.getResults());
11911230
}
11921231

0 commit comments

Comments
 (0)