Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed Aug 9, 2023
1 parent 77d3d4e commit f7cac46
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
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 @@ -81,16 +82,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.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 @@ -103,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 @@ -78,6 +78,9 @@ public void copyRowBatch(RowBatch rowBatch) {
if (rowBatchBuilder == null) {
rowBatchBuilder = new RowBatchBuilder(CacheAnalyzer.CacheMode.Sql);
}
if (!super.checkRowLimit()) {
return;
}
rowBatchBuilder.copyRowData(rowBatch);
}

Expand Down

0 comments on commit f7cac46

Please sign in to comment.