當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。