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


Java OLAPContext.setParameters方法代码示例

本文整理汇总了Java中org.apache.kylin.query.relnode.OLAPContext.setParameters方法的典型用法代码示例。如果您正苦于以下问题:Java OLAPContext.setParameters方法的具体用法?Java OLAPContext.setParameters怎么用?Java OLAPContext.setParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.kylin.query.relnode.OLAPContext的用法示例。


在下文中一共展示了OLAPContext.setParameters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: executeQuery

import org.apache.kylin.query.relnode.OLAPContext; //导入方法依赖的package包/类
protected SQLResponse executeQuery(String sql, SQLRequest sqlRequest) throws Exception {
    sql = sql.trim().replace(";", "");

    int limit = sqlRequest.getLimit();
    if (limit > 0 && !sql.toLowerCase().contains("limit")) {
        sql += (" LIMIT " + limit);
    }

    int offset = sqlRequest.getOffset();
    if (offset > 0 && !sql.toLowerCase().contains("offset")) {
        sql += (" OFFSET " + offset);
    }

    // add extra parameters into olap context, like acceptPartial
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(OLAPContext.PRM_ACCEPT_PARTIAL_RESULT, String.valueOf(sqlRequest.isAcceptPartial()));
    OLAPContext.setParameters(parameters);

    return execute(sql, sqlRequest);
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:21,代码来源:QueryService.java

示例2: setUser

import org.apache.kylin.query.relnode.OLAPContext; //导入方法依赖的package包/类
public static void setUser(String username) {
    Map<String, String> auth = new HashMap<>();
    auth.put(OLAPContext.PRM_USER_AUTHEN_INFO, username);
    OLAPContext.setParameters(auth);
}
 
开发者ID:apache,项目名称:kylin,代码行数:6,代码来源:QueryACLTestUtil.java

示例3: queryWithSqlMassage

import org.apache.kylin.query.relnode.OLAPContext; //导入方法依赖的package包/类
private SQLResponse queryWithSqlMassage(SQLRequest sqlRequest) throws Exception {
    Connection conn = null;

    try {
        conn = QueryConnection.getConnection(sqlRequest.getProject());

        String userInfo = SecurityContextHolder.getContext().getAuthentication().getName();
        QueryContext context = QueryContext.current();
        context.setUsername(userInfo);
        context.setGroups(AclPermissionUtil.getCurrentUserGroups());
        final Collection<? extends GrantedAuthority> grantedAuthorities = SecurityContextHolder.getContext()
                .getAuthentication().getAuthorities();
        for (GrantedAuthority grantedAuthority : grantedAuthorities) {
            userInfo += ",";
            userInfo += grantedAuthority.getAuthority();
        }

        SQLResponse fakeResponse = TableauInterceptor.tableauIntercept(sqlRequest.getSql());
        if (null != fakeResponse) {
            logger.debug("Return fake response, is exception? " + fakeResponse.getIsException());
            return fakeResponse;
        }

        String correctedSql = QueryUtil.massageSql(sqlRequest.getSql(), sqlRequest.getProject(),
                sqlRequest.getLimit(), sqlRequest.getOffset(), conn.getSchema());
        if (!correctedSql.equals(sqlRequest.getSql())) {
            logger.info("The corrected query: " + correctedSql);

            //CAUTION: should not change sqlRequest content!
            //sqlRequest.setSql(correctedSql);
        }
        Trace.addTimelineAnnotation("query massaged");

        // add extra parameters into olap context, like acceptPartial
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put(OLAPContext.PRM_USER_AUTHEN_INFO, userInfo);
        parameters.put(OLAPContext.PRM_ACCEPT_PARTIAL_RESULT, String.valueOf(sqlRequest.isAcceptPartial()));
        OLAPContext.setParameters(parameters);
        // force clear the query context before a new query
        OLAPContext.clearThreadLocalContexts();

        return execute(correctedSql, sqlRequest, conn);

    } finally {
        DBUtils.closeQuietly(conn);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:48,代码来源:QueryService.java


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