Skip to content

Commit

Permalink
[BEAM-12258] Make resourceHints non-nullable (apache#14736)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNeuralBit committed May 7, 2021
1 parent 31b351b commit 825a1ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ public static ResourceHints create() {
public static ResourceHints fromOptions(PipelineOptions options) {
ResourceHintsOptions resourceHintsOptions = options.as(ResourceHintsOptions.class);
ResourceHints result = create();
@Nullable List<String> hints = resourceHintsOptions.getResourceHints();
if (hints == null) {
return result;
}
List<String> hints = resourceHintsOptions.getResourceHints();
Splitter splitter = Splitter.on('=').limit(2);
for (String hint : hints) {
List<String> parts = splitter.splitToList(hint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,27 @@

import com.google.auto.service.AutoService;
import java.util.List;
import org.apache.beam.sdk.options.Default;
import org.apache.beam.sdk.options.DefaultValueFactory;
import org.apache.beam.sdk.options.Description;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.options.PipelineOptionsRegistrar;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList;
import org.checkerframework.checker.nullness.qual.Nullable;

/** Options that are used to control configuration of the remote environment. */
public interface ResourceHintsOptions extends PipelineOptions {
class EmptyListDefault implements DefaultValueFactory<List> {
@Override
public List create(PipelineOptions options) {
return ImmutableList.of();
}
}

@Description("Resource hints used for all transform execution environments.")
@Nullable
@Default.InstanceFactory(EmptyListDefault.class)
List<String> getResourceHints();

void setResourceHints(@Nullable List<String> value);
void setResourceHints(List<String> value);

/** Register the {@link ResourceHintsOptions}. */
@AutoService(PipelineOptionsRegistrar.class)
Expand Down

0 comments on commit 825a1ec

Please sign in to comment.