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

修正快照的接口问题 #8

Merged
merged 68 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
06f9219
增加错误基类、简单的记录接口
kaaass Jan 1, 2021
e9fd13f
增加.gitignore
kaaass Jan 1, 2021
7e3e2b4
完成记录的mock
kaaass Jan 1, 2021
f6edd17
增加记录接口的简易单元测试
kaaass Jan 1, 2021
910fc57
Merge branch 'dev' into feature-mock
kaaass Jan 1, 2021
481bea3
引入Slf4j、log4j、jbbp外部库
kaaass Jan 1, 2021
eb3d19c
[+]add table mock and unit test
KveinAxel Jan 1, 2021
50a8ad6
Merge branch 'feature-mock' into feature-table
KveinAxel Jan 2, 2021
1776095
Merge pull request #2 from kaaass/feature-table
KveinAxel Jan 2, 2021
d8aa315
增加Travis配置
kaaass Jan 2, 2021
c89d9c0
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
kaaass Jan 2, 2021
a2d5fa2
fix: transform java14 to java11
KveinAxel Jan 2, 2021
2491186
更新Gradle配置以允许Scan ToS
kaaass Jan 2, 2021
b1b8e33
删除冗余Travis配置
kaaass Jan 2, 2021
f843d2f
README增加Travis Badge
kaaass Jan 2, 2021
8211faf
增加UTF-8 gradle配置
kaaass Jan 8, 2021
2e50aba
对于数据项管理的mock和测试部分
xwinks Jan 8, 2021
0e6bddf
修改测试用例的文件名
KveinAxel Jan 8, 2021
9240fe7
index mock
DctorWei1314 Jan 8, 2021
845c7f9
增加事务的Mock
Criterionist Jan 8, 2021
37a86d8
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
Criterionist Jan 8, 2021
642c52e
testPage
xiaoxuanNLP Jan 9, 2021
96fc8dd
Merge branch 'feature-mock' of https://github.com/kaaass/rumbase_java…
xiaoxuanNLP Jan 9, 2021
2797554
index mock plus test
DctorWei1314 Jan 9, 2021
3079b1f
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
DctorWei1314 Jan 9, 2021
be73a7d
对于数据项管理的mock和测试部分的修改
xwinks Jan 9, 2021
aa6faa7
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xwinks Jan 9, 2021
35f6267
testPage1.01
xiaoxuanNLP Jan 9, 2021
015b1d1
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xiaoxuanNLP Jan 9, 2021
4d046cc
dataitem模块修改建议
kaaass Jan 9, 2021
934e336
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
kaaass Jan 9, 2021
4f79206
dataitem模块修改建议
kaaass Jan 9, 2021
dd92f0e
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
Criterionist Jan 9, 2021
2f0874e
修正编码风格
Criterionist Jan 9, 2021
2c4cbbb
对于数据项管理的mock和测试部分
xwinks Jan 9, 2021
0242ee6
对于数据项管理的mock和测试部分
xwinks Jan 9, 2021
fd25691
对于数据项管理的mock和测试部分
xwinks Jan 9, 2021
6029610
Index审计、修改建议
kaaass Jan 9, 2021
03f8b09
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
kaaass Jan 9, 2021
019036d
增加JBBP的使用示例
kaaass Jan 9, 2021
5656c6f
page模块审计、修改建议
kaaass Jan 9, 2021
4c3e3c2
删除table模块,更改record模块
kaaass Jan 9, 2021
c381c2e
recovery模块审计
kaaass Jan 9, 2021
1fc4b5c
transaction模块审计
kaaass Jan 9, 2021
c2b5606
对于日志恢复的接口和测试
xwinks Jan 9, 2021
69845d0
完善事务模块接口
Criterionist Jan 9, 2021
4974a28
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
Criterionist Jan 9, 2021
6511024
testPage1.02
xiaoxuanNLP Jan 9, 2021
e590bf2
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xiaoxuanNLP Jan 9, 2021
7e6ccd9
testPage1.03
xiaoxuanNLP Jan 10, 2021
e50c917
复审recovery,tx
kaaass Jan 10, 2021
795ecef
格式化代码
kaaass Jan 10, 2021
26f1626
更新README
kaaass Jan 10, 2021
8fefaa0
Merge branch 'dev' into feature-mock
kaaass Jan 10, 2021
ecbe27f
修改异常名称
xwinks Jan 11, 2021
7fe37c4
修正编译失败
kaaass Jan 11, 2021
f8c5bff
Merge branch 'dev' into feature-mock
kaaass Jan 12, 2021
3aa86e3
表创建、表头解析以及页头解析
xwinks Jan 13, 2021
1cebb4a
Merge branch 'feature-dataitem' into feature-mock
xwinks Jan 13, 2021
476e115
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
xwinks Jan 13, 2021
78f7433
索引审计修改
DctorWei1314 Jan 13, 2021
39870f8
Merge remote-tracking branch 'origin/feature-mock' into feature-mock
DctorWei1314 Jan 13, 2021
5a84ca0
RumbaseException增加错误原因
kaaass Jan 13, 2021
f6a5fe0
Merge to dev
kaaass Jan 13, 2021
98da699
完善事务模块接口,增加事务模块测试用例
Criterionist Jan 13, 2021
668121e
修正事务接口
Criterionist Jan 13, 2021
a46b8c0
Merge remote-tracking branch 'origin/dev' into feature-mock
kaaass Jan 13, 2021
25930c7
修正事务接口
Criterionist Jan 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
格式化代码
  • Loading branch information
