Skip to content

Commit

Permalink
[+]增加索引模块 (#13)
Browse files Browse the repository at this point in the history
* 增加错误基类、简单的记录接口

* 增加.gitignore

* 完成记录的mock

* 增加记录接口的简易单元测试

* 引入Slf4j、log4j、jbbp外部库

* [+]add table mock and unit test

* 增加Travis配置

* fix: transform java14 to java11

* 更新Gradle配置以允许Scan ToS

* 删除冗余Travis配置

* README增加Travis Badge

* 增加UTF-8 gradle配置

* 对于数据项管理的mock和测试部分

* 修改测试用例的文件名

* index mock

* 增加事务的Mock

* testPage

* index mock plus test

* 对于数据项管理的mock和测试部分的修改

* testPage1.01

* dataitem模块修改建议

* 修正编码风格

* 对于数据项管理的mock和测试部分

* 对于数据项管理的mock和测试部分

* Index审计、修改建议

* 增加JBBP的使用示例

* page模块审计、修改建议

* 删除table模块,更改record模块

* recovery模块审计

* transaction模块审计

* 对于日志恢复的接口和测试

* 完善事务模块接口

* testPage1.02

* testPage1.03

* 复审recovery,tx

* 格式化代码

* 更新README

* 修改异常名称

* 修正编译失败

* 表创建、表头解析以及页头解析

* 索引审计修改

* RumbaseException增加错误原因

* 完善事务模块接口,增加事务模块测试用例

* 修正事务接口

* 修正事务接口

* 测试用例修改

* B+树索引,没有flush,没有锁,用synchronized并发也有小问题

* 改进测试用例

* synchronized修改

* 加了pin和unpin,听从lmx建议取消了root页作为成员

* 加了flush,完善了pin和unpin,添加了相对更为复杂的并发测试,由于mock的限制,flush和pin功能并不能得到良好的保证

* 修正、改进单元测试

* 缩小单元测试规模,解决文件冲突

Co-authored-by: Kevin Axel Manjaro <kevinaxel@163.com>
Co-authored-by: Kevin Axel <41867249+KveinAxel@users.noreply.github.com>
Co-authored-by: xiaoxineryi <529086017@qq.com>
Co-authored-by: DctorWei1314 <61504793+DctorWei1314@users.noreply.github.com>
Co-authored-by: Criterionist <1229089076@qq.com>
Co-authored-by: XuanLaoYee <1115810634@qq.com>
  • Loading branch information
7 people authored Jan 15, 2021
1 parent 3470fc9 commit fd4f7a5
Show file tree
Hide file tree
Showing 10 changed files with 1,749 additions and 45 deletions.
33 changes: 24 additions & 9 deletions src/main/java/net/kaaass/rumbase/index/Index.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package net.kaaass.rumbase.index;

import net.kaaass.rumbase.index.btree.BPlusTreeIndex;
import net.kaaass.rumbase.index.exception.IndexAlreadyExistException;
import net.kaaass.rumbase.index.exception.IndexNotFoundException;
import net.kaaass.rumbase.index.mock.MockBtreeIndex;
import net.kaaass.rumbase.page.Page;
import net.kaaass.rumbase.page.PageManager;
import net.kaaass.rumbase.page.PageStorage;
import net.kaaass.rumbase.page.exception.FileException;

import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand All @@ -23,10 +31,16 @@ public interface Index extends Iterable<Pair> {
* @throws IndexNotFoundException
*/
static Index getIndex(String indexFileName) throws IndexNotFoundException {
if (MockBtreeIndex.MOCK_BTREE_INDEX_MAP.get(indexFileName) == null) {
throw new IndexNotFoundException(1);
}
return MockBtreeIndex.MOCK_BTREE_INDEX_MAP.get(indexFileName);
if (BPlusTreeIndex.B_PLUS_TREE_INDEX_MAP.get(indexFileName) != null) {
return BPlusTreeIndex.B_PLUS_TREE_INDEX_MAP.get(indexFileName);
} else {
BPlusTreeIndex bPlusTreeIndex = new BPlusTreeIndex(indexFileName);
if (!bPlusTreeIndex.isIndexedFile()) {
throw new IndexNotFoundException(1);
}
BPlusTreeIndex.B_PLUS_TREE_INDEX_MAP.put(indexFileName, bPlusTreeIndex);
return bPlusTreeIndex;
}
}

/**
Expand All @@ -36,7 +50,7 @@ static Index getIndex(String indexFileName) throws IndexNotFoundException {
* @return
*/
static boolean exists(String indexFileName) {
return MockBtreeIndex.MOCK_BTREE_INDEX_MAP.get(indexFileName) != null;
return new File(indexFileName).exists();
}

/**
Expand All @@ -47,12 +61,13 @@ static boolean exists(String indexFileName) {
* @throws IndexAlreadyExistException
*/
static Index createEmptyIndex(String indexFileName) throws IndexAlreadyExistException {
if (MockBtreeIndex.MOCK_BTREE_INDEX_MAP.get(indexFileName) == null) {
MockBtreeIndex.MOCK_BTREE_INDEX_MAP.put(indexFileName, new MockBtreeIndex());
} else {
BPlusTreeIndex bPlusTreeIndex = new BPlusTreeIndex(indexFileName);
if (bPlusTreeIndex.isIndexedFile()) {
throw new IndexAlreadyExistException(1);
}
return MockBtreeIndex.MOCK_BTREE_INDEX_MAP.get(indexFileName);
bPlusTreeIndex.initPage();
BPlusTreeIndex.B_PLUS_TREE_INDEX_MAP.put(indexFileName, bPlusTreeIndex);
return bPlusTreeIndex;
}

/**
Expand Down
Loading

0 comments on commit fd4f7a5

Please sign in to comment.