use of scala.PartialFunction in project OpenLineage by OpenLineage.
the class InternalEventHandlerFactory method createInputDatasetBuilder.
@Override
public Collection<PartialFunction<Object, List<InputDataset>>> createInputDatasetBuilder(OpenLineageContext context) {
ImmutableList builders = ImmutableList.<PartialFunction<Object, List<InputDataset>>>builder().addAll(generate(eventHandlerFactories, factory -> factory.createInputDatasetBuilder(context))).addAll(DatasetBuilderFactoryProvider.getInstance().getInputBuilders(context)).build();
context.getInputDatasetBuilders().addAll(builders);
return builders;
}
use of scala.PartialFunction in project OpenLineage by OpenLineage.
the class BaseVisitorFactory method getOutputVisitors.
@Override
public List<PartialFunction<LogicalPlan, List<OpenLineage.OutputDataset>>> getOutputVisitors(OpenLineageContext context) {
DatasetFactory<OpenLineage.OutputDataset> factory = DatasetFactory.output(context.getOpenLineage());
List<PartialFunction<LogicalPlan, List<OpenLineage.OutputDataset>>> outputCommonVisitors = getCommonVisitors(context, factory);
List<PartialFunction<LogicalPlan, List<OpenLineage.OutputDataset>>> list = new ArrayList<>(outputCommonVisitors);
list.add(new InsertIntoDataSourceDirVisitor(context));
list.add(new InsertIntoDataSourceVisitor(context));
list.add(new InsertIntoHadoopFsRelationVisitor(context));
list.add(new CreateDataSourceTableAsSelectCommandVisitor(context));
list.add(new InsertIntoDirVisitor(context));
if (InsertIntoHiveTableVisitor.hasHiveClasses()) {
list.add(new InsertIntoHiveTableVisitor(context));
list.add(new InsertIntoHiveDirVisitor(context));
list.add(new CreateHiveTableAsSelectCommandVisitor(context));
}
if (OptimizedCreateHiveTableAsSelectCommandVisitor.hasClasses()) {
list.add(new OptimizedCreateHiveTableAsSelectCommandVisitor(context));
}
list.add(new CreateDataSourceTableCommandVisitor(context));
list.add(new LoadDataCommandVisitor(context));
list.add(new AlterTableRenameCommandVisitor(context));
list.add(new AlterTableAddColumnsCommandVisitor(context));
list.add(new CreateTableCommandVisitor(context));
list.add(new DropTableCommandVisitor(context));
list.add(new TruncateTableCommandVisitor(context));
return list;
}
use of scala.PartialFunction in project ditto by eclipse.
the class StreamingSessionActor method createOutgoingSignalBehavior.
private Receive createOutgoingSignalBehavior() {
final PartialFunction<Object, Object> setCorrelationIdAndStartAckForwarder = new PFBuilder<>().match(Signal.class, this::startAckForwarder).match(DittoRuntimeException.class, x -> x).build();
final Receive publishSignal = ReceiveBuilder.create().match(SubscriptionEvent.class, signal -> {
logger.debug("Got SubscriptionEvent in <{}> session, publishing: {}", type, signal);
eventAndResponsePublisher.offer(SessionedJsonifiable.subscription(signal));
}).match(CommandResponse.class, this::publishResponseOrError).match(DittoRuntimeException.class, this::publishResponseOrError).match(Signal.class, this::isSameOrigin, signal -> logger.withCorrelationId(signal).debug("Got Signal of type <{}> in <{}> session, but this was issued by " + " this connection itself, not publishing", signal.getType(), type)).match(Signal.class, signal -> {
// check if this session is "allowed" to receive the Signal
final var streamingType = determineStreamingType(signal);
@Nullable final var session = streamingSessions.get(streamingType);
if (null != session && isSessionAllowedToReceiveSignal(signal, session, streamingType)) {
final ThreadSafeDittoLoggingAdapter l = logger.withCorrelationId(signal);
l.info("Publishing Signal of type <{}> in <{}> session", signal.getType(), type);
l.debug("Publishing Signal of type <{}> in <{}> session: {}", type, signal.getType(), signal);
final DittoHeaders sessionHeaders = DittoHeaders.newBuilder().authorizationContext(authorizationContext).schemaVersion(jsonSchemaVersion).build();
final var sessionedJsonifiable = SessionedJsonifiable.signal(signal, sessionHeaders, session);
eventAndResponsePublisher.offer(sessionedJsonifiable);
}
}).matchEquals(Done.getInstance(), done -> {
/* already done, nothing to publish */
}).build();
return addPreprocessors(List.of(setCorrelationIdAndStartAckForwarder), publishSignal);
}
use of scala.PartialFunction in project OpenLineage by OpenLineage.
the class InternalEventHandlerFactory method createOutputDatasetBuilder.
@Override
public Collection<PartialFunction<Object, List<OutputDataset>>> createOutputDatasetBuilder(OpenLineageContext context) {
ImmutableList outputDatasetBuilders = ImmutableList.<PartialFunction<Object, List<OutputDataset>>>builder().addAll(generate(eventHandlerFactories, factory -> factory.createOutputDatasetBuilder(context))).addAll(DatasetBuilderFactoryProvider.getInstance().getOutputBuilders(context)).build();
context.getOutputDatasetBuilders().addAll(outputDatasetBuilders);
return outputDatasetBuilders;
}
use of scala.PartialFunction in project OpenLineage by OpenLineage.
the class BaseVisitorFactory method getBaseCommonVisitors.
protected <D extends Dataset> List<PartialFunction<LogicalPlan, List<D>>> getBaseCommonVisitors(OpenLineageContext context, DatasetFactory<D> factory) {
List<PartialFunction<LogicalPlan, List<D>>> list = new ArrayList<>();
list.add(new LogicalRDDVisitor(context, factory));
if (BigQueryNodeVisitor.hasBigQueryClasses()) {
list.add(new BigQueryNodeVisitor(context, factory));
}
if (KafkaRelationVisitor.hasKafkaClasses()) {
list.add(new KafkaRelationVisitor(context, factory));
}
if (SqlDWDatabricksVisitor.hasSqlDWDatabricksClasses()) {
list.add(new SqlDWDatabricksVisitor(context, factory));
}
return list;
}
Aggregations