Skip to content

Commit

Permalink
feat: add insert_memory_limit option
Browse files Browse the repository at this point in the history
  • Loading branch information
4paradigm committed Nov 30, 2023
1 parent c36849e commit 857cfd6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ public class SdkOption {
private int glogLevel = 0;
private String glogDir = "";
private int maxSqlCacheSize = 50;
private int insertMemoryUsageLimit = 0; // [0-100], the default value 0 means unlimited

private void buildBaseOptions(BasicRouterOptions opt) {
opt.setEnable_debug(getEnableDebug());
opt.setRequest_timeout(getRequestTimeout());
opt.setGlog_level(getGlogLevel());
opt.setGlog_dir(getGlogDir());
opt.setMax_sql_cache_size(getMaxSqlCacheSize());
opt.setInsert_memory_usage_limit(getInsertMemoryUsageLimit());
}

public SQLRouterOptions buildSQLRouterOptions() throws SqlException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public OpenmldbDataSingleWriter(OpenmldbWriteConfig config, int partitionId, lon
SdkOption option = new SdkOption();
option.setZkCluster(config.zkCluster);
option.setZkPath(config.zkPath);
option.setInsertMemoryUsageLimit(config.memoryLimit);
SqlClusterExecutor executor = new SqlClusterExecutor(option);
String dbName = config.dbName;
String tableName = config.tableName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@
// Must serializable
public class OpenmldbWriteConfig implements Serializable {
public final String dbName, tableName, zkCluster, zkPath, writerType;
public final int insertMemoryUsageLimit;

public OpenmldbWriteConfig(String dbName, String tableName, SdkOption option, String writerType) {
this.dbName = dbName;
this.tableName = tableName;
this.zkCluster = option.getZkCluster();
this.zkPath = option.getZkPath();
this.writerType = writerType;
this.insertMemoryUsageLimit = option.getInsertMemoryUsageLimit();
// TODO(hw): other configs in SdkOption
}
}
1 change: 1 addition & 0 deletions src/sdk/sql_router.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ struct BasicRouterOptions {
int glog_level = 0;
// empty means to stderr
std::string glog_dir = "";
int insert_memory_usage_limit = 0;
};

struct SQLRouterOptions : BasicRouterOptions {
Expand Down

0 comments on commit 857cfd6

Please sign in to comment.