use of org.apache.asterix.lang.aql.statement.SubscribeFeedStatement in project asterixdb by apache.
the class FeedOperations method getConnectionJob.
private static JobSpecification getConnectionJob(SessionOutput sessionOutput, MetadataProvider metadataProvider, FeedConnection feedConnection, String[] locations, ILangCompilationProvider compilationProvider, IStorageComponentProvider storageComponentProvider, DefaultStatementExecutorFactory qtFactory, IHyracksClientConnection hcc) throws AlgebricksException, RemoteException, ACIDException {
DataverseDecl dataverseDecl = new DataverseDecl(new Identifier(feedConnection.getDataverseName()));
FeedConnectionRequest fcr = new FeedConnectionRequest(FeedRuntimeType.INTAKE, feedConnection.getAppliedFunctions(), feedConnection.getDatasetName(), feedConnection.getPolicyName(), feedConnection.getFeedId());
SubscribeFeedStatement subscribeStmt = new SubscribeFeedStatement(locations, fcr);
subscribeStmt.initialize(metadataProvider.getMetadataTxnContext());
List<Statement> statements = new ArrayList<>();
statements.add(dataverseDecl);
statements.add(subscribeStmt);
IStatementExecutor translator = qtFactory.create(metadataProvider.getApplicationContext(), statements, sessionOutput, compilationProvider, storageComponentProvider);
// configure the metadata provider
metadataProvider.getConfig().put(FunctionUtil.IMPORT_PRIVATE_FUNCTIONS, "" + Boolean.TRUE);
metadataProvider.getConfig().put(FeedActivityDetails.FEED_POLICY_NAME, "" + subscribeStmt.getPolicy());
metadataProvider.getConfig().put(FeedActivityDetails.COLLECT_LOCATIONS, StringUtils.join(subscribeStmt.getLocations(), ','));
CompiledStatements.CompiledSubscribeFeedStatement csfs = new CompiledStatements.CompiledSubscribeFeedStatement(subscribeStmt.getSubscriptionRequest(), subscribeStmt.getVarCounter());
return translator.rewriteCompileQuery(hcc, metadataProvider, subscribeStmt.getQuery(), csfs);
}
Aggregations