Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MabelYC committed Jan 24, 2024
1 parent 1b95e8d commit 2054424
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.apache.beam.sdk.options;

import java.util.Iterator;
import java.util.ServiceLoader;
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Iterators;
import org.checkerframework.checker.initialization.qual.Initialized;
import org.checkerframework.checker.nullness.qual.Nullable;


@SuppressWarnings("rawtypes")
/**
* Interface to support offspring wire-in for Li: if input class meets some requirements,
* the customized pipelineOptions will be initialized.
*
*/
public interface InitializePipelineOptionsFactory<T> {
T initializePipelineOptions(T pipelineOptions, Class<T> clazz);

interface Registrar {
InitializePipelineOptionsFactory create();
}


static @Initialized @Nullable InitializePipelineOptionsFactory getFactory() {
final Iterator<InitializePipelineOptionsFactory.Registrar>
factories = ServiceLoader.load(InitializePipelineOptionsFactory.Registrar.class).iterator();
return factories.hasNext() ? Iterators.getOnlyElement(factories).create() : null;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ <T extends PipelineOptions> T as(Class<T> iface, PipelineOptions pipelineOptions
computedProperties =
computedProperties.updated(iface, existingOption, propertyDescriptors);
// Linkedin specific change: initialize the offspring generator
if (pipelineOptions != null && InvokePipelineOptionsFactory.getFactory() != null) {
InvokePipelineOptionsFactory.getFactory().getPipelineOptions(existingOption, iface);
if (pipelineOptions != null && InitializePipelineOptionsFactory.getFactory() != null) {
InitializePipelineOptionsFactory.getFactory().initializePipelineOptions(existingOption, iface);
}
}
}
Expand Down

0 comments on commit 2054424

Please sign in to comment.