-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcn.html
More file actions
706 lines (595 loc) · 23.8 KB
/
cn.html
File metadata and controls
706 lines (595 loc) · 23.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="keywords" content="iBoxDB,NoSQL,ORM,数据库,ACID,Java,Android,Unity,Xamarin,数据库事务,应用程序,文档数据库">
<meta name="description" content="iBoxDB 双核高性能NoSQL数据库引擎 原生支持 JAVA .NET C# Unity Android Mono Linux Windows">
<link rel="shortcut icon" href="favicon.ico" />
<link rel="bookmark" href="favicon.ico" />
<title>嵌入式NoSQL数据库 iBoxDB Java .NET ACiD 双核</title>
<link rel="stylesheet" href="index.css">
<link rel="stylesheet" href="highlight/styles/vs.css">
</head>
<body>
<!-- HEADER -->
<div id="header_wrap" class="outer" style="border-bottom-style: solid; border-bottom-width: medium; border-bottom-color: #33CC00;">
<header class="inner">
<a href="index.html"><div id="logo"></div>
<h1 id="project_title">iBoxDB</h1></a>
<h1 id="project_title_h1"> e^d = Ne^(Kd) </h1>
<h2 id="project_title_h2"><div>
cos { (1/2) ( y^(1/d) + (y^(-1/d)) ( 1 - (1-y)^(2/d) ) ) } <br>
projection { x = x*cos( a ) + k*cos( XtoK + a ) }
</h2>
<h2 id="project_tagline">双核高效应用程序数据库引擎</h2>
<div id="downloads">
<a href="iboxdb-java-csharp-embedded-nosql-database.html#nosql_download">下载数据库</a>
</div>
</header>
</div>
<!-- MAIN CONTENT -->
<div id="main_content_wrap" class="outer">
<section id="main_content" class="inner">
<!-- key words -->
<div style="width: 1px; height: 1px; overflow: hidden">
</div>
<h3>项目介绍</h3>
<p>iBoxDB 是一个高能效的应用程序数据库,提供事务支持,使用数据库表的风格存取任意结构的文档对象数据,包含无须安装配置的 JAVA 与 .NET 数据库引擎。</p>
<p>iBoxDB 提供一个优雅设计的编程接口,让应用程序无缝地与数据引擎溶为一体, 你能方便地把它发布到移动设备, 桌面设备和服务器上, 然后让它帮助你存取各种有结构的,或者无结构的数据,具备保持数据一致性的能力。</p>
<p>
双引擎数据库
<br />
支持 JAVA C# Android Unity Xamarin Mono ASP.NET Linux
</p>
<h3>特性</h3>
<ul>
<li>NoSQL 增删改查</li>
<li>键表与键值表</li>
<li>唯一或可重复的索引</li>
<li>唯一或可重复的复合索引</li>
<li>SQL 风格数据查询语言</li>
<li>数据库事务支持</li>
<li>并发控制,多线程安全</li>
<li>多进程安全</li>
<li>内存管理</li>
<li>主从和多主的数据库热同步</li>
<li>自动创建数据库文件</li>
<li>支持磁盘永久保存和全内存快速保存</li>
<li>零配置, 复制直接运行, 全受控代码</li>
<li>动态列支持</li>
<li>带不同索引的多个数据类型能存到同一个表中</li>
<li>持久化 + 对象影射 + 缓存 + 嵌入式, 一站式解决方案</li>
<li>Ason, 快速动态对象实例化</li>
<li>结果集支持 LINQ 与 STREAM</li>
<li>事务抱团</li>
<li>快读查询</li>
<li>更新自增</li>
<li>查询追溯</li>
<li>两级事务隔离</li>
<li>高性能无外部系统依赖</li>
<li>JAVA6+ .NET2+</li>
</ul>
<div>
<br>
<h3>示例</h3>
<h5>每个 BOX 都是一个完全隔离的独立数据空间</h5>
<div>
<pre><code class="cs"> using(var box = auto.Cube())
{
//select, insert, update, delete ...
//replace()=(insert or update)
var result = box.Commit();
}
</code></pre> <br>
<pre><code class="java"> try(Box box = auto.cube()){
...
CommitResult r = box.commit();
} </code></pre>
</div>
Box 是本地变量,每个 Box 都是单独的事务。AutoBox 在单进程应用程序中可以用作全局变量。
<br>
<br>
<h5>普通对象操作</h5>
<div>
<pre><code class="cs"> box["Member"].Insert(new Member() {
ID=box.NewId(),
Name = "Andy",
Password = EncodePassowrd("123")
}
);
</code></pre> <br>
<pre><code class="java"> Member m = new Member();
m.ID = box.newId();
m.setName("Kevin");
box.d("Member").insert(m); </code></pre>
</div>
<br>
<h5>动态列的文档数据</h5>
<div>
<pre><code class="cs"> //Game : Dictionary<string, object>
game["GameType"] = "ACT";
box["Product"].Insert(game);
</code></pre> <br>
<pre><code class="java"> //Game extends HashMap<String,Object>
game.put("GameType", "ACT");
box.d("Product").insert(game); </code></pre>
</div>
<br>
<h5>键-值风格的查询</h5>
<div>
<pre><code class="cs"> box["Table", 2L].Select<Member>();
//支持复合键
box["Table2", 99, "ABC"].Select<Product>();
</code></pre> <br>
<pre><code class="java"> box.d("Table", 3L).select(Member.class);
//支持复合键
box.d("Table2", 88, "ABC").select(Product.class); </code></pre>
</div>
<br>
<h5>复合键支持</h5>
<pre><code class="java">config.ensureTable(Item.class, "Item", "UID", "Type")</code></pre>
<img src="images/compositekey.png" alt="iBoxDB Fast ACID NoSQL Application Database Composite Key" />
<br>
<h5>SQL 风格数据查询</h5>
<div>
<pre><code class="cs"> //from TABLE where A>? & B<=? order by C limit 0,10
box.Select<Member>("from Member where Name==?", "MyName");</code></pre>
<pre><code class="java"> //from [table] where [condition]
// order by [field1] desc,[field2] limit [0,10]
//[Condition:] == != < <= > >= & | ( )
//[IFunction:] =[F1,F2,F3]
box.select(Member.class, "from Member where Name==?", "MyName"); </code></pre>
</div>
<h5>查询</h5>
<pre><code class="cs"> box.Select("from Member"); </code></pre>
<h5>查询选项</h5>
<pre><code class="cs"> //先加载到内存,使用 “*”.
//因为操作系统有预读,这选项一般不需要,
box.Select("*from Member");
//查询追溯 使用 “!”.
box.Select("!from Member"); </code></pre>
<br>
<h5>弱类型支持</h5>
<pre><code class="java"> //使用强类型
box.select("from Table where Id > ?" , 1L);
//使用弱类型
box.select("from Table where Id > ?" , new Variant("1")); </code></pre>
<br />
<h5>支持索引提升查询速度,平均快一百倍</h5>
<pre><code class="cs"> //索引
config.EnsureIndex<Member>("Member", "Field1")
config.ensureIndex(Member.class, "Member", isUnique,"Field1")</code></pre>
<pre><code class="cs"> //复合索引
config.EnsureIndex<Member>("Member", "Field1","Field2")
config.ensureIndex(Member.class, "Member", isUnique,"Field1","Field2")</code></pre>
<pre><code class="cs"> //两种索引都可以加速查询,随意选择.
//但一个查询只会加载一个索引,
//同时使用两个会产生浪费.
//一般索引已经足够快.
//复合索引一般用于关联表主键,两个条件相等的情况
box.Select("from Member where Field1 == ? & Field2 == ?",arg1,arg2)</code></pre>
<br />
<pre><code class="cs"> //Id 在左边一般会更快
box.Select("from Member where Id == ? & Field == ?",id,arg)
//主键同时也是主索引,可以创建复合索引包含主键
//但主键是唯一的,所以第二个字段一般很少用到
config.EnsureIndex(..., "Id","Field")
//交换顺序在一些情况下可能有用
config.EnsureIndex(..., "Field","Id")
//具体可查看数组比较的方法
//键值数据库一定有主键</code></pre>
<br />
<pre><code class="cs"> //合并结果会比 OR 条件更快,
//取决于数据集的大小与索引设置.
//where Id == ? | Id == ? | Id == ?
foreach(var id in [ 1, 2, 3 ])
combiner.Add( box.Select("from Member where Id == ?",id) )</code></pre>
<br>
<h5>自定义查询函数</h5>
<div>
<pre><code class="cs"> box.Select<Member>("from Member where [Tags]", new IFunction("Value"));</code></pre>
</div>
<br />
<h5>自定义表-对象绑定</h5>
<div>
<pre><code class="cs"> public bool Insert(Member m){
return auto.Insert(nameof(Member), m);
}</code></pre>
</div>
<br>
<h5>兼容 LINQ (.NET)</h5>
<div>
<pre><code class="cs"> from o in box.Select<Class>("from Class")
where o.Text.Contains(text)
select o;</code></pre>
</div>
<br>
<h5>兼容 Stream (Java8)</h5>
<div>
<pre><code class="java"> StreamSupport.stream(db.select("from Table").spliterator(), true)
.collect(Collectors.groupingBy((l) -> l.get("GroupID"),
Collectors.summingLong((l) -> (Long) l.get("Value"))));</code></pre>
</div>
<br>
<h5>Ason 和 原型对象</h5>
<div>
<pre><code class="java"> //定义原型, Id 是 Long
Ason prototype = new Ason("Id:", 0L, "Name:", "Guest");
Ason record = prototype.select();
//设置 Id 为 String,
record.set("Id", "123");
//自动转为定义原型的 Long
System.out.println("Output: " + record.get("Id").getClass());
//输出: class java.lang.Long
</code></pre>
</div>
<br />
<h5>数据库热备份</h5>
<div>
<pre><code class="cs"> auto.GetDatabase().CopyTo(bakAddr, bakRoot, buffer) </code></pre>
</div>
<br />
<h5>快读查询</h5>
<div>
<pre><code class="cs"> //从小文件中直接查询数据,
//不用启动数据库引擎
IEnumerable records = DB.Select(fileAddress) </code></pre>
</div>
<br />
<h5>事务抱团</h5>
<div>
<pre><code class="cs"> //三个事务一起提交
long huggersBuffer = 1024L * 1024L * 32L;
box1.Commit(huggersBuffer);
box2.Commit(huggersBuffer);
box3.Commit(); </code></pre>
</div>
<br />
<h5>可编程热同步,下载文件了解详细内容</h5>
<div>
<pre><code class="java"> //主-主
BoxData.masterReplicate();
//主-从
BoxData.slaveReplicate();</code></pre>
</div>
<br>
<h5>更新自增</h5>
<table style="width: 100%">
<tr>
<th></th>
<th>作用域 </th>
<th>触发条件 </th>
<th>数据类型 </th>
<th>数据来源 </th>
</tr>
<tr>
<td style="font-weight: bold">更新自增</td>
<td >索引</td>
<td>插入/更新</td>
<td>长整数</td>
<td >Database NewId (MaxPos,1)</td>
</tr>
<tr>
<td>主键自增</td>
<td>主键</td>
<td>插入</td>
<td>数字</td>
<td>Table Max (ID)+1</td>
</tr>
</table>
<br>
<h5>查询追溯</h5>
<table style="width: 100%">
<tr>
<th></th>
<th>线程 </th>
<th>用法 </th>
</tr>
<tr>
<td style="font-weight: bold">查询追溯</td>
<td>不阻塞 </td>
<td>读写不同的数据行 </td>
</tr>
<tr>
<td>数据锁 </td>
<td>阻塞 </td>
<td>读写同一数据行</td>
</tr>
</table>
<br>
<h5>Snapshot-Serializable 两级事务</h5>
<table style="width: 100%">
<tr>
<th>程序区域</th>
<th>隔离级别</th>
</tr>
<tr>
<td>应用程序</td>
<td>Snapshot</td>
</tr>
<tr>
<td>数据库</td>
<td>Serializable</td>
</tr>
</table>
<pre style="margin: 0px; padding: 0px;"><code class="cs">using(var box = auto.Cube()){
//Snapshot...
box.Commit( ()=>{
//Serializable...
});
}</code></pre>
<br>
<h5>数据持久层</h5>
<table style="margin: 0px; padding: 0px; width: 100%">
<tr>
<th>IO</th>
</tr>
<tr>
<td style="margin: 0px; padding: 0px; vertical-align: top;">
<pre style="margin: 0px; padding: 0px;"><code class="cs"> <b>BoxFileStreamConfig</b>
BoxMemoryStreamConfig
ReadonlyStreamConfig
CacheStreamConfig </code></pre>
</td>
</tr>
</table>
<br>
<h5>数据库路径设置</h5>
C# & JAVA, 把数据库文件放到<b>项目工作目录外</b>会有更好性能
<pre><code class="cs">//在虚拟机里,不同的路径有很大的读写速度差别.
//先创建目录,再放入数据库.
//new File(path).mkdirs();
//Directory.CreateDirectory(path)
iBoxDB.LocalServer.DB.Root("/data/"); </code></pre>
在<b>扫描软件</b>中把数据库根目录设置为<b>例外</b>,可以加快读写速度
<br> <br>
ASP.NET Cross Platform
<pre><code class="cs">iBoxDB.LocalServer.DB.Root(MapPath("~/App_Data/"));</code></pre>
<br>
Xamarin
<pre><code class="cs">iBoxDB.LocalServer.DB.Root(System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal));</code></pre>
<br>
Unity3D
<pre><code class="cs">iBoxDB.LocalServer.DB.Root(Application.persistentDataPath);</code></pre>
<br>
Android
<pre><code class="java">iBoxDB.LocalServer.DB.root(android.os.Environment.getDataDirectory()
.getAbsolutePath() + "/data/" + packageName + "/"); </code></pre>
<br>
JSP WebApplication
<pre><code class="java">@WebListener()
public class StartListener implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
String path = System.getProperty("user.home") + "/data/";
new File(path).mkdirs();
iBoxDB.LocalServer.DB.root(path);
}
} </code></pre>
<br />
Godot
<pre><code class="xml"><PackageReference Include="iBoxDB" Version="" />
var dir = Godot.OS.GetUserDataDir();
dir = Path.Combine(dir, "DBROOT");
Directory.CreateDirectory(dir);
DB.Root(dir)</code></pre>
<br />
jMonkeyEngine
<pre><code class="java">File dir = JmeSystem.getStorageFolder(StorageFolderType.Internal);
dir = new File(dir, "ProjectName");
dir = new File(dir, "DatabaseName");
dir.mkdir();
DB.root(dir.getAbsolutePath()); </code></pre>
<br>
<h5>快速入门 C# and JAVA</h5>
<pre><code class="cs"> using IBoxDB.LocalServer;
var db = new DB();
db.GetConfig().EnsureTable<Record>("Table", "Id");
AutoBox auto = db.Open();
auto.Insert("Table", new Record { Id = 1L, Name = "Andy" });
var record = auto.Get<Record>("Table", 1L);
record.Name = "Kelly";
auto.Update("Table", record);
auto.Delete("Table", 1L); </code></pre>
<br />
<pre><code class="java"> import iboxdb.localserver.*;
DB db = new DB();
db.getConfig().ensureTable(Record.class, "Table", "Id");
AutoBox auto = db.open();
auto.insert("Table", new Record(1L, "Andy"));
Record record = auto.get(Record.class, "Table", 1L);
record.Name = "Kelly";
auto.update("Table", record);
auto.delete("Table", 1L); </code></pre>
<br />
<h5>内存使用</h5>
<pre><code class="java"> DatabaseConfig cfg = db.getConfig();
//缓存,小于三分一总内存
cfg.CacheLength = cfg.mb(1024L);
//移动设备 64MB
cfg.CacheLength = cfg.mb(64L);
//读线程, 在小缓存机器中设置 <b>8+</b>
cfg.ReadStreamCount = 8;
//写线程, 在小缓存机器中设置 <b>4-</b> 或者 <b>1</b>
cfg.WriteStreamCount = 1;</code></pre>
<br>
<h5>安装使用</h5>
<pre><code class="cs">.NET: 在项目中引用 NETDB/iBoxDB.DLL </code></pre>
<pre><code class="java">Java: 在项目中引用 JavaDB/iBoxDB.jar </code></pre>
<br>
<h5>与 MySQL 的性能参照</h5>
<pre><code class="sql">iBoxDB
Insert: 1,000,000 AVG: 47,016 objects/s
Update: 1,000,000 AVG: 25,558 objects/s
Delete: 1,000,000 AVG: 42,714 objects/s
MySQL
Insert: 1,000,000 AVG: 5,514 objects/s
Update: 1,000,000 AVG: 5,109 objects/s
Delete: 1,000,000 AVG: 6,044 objects/s
</code></pre>
<br>
<h5>数据类型支持</h5>
<table style="margin: 0px; padding: 0px; width: 100%;">
<tr>
<th >.NET </th>
<th >JAVA </th>
</tr>
<tr>
<td style="margin: 0px; padding: 0px; vertical-align: top;">
<pre style="margin: 0px; padding: 0px; font-size:13px"><code class="diff"> bool
char
byte
sbyte
short
ushort
int
uint
long
ulong
float
double
decimal
DateTime
Guid
bool?
char?
byte?
sbyte?
short?
ushort?
int?
uint?
long?
ulong?
float?
double?
decimal?
DateTime?
Guid?
string
//non indexable
Dictionary
<string, object>
MemoryStream
byte[]
string[]
<!--
bool[]
char[]
sbyte[]
short[]
ushort[]
int[]
uint[]
long[]
ulong[]
float[]
double[]
decimal[]
DateTime[]
Guid[]--> </code></pre>
</td>
<td style="margin: 0px; padding: 0px; vertical-align: top;">
<pre style="margin: 0px; padding: 0px; font-size:13px"><code class="diff"> boolean
Boolean
byte
Byte
char
Character
short
Short
int
Integer
long
Long
float
Float
double
Double
UUID
Date
//dynamic length
BigDecimal
BigInteger
String
//non indexable
HashMap
<String, Object>
MemoryStream
byte[]
Object[]
</code></pre>
</td>
</tr>
<tr>
<th colspan="2"> ORM </th>
</tr>
<tr>
<td style="margin: 0px; padding: 0px; vertical-align: top;">
<pre style="margin: 0px; padding: 0px; font-size:13px">
<code class="cs">//Name
*.Name
//name
*.name
</code></pre>
</td>
<td style="margin: 0px; padding: 0px; vertical-align: top;">
<pre style="margin: 0px; padding: 0px; font-size:13px">
<code class="java">//Name
*.Name
*.Name(val)
*.setName(val)
//name
*.name
*.name(val)
*.setname(val)</code></pre>
</td>
</tr>
</table>
<pre><code class="java"> DatabaseConfig cfg;
//创建表
ensureTable(Record.class, "Table", "Id");
//创建长度为 32 的索引
ensureIndex(Record.class, "Table", "Name(32)");
//如果要索引 byte[] 或其它,
//使用 ToBase64String(byte[]) 转换为字符串 String. </code></pre>
<br />
<h5>.NET AOT 注册类型</h5>
<pre><code class="cs"> public static object Register
<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>()
where T : new()
{
return new T();
}
//触发 DynamicallyAccessedMemberTypes.All
Register<T1>();
EnsureTable<T1>("T1", "Id"); </code></pre>
<br />
<!-- img src="images/p1.png" alt="iBoxDB Fast Transactional NoSQL Application Database Replication" / -->
<h5>全平台支持</h5>
<img src="images/p3.png" alt="iBoxDB Fast Transactional NoSQL Application Database For Java, .Net, Android, Windows Phone, Mono, Unity3D, Xamarin, Linux, Windows" />
</div>
</section>
</div>
<!-- FOOTER -->
<div id="footer_wrap" class="outer" style="border-top-style: solid; border-top-width: medium; border-top-color: #33CC00">
<footer class="inner">
<p class="copyright">
双引擎数据库
<br />
支持 JAVA C# Android Unity3D Xamarin Mono ASP.NET Core Linux
<br />
NoSQL Storage Engines Home <a href="index.html" style="color: #FFFFFF; text-decoration: underline;">www.iBoxDB.com</a>
</p>
<br />
<br />
</footer>
</div>
<div class="outer" style="position: relative; top: -50px; left: -1px">
</div>
<script src="highlight/highlight.packS.jS?SRC=USER"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>