kaaass committed Jan 10, 2021
commit 795ecef0d0ca184402782c96d86af34dd01d14e3
6 changes: 3 additions & 3 deletions src/main/java/net/kaaass/rumbase/dataitem/IItemStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public interface IItemStorage {
* <p>
* 如果数据项已经存在,就将数据更新在已存在的数据项所在空间上;
* 如果数据项不存在,则以此UUID插入数据项
*</p>
* </p>
*
* @param item 数据项
* @param uuid 编号
*/
void insertItemWithUuid(byte[] item, long uuid);

/**
*
* 通过UUID查询数据项
*
* @param uuid 编号
Expand All @@ -40,7 +40,6 @@ public interface IItemStorage {
byte[] queryItemByUuid(long uuid) throws UUIDException;



/**
* 列出页中所有的记录
*
Expand All @@ -51,6 +50,7 @@ public interface IItemStorage {

/**
* 根据UUID更新数据项
*
* @param uuid 编号
* @param item 数据项
* @throws UUIDException 没有找到对应UUID的异常
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import java.util.Map;

/**
* 在创建、打开数据库时
* 在创建、打开数据库时
*
* @author kaito
*/
public class FileException extends RumbaseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import java.util.Map;

/**
* 关于Uuid的相关错误
* @author kaito
* 关于Uuid的相关错误
*
* @author kaito
*/
public class UUIDException extends RumbaseException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public class MockItemStorage implements IItemStorage {
*/
private Map<Long, byte[]> maps;
/**
* 模拟的文件头信息
* 模拟的文件头信息
*/
private byte[] meta;

/**
* 模拟的构造函数
*
* @param fileName 文件名
* @param fileName 文件名
* @param tempFreePage 当前第一个空闲页号
* @param headerUuid 头信息对应UUID
* @param headerUuid 头信息对应UUID
*/
public MockItemStorage(String fileName, int tempFreePage, long headerUuid) {
this.fileName = fileName;
Expand Down Expand Up @@ -68,7 +68,7 @@ public static IItemStorage ofFile(String fileName) {
/**
* 新建数据库,并写入表头
*
* @param fileName 文件名
* @param fileName 文件名
* @param tableHeader 表头信息
* @return 返回数据项管理器
*/
Expand All @@ -87,15 +87,15 @@ public long insertItem(byte[] item) {
}

@Override
public void insertItemWithUuid(byte[] item, long uuid){
maps.put(uuid,item);
public void insertItemWithUuid(byte[] item, long uuid) {
maps.put(uuid, item);
}

@Override
public byte[] queryItemByUuid(long uuid) throws UUIDException {
if (maps.containsKey(uuid)){
if (maps.containsKey(uuid)) {
return maps.get(uuid);
}else {
} else {
throw new UUIDException(2);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/kaaass/rumbase/page/PageStorage.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package net.kaaass.rumbase.page;

import net.kaaass.rumbase.page.exception.FileException;

/**
* 用于管理一系列连续页的存储对象,隐藏任何关于存储的物理细节
*
Expand All @@ -11,6 +9,7 @@ public interface PageStorage {

/**
* 获取该页存储中的某一页
*
* @param pageId 页号
* @return 该页页对象
*/
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/kaaass/rumbase/page/mock/MockBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,34 @@ public void put(int offset, byte[] bytes) throws BufferExeception {
try {
System.arraycopy(bytes, 0, this.byteBuffer, offset, bytes.length);
this.size--;
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
lock.unlock();
}
}

public byte[] get(int offset) {
lock.lock();
try{
try {
byte[] temp = new byte[PageManager.PAGE_SIZE];
System.arraycopy(this.byteBuffer, offset, temp, offset, PageManager.PAGE_SIZE);
return temp;
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}finally {
} finally {
lock.unlock();
}
return null;
}

public void free(int offset) {
lock.lock();
try{
try {
System.arraycopy(this.byteBuffer, offset, new byte[PageManager.PAGE_SIZE], 0, PageManager.PAGE_SIZE);
}catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}finally{
} finally {
lock.unlock();
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/net/kaaass/rumbase/page/mock/MockPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
import net.kaaass.rumbase.page.exception.FileException;
import net.kaaass.rumbase.page.exception.PageException;

import java.io.File;
import java.io.RandomAccessFile;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class MockPage implements Page {
private byte[] data;
long pageId;
Expand Down Expand Up @@ -40,7 +35,8 @@ public void patchData(int offset, byte[] data) throws PageException {
}

@Override
public void flush() throws FileException { }
public void flush() throws FileException {
}

@Override
public void pin() {
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/net/kaaass/rumbase/page/mock/MockPageStorage.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package net.kaaass.rumbase.page.mock;

import net.kaaass.rumbase.page.Page;
import net.kaaass.rumbase.page.PageStorage;
import net.kaaass.rumbase.page.PageManager;
import net.kaaass.rumbase.page.PageStorage;
import net.kaaass.rumbase.page.exception.FileException;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.*;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -25,7 +20,7 @@ public MockPageStorage(String filepath) throws FileException {
this.fakeFile = new byte[1024 * 4 * 20];
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 1024 * 4; j++) {
this.fakeFile[1024 * 4 * i + j] = (byte)i;
this.fakeFile[1024 * 4 * i + j] = (byte) i;
}
}
}
Expand All @@ -35,7 +30,7 @@ public Page get(long pageId) {
//文件会预留5页作为文件头
try {
byte[] data = new byte[PageManager.PAGE_SIZE];
System.arraycopy(fakeFile, (int) (pageId + PageManager.FILE_HEAD_SIZE)*PageManager.PAGE_SIZE, data, 0, data.length);
System.arraycopy(fakeFile, (int) (pageId + PageManager.FILE_HEAD_SIZE) * PageManager.PAGE_SIZE, data, 0, data.length);
Integer tmpId = (int) pageId;
if (pageMap.containsKey(tmpId)) {
return pageMap.get(tmpId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.kaaass.rumbase.transaction.TransactionContext;

import java.util.Optional;
import java.util.UUID;

/**
* 记录存储接口,提供由记录ID存取数据的容器
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
*/
public class RecordNotFoundException extends RumbaseException {

public static final Map<Integer, String> REASONS = new HashMap<>(){{
public static final Map<Integer, String> REASONS = new HashMap<>() {{
put(1, "物理记录不存在");
}};

/**
* 记录不存在异常
* @param subId 子错误号
*
* @param subId 子错误号
*/
public RecordNotFoundException(int subId) {
super(5001, subId, REASONS.get(subId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ static TransactionContext empty() {
/**
* 对记录加共享锁
*
* @param uuid 记录id
* @param uuid 记录id
* @param tableName 表字段
*/
void sharedLock(long uuid, String tableName);

/**
* 对记录加排他锁
*
* @param uuid 记录id
* @param uuid 记录id
* @param tableName 表字段
*/
void exclusiveLock(long uuid, String tableName);
Expand Down