本文整理汇总了Java中com.facebook.presto.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于com.facebook.presto包,在下文中一共展示了Session类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLocalQueryRunner
import com.facebook.presto.Session; //导入依赖的package包/类
public static QueryRunner createLocalQueryRunner()
throws Exception
{
Session defaultSession = testSessionBuilder()
.setCatalog("slack")
.setSchema("default")
.build();
QueryRunner queryRunner = new DistributedQueryRunner(defaultSession, 1);
queryRunner.installPlugin(new SlackPlugin());
queryRunner.createCatalog(
"slack",
"slack",
ImmutableMap.of("token", System.getenv("SLACK_TOKEN")));
return queryRunner;
}
示例2: createLocalQueryRunner
import com.facebook.presto.Session; //导入依赖的package包/类
public static QueryRunner createLocalQueryRunner()
throws Exception
{
Session defaultSession = testSessionBuilder()
.setCatalog("github")
.setSchema("default")
.build();
QueryRunner queryRunner = new DistributedQueryRunner(defaultSession, 1);
queryRunner.installPlugin(new GithubPlugin());
queryRunner.createCatalog(
"github",
"github",
ImmutableMap.of("token", System.getenv("GITHUB_TOKEN")));
return queryRunner;
}
示例3: createLocalQueryRunner
import com.facebook.presto.Session; //导入依赖的package包/类
private static QueryRunner createLocalQueryRunner()
throws Exception
{
Session defaultSession = TestingSession.testSessionBuilder()
.setCatalog("twitter")
.setSchema("default")
.build();
QueryRunner queryRunner = new DistributedQueryRunner(defaultSession, 1);
queryRunner.installPlugin(new TwitterPlugin());
queryRunner.createCatalog(
"twitter",
"twitter",
ImmutableMap.of(
"customer_key", System.getenv("TWITTER_CUSTOMER_KEY"),
"customer_secret", System.getenv("TWITTER_CUSTOMER_SECRET"),
"token", System.getenv("TWITTER_TOKEN"),
"secret", System.getenv("TWITTER_SECRET")));
return queryRunner;
}
示例4: createLocalQueryRunner
import com.facebook.presto.Session; //导入依赖的package包/类
private static LocalQueryRunner createLocalQueryRunner()
{
Session defaultSession = testSessionBuilder()
.setCatalog("tpch")
.setSchema(TINY_SCHEMA_NAME)
.build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());
HyperLogLogPlugin plugin = new HyperLogLogPlugin();
for (Type type : plugin.getTypes()) {
localQueryRunner.getTypeManager().addType(type);
}
for (ParametricType parametricType : plugin.getParametricTypes()) {
localQueryRunner.getTypeManager().addParametricType(parametricType);
}
localQueryRunner.getMetadata().addFunctions(extractFunctions(plugin.getFunctions()));
return localQueryRunner;
}
示例5: listTables
import com.facebook.presto.Session; //导入依赖的package包/类
@Override
public List<QualifiedObjectName> listTables(Session session, QualifiedTablePrefix prefix)
{
requireNonNull(prefix, "prefix is null");
String schemaNameOrNull = prefix.getSchemaName().orElse(null);
Set<QualifiedObjectName> tables = new LinkedHashSet<>();
for (ConnectorEntry entry : allConnectorsFor(prefix.getCatalogName())) {
ConnectorMetadata metadata = entry.getMetadata(session);
ConnectorSession connectorSession = session.toConnectorSession(entry.getCatalog());
for (QualifiedObjectName tableName : transform(metadata.listTables(connectorSession, schemaNameOrNull), convertFromSchemaTableName(prefix.getCatalogName()))) {
tables.add(tableName);
}
}
return ImmutableList.copyOf(tables);
}
示例6: StatementAnalyzer
import com.facebook.presto.Session; //导入依赖的package包/类
public StatementAnalyzer(
Analysis analysis,
Metadata metadata,
SqlParser sqlParser,
AccessControl accessControl, Session session,
boolean experimentalSyntaxEnabled,
Optional<QueryExplainer> queryExplainer)
{
this.analysis = requireNonNull(analysis, "analysis is null");
this.metadata = requireNonNull(metadata, "metadata is null");
this.sqlParser = requireNonNull(sqlParser, "sqlParser is null");
this.accessControl = requireNonNull(accessControl, "accessControl is null");
this.session = requireNonNull(session, "session is null");
this.experimentalSyntaxEnabled = experimentalSyntaxEnabled;
this.queryExplainer = requireNonNull(queryExplainer, "queryExplainer is null");
}
示例7: createLocalQueryRunner
import com.facebook.presto.Session; //导入依赖的package包/类
public static LocalQueryRunner createLocalQueryRunner()
{
Session session = testSessionBuilder()
.setCatalog("raptor")
.setSchema("benchmark")
.build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);
// add tpch
InMemoryNodeManager nodeManager = localQueryRunner.getNodeManager();
localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(nodeManager, 1), ImmutableMap.<String, String>of());
// add raptor
ConnectorFactory raptorConnectorFactory = createRaptorConnectorFactory(TPCH_CACHE_DIR, nodeManager);
localQueryRunner.createCatalog("raptor", raptorConnectorFactory, ImmutableMap.of());
if (!localQueryRunner.tableExists(session, "orders")) {
localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
}
if (!localQueryRunner.tableExists(session, "lineitem")) {
localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
}
return localQueryRunner;
}
示例8: getGraphvizPlan
import com.facebook.presto.Session; //导入依赖的package包/类
public String getGraphvizPlan(Session session, Statement statement, Type planType)
{
DataDefinitionTask<?> task = dataDefinitionTask.get(statement.getClass());
if (task != null) {
// todo format as graphviz
return explainTask(statement, task);
}
switch (planType) {
case LOGICAL:
Plan plan = getLogicalPlan(session, statement);
return PlanPrinter.graphvizLogicalPlan(plan.getRoot(), plan.getTypes());
case DISTRIBUTED:
SubPlan subPlan = getDistributedPlan(session, statement);
return PlanPrinter.graphvizDistributedPlan(subPlan);
}
throw new IllegalArgumentException("Unhandled plan type: " + planType);
}
示例9: listViews
import com.facebook.presto.Session; //导入依赖的package包/类
@Override
public List<QualifiedObjectName> listViews(Session session, QualifiedTablePrefix prefix)
{
requireNonNull(prefix, "prefix is null");
String schemaNameOrNull = prefix.getSchemaName().orElse(null);
Set<QualifiedObjectName> views = new LinkedHashSet<>();
for (ConnectorEntry entry : allConnectorsFor(prefix.getCatalogName())) {
ConnectorMetadata metadata = entry.getMetadata(session);
ConnectorSession connectorSession = session.toConnectorSession(entry.getCatalog());
for (QualifiedObjectName tableName : transform(metadata.listViews(connectorSession, schemaNameOrNull), convertFromSchemaTableName(prefix.getCatalogName()))) {
views.add(tableName);
}
}
return ImmutableList.copyOf(views);
}
示例10: analyzeExpressionsWithSymbols
import com.facebook.presto.Session; //导入依赖的package包/类
public static ExpressionAnalysis analyzeExpressionsWithSymbols(
Session session,
Metadata metadata,
SqlParser sqlParser,
Map<Symbol, Type> types,
Iterable<? extends Expression> expressions)
{
List<Field> fields = DependencyExtractor.extractUnique(expressions).stream()
.map(symbol -> {
Type type = types.get(symbol);
checkArgument(type != null, "No type for symbol %s", symbol);
return Field.newUnqualified(symbol.getName(), type);
})
.collect(toImmutableList());
return analyzeExpressions(session, metadata, sqlParser, new RelationType(fields), expressions);
}
示例11: translate
import com.facebook.presto.Session; //导入依赖的package包/类
public static RowExpression translate(
Expression expression,
FunctionKind functionKind,
IdentityHashMap<Expression, Type> types,
FunctionRegistry functionRegistry,
TypeManager typeManager,
Session session,
boolean optimize)
{
RowExpression result = new Visitor(functionKind, types, typeManager, session.getTimeZoneKey()).process(expression, null);
requireNonNull(result, "translated expression is null");
if (optimize) {
ExpressionOptimizer optimizer = new ExpressionOptimizer(functionRegistry, typeManager, session);
return optimizer.optimize(result);
}
return result;
}
示例12: Query
import com.facebook.presto.Session; //导入依赖的package包/类
public Query(Session session,
String query,
QueryManager queryManager,
ExchangeClient exchangeClient)
{
requireNonNull(session, "session is null");
requireNonNull(query, "query is null");
requireNonNull(queryManager, "queryManager is null");
requireNonNull(exchangeClient, "exchangeClient is null");
this.session = session;
this.queryManager = queryManager;
QueryInfo queryInfo = queryManager.createQuery(session, query);
queryId = queryInfo.getQueryId();
this.exchangeClient = exchangeClient;
}
示例13: execute
import com.facebook.presto.Session; //导入依赖的package包/类
@Override
public CompletableFuture<?> execute(RenameTable statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine)
{
Session session = stateMachine.getSession();
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getSource());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
if (!tableHandle.isPresent()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
QualifiedObjectName target = createQualifiedObjectName(session, statement, statement.getTarget());
if (!metadata.getCatalogNames().containsKey(target.getCatalogName())) {
throw new SemanticException(MISSING_CATALOG, statement, "Target catalog '%s' does not exist", target.getCatalogName());
}
if (metadata.getTableHandle(session, target).isPresent()) {
throw new SemanticException(TABLE_ALREADY_EXISTS, statement, "Target table '%s' already exists", target);
}
if (!tableName.getCatalogName().equals(target.getCatalogName())) {
throw new SemanticException(NOT_SUPPORTED, statement, "Table rename across catalogs is not supported");
}
accessControl.checkCanRenameTable(session.getRequiredTransactionId(), session.getIdentity(), tableName, target);
metadata.renameTable(session, tableHandle.get(), target);
return completedFuture(null);
}
示例14: createQuery
import com.facebook.presto.Session; //导入依赖的package包/类
@POST
@Produces(MediaType.APPLICATION_JSON)
public Response createQuery(String query, @Context HttpServletRequest servletRequest)
{
assertRequest(!isNullOrEmpty(query), "SQL query is empty");
Session session = createSessionForRequest(servletRequest, accessControl, sessionPropertyManager, queryIdGenerator.createNextQueryId());
ClientSession clientSession = session.toClientSession(serverUri(), false, new Duration(2, MINUTES));
StatementClient client = new StatementClient(httpClient, queryResultsCodec, clientSession, query);
List<Column> columns = getColumns(client);
Iterator<List<Object>> iterator = flatten(new ResultsPageIterator(client));
SimpleQueryResults results = new SimpleQueryResults(columns, iterator);
return Response.ok(results, MediaType.APPLICATION_JSON_TYPE).build();
}
示例15: interpretedFilterProject
import com.facebook.presto.Session; //导入依赖的package包/类
private Operator interpretedFilterProject(Expression filter, Expression projection, Session session)
{
FilterFunction filterFunction = new InterpretedFilterFunction(
filter,
SYMBOL_TYPES,
INPUT_MAPPING,
metadata,
SQL_PARSER,
session
);
ProjectionFunction projectionFunction = new InterpretedProjectionFunction(
projection,
SYMBOL_TYPES,
INPUT_MAPPING,
metadata,
SQL_PARSER,
session
);
OperatorFactory operatorFactory = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), new GenericPageProcessor(filterFunction, ImmutableList.of(projectionFunction)), toTypes(
ImmutableList.of(projectionFunction)));
return operatorFactory.createOperator(createDriverContext(session));
}