1313import feast .ingestion .transform .ReadFeatureRow ;
1414import feast .ingestion .transform .ToFeatureRowExtended ;
1515import feast .ingestion .transform .WriteFeaturesTransform ;
16+ import feast .ingestion .transform .metrics .WriteMetricsTransform ;
1617import feast .ingestion .util .StorageUtil ;
18+ import feast .types .FeatureRowExtendedProto .FeatureRowExtended ;
1719import java .io .IOException ;
1820import java .net .URISyntaxException ;
1921import java .util .HashMap ;
2527import org .apache .beam .sdk .PipelineResult ;
2628import org .apache .beam .sdk .options .PipelineOptionsFactory ;
2729import org .apache .beam .sdk .options .PipelineOptionsValidator ;
30+ import org .apache .beam .sdk .values .PCollection ;
2831import org .apache .kafka .clients .consumer .KafkaConsumer ;
2932import org .apache .kafka .clients .consumer .OffsetAndTimestamp ;
3033import org .apache .kafka .common .PartitionInfo ;
@@ -39,8 +42,8 @@ public class ImportJob {
3942 * <p>The arguments will be passed to Beam {@code PipelineOptionsFactory} to create {@code
4043 * ImportJobPipelineOptions}.
4144 *
42- * <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if it
43- * is running, done or cancelled.
45+ * <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if
46+ * it is running, done or cancelled.
4447 *
4548 * @param args command line arguments, typically come from the main() method
4649 * @return PipelineResult
@@ -55,8 +58,8 @@ public static PipelineResult runPipeline(String[] args) throws IOException, URIS
5558 /**
5659 * Create and run a Beam pipeline from {@code ImportJobPipelineOptions}.
5760 *
58- * <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if it
59- * is running, done or cancelled.
61+ * <p>The returned PipelineResult object can be used to check the state of the pipeline e.g. if
62+ * it is running, done or cancelled.
6063 *
6164 * @param pipelineOptions configuration for the pipeline
6265 * @return PipelineResult
@@ -81,10 +84,14 @@ public static PipelineResult runPipeline(ImportJobPipelineOptions pipelineOption
8184 setupSource (pipelineOptions .getJobName (), featureSetSpec .getSource ());
8285 setupStore (store , featureSetSpec );
8386
84- pipeline
87+ PCollection < FeatureRowExtended > featureRows = pipeline
8588 .apply ("Read FeatureRow" , new ReadFeatureRow (featureSetSpec ))
8689 .apply ("Filter FeatureRow" , new FilterFeatureRow (featureSetSpec ))
87- .apply ("Create FeatureRowExtended from FeatureRow" , new ToFeatureRowExtended ())
90+ .apply ("Create FeatureRowExtended from FeatureRow" , new ToFeatureRowExtended ());
91+
92+ featureRows
93+ .apply ("Write metrics" , new WriteMetricsTransform (store .getName (), featureSetSpec ));
94+ featureRows
8895 .apply ("Write FeatureRowExtended" , new WriteFeaturesTransform (store , featureSetSpec ));
8996 }
9097 }
@@ -128,8 +135,9 @@ private static void setupStore(Store store, FeatureSetSpec featureSetSpec) {
128135 * <p>Manually sets the consumer group offset for this job's consumer group to the offset at the
129136 * time at which we provision the ingestion job.
130137 *
131- * <p>This is necessary because the setup time for certain runners (e.g. Dataflow) might cause the
132- * worker to miss the messages that were emitted into the stream prior to the workers being ready.
138+ * <p>This is necessary because the setup time for certain runners (e.g. Dataflow) might cause
139+ * the worker to miss the messages that were emitted into the stream prior to the workers being
140+ * ready.
133141 */
134142 private static void setupSource (String jobName , Source source ) {
135143 if (!source .getType ().equals (SourceType .KAFKA )) {
@@ -174,4 +182,5 @@ private static void setupSource(String jobName, Source source) {
174182 }
175183 });
176184 }
185+
177186}
0 commit comments