Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3fc1302
style: remove unused using
Grey-Wind Dec 21, 2024
e405fca
docs: change some comments
Grey-Wind Dec 21, 2024
f0f43e8
docs: add "How To Use" file
Grey-Wind Dec 22, 2024
9a0aa6c
写三个新方法用于读取不同大小的文件文件
Grey-Wind Dec 23, 2024
21800da
统一传参
Grey-Wind Dec 23, 2024
5cb8fe1
扩大缓存
Grey-Wind Dec 23, 2024
fa35dad
加入自动readfile判断
Grey-Wind Dec 23, 2024
9750411
删除无用代码
Grey-Wind Dec 24, 2024
ecc0291
移除对旧版本的支持
Grey-Wind Dec 24, 2024
c8e9a4d
优化读取代码
Grey-Wind Dec 24, 2024
692f409
优化测试代码
Grey-Wind Dec 24, 2024
41b856e
删除无法使用的测试代码
Grey-Wind Dec 24, 2024
097b1ef
优化读取代码
Grey-Wind Dec 24, 2024
364a659
优化测试代码
Grey-Wind Dec 24, 2024
d815c53
重命名文件
Grey-Wind Dec 24, 2024
a66e61e
快速缓存支持
Grey-Wind Dec 27, 2024
80eeca3
更新readme
Grey-Wind Dec 27, 2024
4920f4e
更新版本号
Grey-Wind Dec 27, 2024
9c48a8b
feat: 使用接口
Grey-Wind Dec 27, 2024
a218cc1
refactor: 代码略微优化
Grey-Wind Dec 27, 2024
870ca7f
docs: 更新版本号
Grey-Wind Dec 27, 2024
3449d16
docs: 调整打包设置
Grey-Wind Dec 27, 2024
54268c9
feat: 尝试使用更快的并发词典
Grey-Wind Dec 27, 2024
dd32742
Merge branch 'main' into v1.0.0
Grey-Wind Dec 27, 2024
510cbf4
refactor: 使用抽象类来过渡接口与实现
Grey-Wind Dec 28, 2024
d12e130
docs: 添加更新日志
Grey-Wind Dec 28, 2024
9b48b27
Merge branch 'v1.0.0' of https://github.com/Grey-Wind/TYLDDB-CSharp i…
Grey-Wind Dec 28, 2024
88c56c4
Merge branch 'main' into v1.0.0
Grey-Wind Dec 28, 2024
8a1047d
docs: 修改版权声明
Grey-Wind Dec 28, 2024
be42d7a
docs: 修正版权许可名称
Grey-Wind Dec 28, 2024
42cf92d
docs: 删除旧的发行日志
Grey-Wind Dec 28, 2024
91a965f
docs: 优化注释
Grey-Wind Dec 28, 2024
70213e7
docs: 更新版本号
Grey-Wind Dec 28, 2024
4cdb916
test: 设置单独的类来进行时间测试,而不是很多一样的代码
Grey-Wind Dec 28, 2024
ddbb9ba
feat: 添加写入文件的代码
Grey-Wind Dec 28, 2024
0a42304
test: 写入文件的测试代码
Grey-Wind Dec 28, 2024
c91cbf4
refactor: 简化using
Grey-Wind Dec 29, 2024
c04c3aa
feat: parser
Grey-Wind Dec 29, 2024
9f2c010
feat: rewrite parser
Grey-Wind Dec 29, 2024
47ab038
docs: update release notes
Grey-Wind Dec 29, 2024
104d9de
Merge branch 'main' into v1.0.0
Grey-Wind Dec 29, 2024
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
11 changes: 4 additions & 7 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
BSD 3-Clause License
BSD 3-Clause License (Modified)

Copyright (c) 2024, Tsing Yi Local Distributed Database

Redistribution and use in source and binary forms, with or without
Redistribution and use in binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
1. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
2. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

Expand Down
48 changes: 48 additions & 0 deletions LICENSE_CN
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
BSD 3-Clause License (修改版)

Copyright (c) 2024, Tsing Yi Local Distributed Database

在满足以下条件的情况下,允许以二进制形式重新分发和使用,无论是否进行修改:

1. 以二进制形式重新分发必须在文件和/或随分发提供的其他材料中复制上述版权声明、本
条件列表和以下免责声明。

2. 未经事先书面许可,不得使用版权所有者的名字或贡献者的名字来支持或推广源自本软件
的产品。

3. 以下子条件针对所有中国大陆公司,内部所有国家均指中国大陆:

3.1 不得将本软件用于任何与国家法律、法规和政策相抵触的活动。

3.2 不得将本软件用于任何可能损害国家安全、社会公共利益或他人合法权益的活动。

3.3 不得将本软件用于任何可能侵犯他人知识产权的活动。

3.4 不得将本软件用于任何可能违反国家法律法规的活动。

3.5 不得将本软件用于任何可能损害国家信息安全的活动。

3.6 不得将本软件用于任何可能损害国家政治稳定的活动。

3.7 不得将本软件用于任何可能损害国家经济利益的活动。

3.8 不得将本软件用于任何可能损害国家文化利益的活动。

