Skip to content

Commit 54366bf

Browse files
committed
chore: enhance PipelineParser to support execute options for Firestore pipelines
1 parent 143bde5 commit 54366bf

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

  • packages/cloud_firestore/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/firestore/utils

packages/cloud_firestore/cloud_firestore/android/src/main/java/io/flutter/plugins/firebase/firestore/utils/PipelineParser.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,29 @@ public static Snapshot executePipeline(
3636
@Nullable Map<String, Object> options)
3737
throws Exception {
3838
Pipeline pipeline = buildPipeline(firestore, stages);
39-
Task<Snapshot> task = pipeline.execute();
39+
Task<Snapshot> task;
40+
if (options != null && !options.isEmpty()) {
41+
Pipeline.ExecuteOptions executeOptions = parseExecuteOptions(options);
42+
task = pipeline.execute(executeOptions);
43+
} else {
44+
task = pipeline.execute();
45+
}
4046
return Tasks.await(task);
4147
}
4248

49+
private static Pipeline.ExecuteOptions parseExecuteOptions(@NonNull Map<String, Object> options) {
50+
Pipeline.ExecuteOptions executeOptions = new Pipeline.ExecuteOptions();
51+
Object indexModeObj = options.get("indexMode");
52+
if (indexModeObj instanceof String) {
53+
String indexModeStr = (String) indexModeObj;
54+
if ("recommended".equalsIgnoreCase(indexModeStr)) {
55+
executeOptions =
56+
executeOptions.withIndexMode(Pipeline.ExecuteOptions.IndexMode.RECOMMENDED);
57+
}
58+
}
59+
return executeOptions;
60+
}
61+
4362
/**
4463
* Builds a Pipeline from a list of stage maps without executing it. Used when a stage (e.g.
4564
* union) requires another pipeline as an argument.

0 commit comments

Comments
 (0)