Skip to content

Commit

Permalink
(cloud-merge) Support to write data into cache in cloud mode (#31934)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lchangliang authored Mar 9, 2024
1 parent 440daae commit e4d124a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions be/src/vec/sink/writer/vtablet_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ void VNodeChannel::_open_internal(bool is_incremental) {
request->set_enable_profile(_state->enable_profile());
request->set_is_incremental(is_incremental);
request->set_txn_expiration(_parent->_txn_expiration);
request->set_write_file_cache(_parent->_write_file_cache);

auto open_callback = DummyBrpcCallback<PTabletWriterOpenResult>::create_shared();
auto open_closure = AutoReleaseClosure<
Expand Down Expand Up @@ -1129,6 +1130,7 @@ Status VTabletWriter::_init(RuntimeState* state, RuntimeProfile* profile) {
_txn_id = table_sink.txn_id;
_num_replicas = table_sink.num_replicas;
_tuple_desc_id = table_sink.tuple_id;
_write_file_cache = table_sink.write_file_cache;
_schema.reset(new OlapTableSchemaParam());
RETURN_IF_ERROR(_schema->init(table_sink.schema));
_location = _pool->add(new OlapTableLocationParam(table_sink.location));
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/sink/writer/vtablet_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ class VTabletWriter final : public AsyncResultWriter {
// for non-pipeline, if close() did something, close_wait() should wait it.
bool _close_wait = false;
bool _inited = false;
bool _write_file_cache = false;

// User can change this config at runtime, avoid it being modified during query or loading process.
bool _transfer_large_data_by_brpc = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ public void init(TUniqueId loadId, long txnId, long dbId, long loadChannelTimeou
tSink.setBaseSchemaVersion(dstTable.getBaseSchemaVersion());
tSink.setLoadChannelTimeoutS(loadChannelTimeoutS);
tSink.setSendBatchParallelism(sendBatchParallelism);
tSink.setWriteFileCache(ConnectContext.get() != null
? !ConnectContext.get().getSessionVariable().isDisableFileCache()
: false);
this.isStrictMode = isStrictMode;
this.txnId = txnId;
if (loadToSingleTablet && !(dstTable.getDefaultDistributionInfo() instanceof RandomDistributionInfo)) {
Expand Down
16 changes: 16 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ public class SessionVariable implements Serializable, Writable {

public static final String ENABLE_FILE_CACHE = "enable_file_cache";

public static final String DISABLE_FILE_CACHE = "disable_file_cache";

public static final String FILE_CACHE_BASE_PATH = "file_cache_base_path";

public static final String ENABLE_INVERTED_INDEX_QUERY = "enable_inverted_index_query";
Expand Down Expand Up @@ -1305,6 +1307,11 @@ public void setEnableLeftZigZag(boolean enableLeftZigZag) {
@VariableMgr.VarAttr(name = GROUP_BY_AND_HAVING_USE_ALIAS_FIRST)
public boolean groupByAndHavingUseAliasFirst = false;

// Whether disable block file cache. Block cache only works when FE's query options sets disableFileCache false
// along with BE's config `enable_file_cache` true
@VariableMgr.VarAttr(name = DISABLE_FILE_CACHE, needForward = true)
public boolean disableFileCache = false;

// Whether enable block file cache. Only take effect when BE config item enable_file_cache is true.
@VariableMgr.VarAttr(name = ENABLE_FILE_CACHE, needForward = true, description = {
"是否启用file cache。该变量只有在be.conf中enable_file_cache=true时才有效,"
Expand Down Expand Up @@ -2131,6 +2138,14 @@ public void setResourceGroup(String resourceGroup) {
this.resourceGroup = resourceGroup;
}

public boolean isDisableFileCache() {
return Config.isCloudMode() ? disableFileCache : false;
}

public void setDisableFileCache(boolean disableFileCache) {
this.disableFileCache = disableFileCache;
}

public boolean isDisableColocatePlan() {
return disableColocatePlan;
}
Expand Down Expand Up @@ -2982,6 +2997,7 @@ public TQueryOptions toThrift() {
tResult.setParallelScanMaxScannersCount(parallelScanMaxScannersCount);
tResult.setParallelScanMinRowsPerScanner(parallelScanMinRowsPerScanner);
tResult.setSkipBadTablet(skipBadTablet);
tResult.setDisableFileCache(disableFileCache);

return tResult;
}
Expand Down

0 comments on commit e4d124a

Please sign in to comment.