Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion fe/fe-common/src/main/java/org/apache/doris/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1386,9 +1386,17 @@ public class Config extends ConfigBase {
/**
* Set the maximum number of rows that can be cached
*/
@ConfField(mutable = true, masterOnly = false)
@ConfField(mutable = true, masterOnly = false, description = {"SQL/Partition Cache可以缓存的最大行数。",
"Maximum number of rows that can be cached in SQL/Partition Cache, is 3000 by default."})
public static int cache_result_max_row_count = 3000;

/**
* Set the maximum data size that can be cached
*/
@ConfField(mutable = true, masterOnly = false, description = {"SQL/Partition Cache可以缓存的最大数据大小。",
"Maximum data size of rows that can be cached in SQL/Partition Cache, is 3000 by default."})
public static int cache_result_max_data_size = 31457280; // 30M

/**
* Used to limit element num of InPredicate in delete statement.
*/
Expand Down
13 changes: 11 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/qe/cache/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public enum HitRange {
protected TUniqueId queryId;
protected SelectStmt selectStmt;
protected RowBatchBuilder rowBatchBuilder;
protected boolean disableCache = false;
protected CacheAnalyzer.CacheTable latestTable;
protected CacheProxy proxy;
protected HitRange hitRange;
Expand Down Expand Up @@ -75,12 +76,20 @@ public HitRange getHitRange() {
public abstract void updateCache();

protected boolean checkRowLimit() {
if (rowBatchBuilder == null) {
if (disableCache || rowBatchBuilder == null) {
return false;
}
if (rowBatchBuilder.getRowSize() > Config.cache_result_max_row_count) {
LOG.info("can not be cached. rowbatch size {} is more than {}", rowBatchBuilder.getRowSize(),
LOG.debug("can not be cached. rowbatch size {} is more than {}", rowBatchBuilder.getRowSize(),
Config.cache_result_max_row_count);
rowBatchBuilder.clear();
disableCache = true;
return false;
} else if (rowBatchBuilder.getDataSize() > Config.cache_result_max_data_size) {
LOG.debug("can not be cached. rowbatch data size {} is more than {}", rowBatchBuilder.getDataSize(),
Config.cache_result_max_data_size);
rowBatchBuilder.clear();
disableCache = true;
return false;
} else {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ public void copyRowBatch(RowBatch rowBatch) {
rowBatchBuilder.buildPartitionIndex(selectStmt.getResultExprs(), selectStmt.getColLabels(),
partColumn, range.buildUpdatePartitionRange());
}
if (!super.checkRowLimit()) {
return;
}
rowBatchBuilder.copyRowData(rowBatch);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ public int getRowSize() {
return rowSize;
}

public int getDataSize() {
return dataSize;
}

public RowBatchBuilder(CacheAnalyzer.CacheMode model) {
cacheMode = model;
keyIndex = 0;
Expand Down Expand Up @@ -99,6 +103,14 @@ public void copyRowData(RowBatch rowBatch) {
}
}

public void clear() {
rowList = Lists.newArrayList();
cachePartMap = new HashMap<>();
batchSize = 0;
rowSize = 0;
dataSize = 0;
}

public InternalService.PUpdateCacheRequest buildSqlUpdateRequest(
String sql, long partitionKey, long lastVersion, long lastestTime) {
if (updateRequest == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public void copyRowBatch(RowBatch rowBatch) {
if (rowBatchBuilder == null) {
rowBatchBuilder = new RowBatchBuilder(CacheAnalyzer.CacheMode.Sql);
}
if (!super.checkRowLimit()) {
return;
}
rowBatchBuilder.copyRowData(rowBatch);
}

Expand Down
Loading