dsmiley commented on code in PR #4109:
URL: https://github.com/apache/solr/pull/4109#discussion_r2867532007
##########
solr/solrj/src/java/org/apache/solr/client/solrj/request/AbstractUpdateRequest.java:
##########
@@ -26,30 +28,90 @@ public abstract class AbstractUpdateRequest extends
CollectionRequiringSolrReque
protected ModifiableSolrParams params = new ModifiableSolrParams(); // maybe
make final; no setter
protected int commitWithin = -1;
+ public AbstractUpdateRequest(METHOD m, String path) {
+ super(m, path, SolrRequestType.UPDATE);
+ }
+
+ public enum CommitOption {
+ /** Makes the changes visible. True by default. */
+ openSearcher,
+ /** The request should wait for the changes to be visible. True by
default. */
+ waitSearcher,
+ /** A faster commit that's slightly less durable, and only affects the
leader replica. */
+ softCommit;
+
+ /** Default standard set of commit options: waitSearcher and openSearcher
*/
+ public static final EnumSet<CommitOption> DEFAULTS =
EnumSet.of(waitSearcher, openSearcher);
+ }
+
+ @Deprecated
public enum ACTION {
COMMIT,
OPTIMIZE
}
- public AbstractUpdateRequest(METHOD m, String path) {
- super(m, path, SolrRequestType.UPDATE);
+ /**
+ * Solr returns early but schedules a (typically soft) commit. When Solr
finishes processing the
+ * changes, it will then schedule the next auto soft-commit to occur no
later than the provided
+ * time interval. Other commit requests and automatic ones may expedite that
commit to occur
+ * sooner.
+ */
+ public AbstractUpdateRequest commitWithin(int val, TimeUnit unit) {
+ this.commitWithin = Math.toIntExact(unit.toMillis(val));
+ return this;
+ }
+
+ public AbstractUpdateRequest commit() {
+ params.set(UpdateParams.COMMIT, true);
+ return this;
+ }
+
+ /** Commits with additional options. The absense of an option means to
disable the option. */
+ public AbstractUpdateRequest commit(EnumSet<CommitOption> options) {
+ params.set(UpdateParams.COMMIT, true);
+ // only set if varies from default
+ if (options.contains(CommitOption.softCommit) == true) {
+ params.set(UpdateParams.SOFT_COMMIT, true);
Review Comment:
speaking of enum capitalization... my choice allows me to skip referencing
UpdateParams constants and instead take the enum name itself as-is. I didn't
do that... maybe I should. OTH, I often do a find-usages on canonical
constants to see where we reference them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]