本文整理汇总了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);
}
}