-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 将接口、mock改成普通类 * 将接口、mock改成普通类 * 使用访问者模式替代原先的switch匹配 * 去除visitor, 重构表管理 * 去除visitor, 重构表管理 * 重写jbbp解析方法,增加测试 * 增加表配置信息操作 * 增加表加载测试 * 增加系统表和测试 * 完成Select语句的语法树定义 * 完成Insert语句的语法树定义 * 完成Update语句的语法树定义 * 完成Delete语句的语法树定义 * 完成Create table语句的语法树定义 * 完成Create index语句的语法树定义 * 格式化代码 * 增加空字段,增加field的方法 * 增加query模块 * 更新测试用例的序列化格式 * 修复空值Condition * 增加创建索引测试 * 更改测试文件路径 * 完成服务器程序基本框架 * 字符串解析增加单引号 * 完成echo服务器 * 增加增删改、创建表的执行测试 * 更改测试路径 * 实现访问者模式处理sql语句 * 改进select语句解析 * 完善语句解析的返回值,使用泛型 * 完成语句执行逻辑 * 增加select测试 * 修复delete测试 * 实现指令解析,完成当前所有指令运行的测试 * 将mock换为RecordManager * 完成自动提交 * 完成todo/fixme * 增加获取所有文件路径的api * 修正测试文件路径 * 增加field加载时的索引重建 * 修复未抛出的异常 * 修正执行的系列错误 * 修正自动提交事务上下文更改的问题 * 修正ci重复进行测试 * 修复投影获得空列表的bug * 修复列未空的插入请求 * 修正select输出格式 * 修复metadata写入bug * unpin遗漏 * 增加CreateIndex时的表结构序列化 * 修复物理记录查找问题 * 修复错误@nonnull的问题 * 更新dummy * 修正一系列select解析问题 * 修正between计算问题 * 增加插入列检查 * record提供路径名 * 更改文件目录 * 创建数据文件夹 * 增加flush、exec语句 * 修正null值错误处理 * 通过记录来保存数据字典 * flush错误处理 * 修正系列问题,增加recordapi * 修正测试用例编译 * 修复metadata加载问题 * 修复metadata加载问题 * 修正一处forEach * 修复列persist标志位 * metadata加载的空指针问题 * 修改测试用例 * 修正若干错误测试用例 * 修正表模块单元测试路径 * 统一单元测试文件路径 Co-authored-by: Kevin Axel Manjaro <kevinaxel@163.com>
- Loading branch information
Showing
68 changed files
with
2,218 additions
and
866 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,4 @@ dist: trusty | |
group: edge | ||
|
||
script: | ||
- ./gradlew check | ||
- ./gradlew build --scan -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,6 @@ | |
* @author kaaass | ||
*/ | ||
public interface ISqlStatement { | ||
|
||
<T> T accept(ISqlStatementVisitor<T> visitor); | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/net/kaaass/rumbase/parse/ISqlStatementVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.kaaass.rumbase.parse; | ||
|
||
import net.kaaass.rumbase.parse.stmt.*; | ||
|
||
/** | ||
* SQL语句访问者,用于处理对应SQL语句 | ||
* | ||
* @author kaaass | ||
*/ | ||
public interface ISqlStatementVisitor<T> { | ||
|
||
T visit(SelectStatement statement); | ||
|
||
T visit(InsertStatement statement); | ||
|
||
T visit(UpdateStatement statement); | ||
|
||
T visit(DeleteStatement statement); | ||
|
||
T visit(CreateIndexStatement statement); | ||
|
||
T visit(CreateTableStatement statement); | ||
|
||
T visit(StartTransactionStatement statement); | ||
|
||
T visit(CommitStatement statement); | ||
|
||
T visit(RollbackStatement statement); | ||
|
||
T visit(ExitStatement statement); | ||
|
||
T visit(ShutdownStatement statement); | ||
|
||
T visit(FlushStatement statement); | ||
|
||
T visit(ExecStatement statement); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/net/kaaass/rumbase/parse/parser/CommandStatementParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package net.kaaass.rumbase.parse.parser; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import net.kaaass.rumbase.parse.ISqlStatement; | ||
import net.kaaass.rumbase.parse.SqlParser; | ||
import net.kaaass.rumbase.parse.exception.SqlSyntaxException; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
|
||
/** | ||
* 字符串指令解析器 | ||
* @author kaaass | ||
*/ | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class CommandStatementParser implements SqlParser.StatementParser<String> { | ||
|
||
/** | ||
* 语句解析结果的类 | ||
*/ | ||
private final Class<? extends ISqlStatement> stmtClazz; | ||
|
||
/** | ||
* 指令格式 | ||
*/ | ||
private final String command; | ||
|
||
@Override | ||
public ISqlStatement parse(String input) throws SqlSyntaxException { | ||
try { | ||
return stmtClazz.getDeclaredConstructor().newInstance(); | ||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { | ||
log.error("无法生成指令对象 {}", input, e); | ||
throw new SqlSyntaxException(3, e); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean checkStatement(String input) { | ||
// 忽略逗号 | ||
if (input.charAt(input.length() - 1) == ';') { | ||
input = input.substring(0, input.length() - 1); | ||
} | ||
return command.compareToIgnoreCase(input) == 0; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/net/kaaass/rumbase/parse/parser/command/ExecStatementParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.kaaass.rumbase.parse.parser.command; | ||
|
||
import net.kaaass.rumbase.parse.ISqlStatement; | ||
import net.kaaass.rumbase.parse.SqlParser; | ||
import net.kaaass.rumbase.parse.stmt.ExecStatement; | ||
|
||
/** | ||
* 将执行SQL文件语句解释为对应语法树 | ||
* | ||
* @author kaaass | ||
*/ | ||
public class ExecStatementParser implements SqlParser.StatementParser<String> { | ||
@Override | ||
public ISqlStatement parse(String input) { | ||
return new ExecStatement(input.substring(5).trim()); | ||
} | ||
|
||
@Override | ||
public boolean checkStatement(String input) { | ||
return input.startsWith("exec ") || input.startsWith("EXEC "); | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...se/parser/CreateIndexStatementParser.java → ...ser/jsqlp/CreateIndexStatementParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...e/parse/parser/DeleteStatementParser.java → ...e/parser/jsqlp/DeleteStatementParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.