当前位置: 首页>>代码示例>>Java>>正文


Java Session类代码示例

本文整理汇总了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;
}
 
开发者ID:prestodb-rocks,项目名称:presto-rest,代码行数:19,代码来源:TestSlackQueries.java

示例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;
}
 
开发者ID:prestodb-rocks,项目名称:presto-rest,代码行数:19,代码来源:TestGithubQueries.java

示例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;
}
 
开发者ID:prestodb-rocks,项目名称:presto-rest,代码行数:23,代码来源:TestTwitterQueries.java

示例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;
}
 
开发者ID:vitillo,项目名称:presto-hyperloglog,代码行数:24,代码来源:TestHyperLogLogQueries.java

示例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);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:MetadataManager.java

示例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");
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:StatementAnalyzer.java

示例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;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:RaptorBenchmarkQueryRunner.java

示例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);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:19,代码来源:QueryExplainer.java

示例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);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:17,代码来源:MetadataManager.java

示例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);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:ExpressionAnalyzer.java

示例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;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:21,代码来源:SqlToRowExpressionTranslator.java

示例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;
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:StatementResource.java

示例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);
}
 
开发者ID:y-lan,项目名称:presto,代码行数:27,代码来源:RenameTableTask.java

示例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();
}
 
开发者ID:y-lan,项目名称:presto,代码行数:18,代码来源:ExecuteResource.java

示例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));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:25,代码来源:FunctionAssertions.java


注:本文中的com.facebook.presto.Session类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。