Skip to content

Commit

Permalink
fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
924060929 committed Jul 16, 2024
1 parent 8cce207 commit e1b824a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void tryAddFeSqlCache(ConnectContext connectContext, String sql) {

SqlCacheContext sqlCacheContext = sqlCacheContextOpt.get();
UserIdentity currentUserIdentity = connectContext.getCurrentUserIdentity();
String key = sqlCacheContext.cacheKeyType == CacheKeyType.SQL
String key = sqlCacheContext.getCacheKeyType() == CacheKeyType.SQL
? currentUserIdentity.toString() + ":" + sql.trim()
: currentUserIdentity.toString() + ":" + DebugUtil.printId(sqlCacheContext.getOrComputeCacheKeyMd5());
if (sqlCaches.getIfPresent(key) == null && sqlCacheContext.getOrComputeCacheKeyMd5() != null
Expand All @@ -147,7 +147,7 @@ public void tryAddBeCache(ConnectContext connectContext, String sql, CacheAnalyz
}
SqlCacheContext sqlCacheContext = sqlCacheContextOpt.get();
UserIdentity currentUserIdentity = connectContext.getCurrentUserIdentity();
String key = sqlCacheContext.cacheKeyType == CacheKeyType.SQL
String key = sqlCacheContext.getCacheKeyType() == CacheKeyType.SQL
? currentUserIdentity.toString() + ":" + sql.trim()
: currentUserIdentity.toString() + ":" + DebugUtil.printId(sqlCacheContext.getOrComputeCacheKeyMd5());
if (sqlCaches.getIfPresent(key) == null && sqlCacheContext.getOrComputeCacheKeyMd5() != null) {
Expand Down Expand Up @@ -188,7 +188,7 @@ public Optional<LogicalSqlCache> tryParseSql(ConnectContext connectContext, Stri
// already exist cache in the fe, but the variable is different to this query,
// we should create another cache context in fe, use another cache key
connectContext.getStatementContext()
.getSqlCacheContext().ifPresent(ctx -> ctx.cacheKeyType = CacheKeyType.MD5);
.getSqlCacheContext().ifPresent(ctx -> ctx.setCacheKeyType(CacheKeyType.MD5));

if (sqlCacheContextWithVariable != null) {
return tryParseSqlWithoutCheckVariable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class SqlCacheContext {
private volatile PUniqueId cacheKeyMd5;
private volatile ResultSet resultSetInFe;

public volatile CacheKeyType cacheKeyType = CacheKeyType.SQL;
private volatile CacheKeyType cacheKeyType = CacheKeyType.SQL;

public SqlCacheContext(UserIdentity userIdentity, TUniqueId queryId) {
this.userIdentity = Objects.requireNonNull(userIdentity, "userIdentity cannot be null");
Expand Down Expand Up @@ -394,6 +394,14 @@ public void setResultSetInFe(ResultSet resultSetInFe) {
this.resultSetInFe = resultSetInFe;
}

public CacheKeyType getCacheKeyType() {
return cacheKeyType;
}

public void setCacheKeyType(CacheKeyType cacheKeyType) {
this.cacheKeyType = cacheKeyType;
}

/** FullTableName */
@lombok.Data
@lombok.AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void executeQuery(MysqlCommand mysqlCommand, String originStmt) throws Ex
Optional<SqlCacheContext> sqlCacheContext = ConnectContext.get()
.getStatementContext().getSqlCacheContext();
if (sqlCacheContext.isPresent()) {
cacheKeyType = sqlCacheContext.get().cacheKeyType;
cacheKeyType = sqlCacheContext.get().getCacheKeyType();
}
if (cachedStmts != null) {
stmts = cachedStmts;
Expand Down Expand Up @@ -378,7 +378,7 @@ public void executeQuery(MysqlCommand mysqlCommand, String originStmt) throws Ex
if (cacheKeyType != null) {
SqlCacheContext sqlCacheContext =
executor.getContext().getStatementContext().getSqlCacheContext().get();
sqlCacheContext.cacheKeyType = cacheKeyType;
sqlCacheContext.setCacheKeyType(cacheKeyType);
}

try {
Expand Down

0 comments on commit e1b824a

Please sign in to comment.