本文整理匯總了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);
}
示例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);
}
示例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);
}
}