3.9 不得将本软件用于任何可能损害国家形象的活动。

3.10 不得将本软件用于任何可能损害国家荣誉的活动。

3.11 不得将本软件用于任何可能损害国家尊严的活动。

3.12 不得在未经书面许可的情况下将该程序商用。

3.13 由于该程序造成的损失本程序作者与团队概不负责。

3.14 未经书面许可禁止将本项目代码商用。

本软件由版权持有人和贡献者“按原样”提供,不承担任何明示或暗示的保证,包括但不限于对
适销性和适合特定目的的暗示保证。在任何情况下,版权持有人或贡献者均不对任何直接、间
接、附带、特殊、惩戒性或后果性损害(包括但不限于,购买替代商品或服务;损失:失去使用
、数据或利润;(或业务中断),无论如何造成的,以及根据任何责任理论,无论是合同责任,
严格责任,还是侵权行为(包括疏忽或其他),即使被告知该等损害的可能性,也会因使用本
软件而以任何方式产生。
21 changes: 21 additions & 0 deletions TYLDDB-CSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TYLDDB.Utils.FastCache.Test
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{95BC8FAF-AB03-44A3-A7E7-8E42FA7138E3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TYLDDB.Utils.Writer.Test", "TYLDDB.Utils.Writer.Test\TYLDDB.Utils.Writer.Test.csproj", "{1BA4CC53-078F-4943-B8EF-A522DA9E5060}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimeRecord", "TimeRecord\TimeRecord.csproj", "{F95CF6BC-2255-47F8-AAB3-B7812BB2894D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TYLDDB.Parser.Test", "TYLDDB.Parser.Test\TYLDDB.Parser.Test.csproj", "{0B96CCF3-16C7-4B18-9D07-A19D5D8E9641}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -34,13 +40,28 @@ Global
{A58C0A6B-9BD4-4B29-9B5F-5FDFB849D23B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A58C0A6B-9BD4-4B29-9B5F-5FDFB849D23B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A58C0A6B-9BD4-4B29-9B5F-5FDFB849D23B}.Release|Any CPU.Build.0 = Release|Any CPU
{1BA4CC53-078F-4943-B8EF-A522DA9E5060}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1BA4CC53-078F-4943-B8EF-A522DA9E5060}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BA4CC53-078F-4943-B8EF-A522DA9E5060}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BA4CC53-078F-4943-B8EF-A522DA9E5060}.Release|Any CPU.Build.0 = Release|Any CPU
{F95CF6BC-2255-47F8-AAB3-B7812BB2894D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F95CF6BC-2255-47F8-AAB3-B7812BB2894D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F95CF6BC-2255-47F8-AAB3-B7812BB2894D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F95CF6BC-2255-47F8-AAB3-B7812BB2894D}.Release|Any CPU.Build.0 = Release|Any CPU
{0B96CCF3-16C7-4B18-9D07-A19D5D8E9641}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B96CCF3-16C7-4B18-9D07-A19D5D8E9641}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B96CCF3-16C7-4B18-9D07-A19D5D8E9641}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B96CCF3-16C7-4B18-9D07-A19D5D8E9641}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{FDFD566C-CB13-43EB-970E-0EC0A21E36C0} = {95BC8FAF-AB03-44A3-A7E7-8E42FA7138E3}
{A58C0A6B-9BD4-4B29-9B5F-5FDFB849D23B} = {95BC8FAF-AB03-44A3-A7E7-8E42FA7138E3}
{1BA4CC53-078F-4943-B8EF-A522DA9E5060} = {95BC8FAF-AB03-44A3-A7E7-8E42FA7138E3}
{F95CF6BC-2255-47F8-AAB3-B7812BB2894D} = {95BC8FAF-AB03-44A3-A7E7-8E42FA7138E3}
{0B96CCF3-16C7-4B18-9D07-A19D5D8E9641} = {95BC8FAF-AB03-44A3-A7E7-8E42FA7138E3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {19390089-354C-41AD-AF7D-9FB3998A88EA}
Expand Down
33 changes: 33 additions & 0 deletions TYLDDB.Parser.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using TimeRecord;
using TYLDDB.Parser;

string content = @"
string::""str_name""=""name1"";
int::""int_value""=""123"";
short::""short_value""=""32767"";
long::""long_value""=""2147483647"";
float::""float_value""=""3.14f"";
double::""double_value""=""3.141592653589793"";
boolean::""bool""=""true"";
char::""char_value""=""127"";
decimal::decima_value = 19.99m"";
internaldb::""db_name""={};
";

var parser = new Parser();
var time = new HighPrecisionTimer();
time.Start();
// 调用 Parse 方法进行解析
var result = Parser.ParseString(content);
time.Stop();
// 输出找到的所有键值对
if (result.Count > 0)
{
foreach (var entry in result)
{
Console.WriteLine($"{entry.Key}: {entry.Value}");
}
}

Console.WriteLine($"Time: {time.ElapsedMilliseconds()}ms");
Console.ReadLine();
15 changes: 15 additions & 0 deletions TYLDDB.Parser.Test/TYLDDB.Parser.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\TimeRecord\TimeRecord.csproj" />
<ProjectReference Include="..\TYLDDB\TYLDDB.csproj" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions TYLDDB.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using TYLDDB;
using TYLDDB.Test;
using TimeRecord;
using TYLDDB;

string dbFilePath = "./example.lddb";

///////////////////////////////////////////////////////////////////////////////////////////////////////// 实例化
LDDB lddb = new LDDB();
var lddb = new LDDB();

///////////////////////////////////////////////////////////////////////////////////////////////////////// 读取文件
HighPrecisionTimer readDbTimer = new(); // 从发起读取文件到成功读取的总时间
Expand Down
1 change: 1 addition & 0 deletions TYLDDB.Test/TYLDDB.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\TimeRecord\TimeRecord.csproj" />
<ProjectReference Include="..\TYLDDB\TYLDDB.csproj" />
</ItemGroup>

Expand Down
14 changes: 7 additions & 7 deletions TYLDDB.Test/example.lddb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
database1::{
string::"str_name"="name1";
int::"int_value"="123"
short::"short_value"="32767"
int::"int_value"="123";
short::"short_value"="32767";
long::"long_value"="2147483647";
float::"float_value"="3.14f"
double::"double_value"="3.141592653589793"
boolean::"bool"="true"
char::"char_value"="127"
decimal::decima_value = 19.99m"
float::"float_value"="3.14f";
double::"double_value"="3.141592653589793";
boolean::"bool"="true";
char::"char_value"="127";
decimal::decima_value = 19.99m";
internaldb::"db_name"={};
distributeddb::"distributed_db_name"="./example.lddb";
};
Expand Down
44 changes: 0 additions & 44 deletions TYLDDB.Utils.FastCache.Test/HighPrecisionTimer.cs

This file was deleted.

6 changes: 3 additions & 3 deletions TYLDDB.Utils.FastCache.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TimeRecord;
using TYLDDB.Utils.FastCache;
using TYLDDB.Utils.FastCache.Test;

Console.WriteLine("基于信号量的缓存读写运行");
SemaphoreSlimDefault();
Expand All @@ -21,7 +21,7 @@ static async void SemaphoreSlimDefault()
var getAllCacheTime = new HighPrecisionTimer();
var getAllCacheAsyncTime = new HighPrecisionTimer();

ICache cache = new SemaphoreThreadLock();
var cache = new SemaphoreThreadLock();

setTime.Start();
cache.Set("TESTKEY1", "TESTVALUE1");
Expand Down Expand Up @@ -91,7 +91,7 @@ static async void ConcurrentDictionary()
var getAllCacheTime = new HighPrecisionTimer();
var getAllCacheAsyncTime = new HighPrecisionTimer();

ICache cache = new ConcurrentDictionary();
var cache = new ConcurrentDictionary();

setTime.Start();
cache.Set("TESTKEY1", "TESTVALUE1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\TimeRecord\TimeRecord.csproj" />
<ProjectReference Include="..\TYLDDB\TYLDDB.csproj" />
</ItemGroup>

Expand Down
37 changes: 37 additions & 0 deletions TYLDDB.Utils.Writer.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using TimeRecord;
using TYLDDB.Utils;

string largeString = new('A', 1);
string syncFilePath = "sync.txt";
string asyncFilePath = "async.txt";
string syncChunkFilePath = "sync-chunk.txt";
string asyncChunkFilePath = "async-chunk.txt";

var syncTime = new HighPrecisionTimer();
var asyncTime = new HighPrecisionTimer();
var syncChunkTime = new HighPrecisionTimer();
var asyncChunkTime = new HighPrecisionTimer();

syncTime.Start();
Writer.WriteStringToFile(syncFilePath, largeString);
syncTime.Stop();

asyncTime.Start();
await Writer.WriteStringToFileAsync(asyncFilePath, largeString);
asyncTime.Stop();

syncChunkTime.Start();
Writer.WriteStringToFileInChunks(syncChunkFilePath, largeString);
syncChunkTime.Stop();

asyncChunkTime.Start();
await Writer.WriteStringToFileInChunksAsync(asyncChunkFilePath, largeString);
asyncChunkTime.Stop();

Console.WriteLine("测试结果:");
Console.WriteLine($"同步写入:{syncTime.ElapsedMilliseconds()}ms");
Console.WriteLine($"异步写入:{asyncTime.ElapsedMilliseconds()}ms");
Console.WriteLine($"同步分块写入:{syncChunkTime.ElapsedMilliseconds()}ms");
Console.WriteLine($"异步分块写入:{asyncChunkTime.ElapsedMilliseconds()}ms");

Console.ReadLine();
15 changes: 15 additions & 0 deletions TYLDDB.Utils.Writer.Test/TYLDDB.Utils.Writer.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\TimeRecord\TimeRecord.csproj" />
<ProjectReference Include="..\TYLDDB\TYLDDB.csproj" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions TYLDDB/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 3-Clause License (Modified)

Copyright (c) 2024, Tsing Yi Local Distributed Database

Redistribution and use in binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

2. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading
Loading