Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add conf entry jdbc.storage_engine to change storage engine #555

Merged
merged 7 commits into from
Jun 5, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,12 @@ public static synchronized MysqlOptions instance() {
disallowEmpty(),
"disable"
);

public static final ConfigOption<String> STORAGE_ENGINE =
new ConfigOption<>(
"jdbc.storage_engine",
"The storage engine of backend store database, like InnoDB/MyISAM/RocksDB for MySQL.",
disallowEmpty(),
"InnoDB"
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ public Session() {
}
}

public HugeConfig config() {
return MysqlSessions.this.config();
}

public void open() throws SQLException {
if (this.conn != null && !this.conn.isClosed()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected void createTable(Session session, TableDefine tableDefine) {
}
}
sql.append("))");
sql.append(this.engine());
sql.append(this.engine(session));
sql.append(";");

LOG.debug("Create table: {}", sql);
Expand All @@ -116,8 +116,9 @@ protected void createTable(Session session, TableDefine tableDefine) {
}
}

protected String engine() {
return " ENGINE=InnoDB";
protected String engine(Session session) {
wenzhenghu marked this conversation as resolved.
Show resolved Hide resolved
String engine = session.config().get(MysqlOptions.STORAGE_ENGINE);
return " ENGINE=" + engine;
}

wenzhenghu marked this conversation as resolved.
Show resolved Hide resolved
protected void dropTable(Session session) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.baidu.hugegraph.backend.store.mysql.MysqlBackendEntry;
import com.baidu.hugegraph.backend.store.mysql.MysqlTable;
import com.baidu.hugegraph.backend.store.mysql.MysqlSessions.Session;
import com.baidu.hugegraph.type.define.HugeKeys;

public abstract class PostgresqlTable extends MysqlTable {
Expand All @@ -46,7 +47,7 @@ protected String buildTruncateTemplate() {
}

@Override
protected String engine() {
protected String engine(Session session) {
return Strings.EMPTY;
}

wenzhenghu marked this conversation as resolved.
Show resolved Hide resolved
Expand Down