iBoxDB 2.33/2.27 发布,环保型嵌入式数据库

iBoxDB是一杯浓缩的 Java .NET 嵌入式 NoSQL 数据库,简洁清香。
优化静态类型数据,缓存动态类型数据,无论使用哪种编程方式都能得到最佳性能。
安全稳健,从语法解析上去掉了SQL注入的可能。
使用编程语言的逻辑操作数据,并且每段代码有独立的数据空间,无需担心外部注入数据破坏一致性。
安装简单,维护容易。

支持平台
Java .NET Xamarin Mono Unity Android Windows Linux Blazor Wasm

更新内容:

1. 优化缓存预读,性能提升 -1%到+5%。
2. 调整了设置类 。
3. 方便的动态类型与闭包编程。
通过在iBoxDB中引入的一种快速生成动态对象的结构 Ason,代码例子在后面。

Ason详细说明

更多更新说明,示例,下载。

性能对比
执行相同量的数据处理,显示iBoxDB有更高的能效比,绿色节能环保。

与MySQL8性能对比 Java11
与SQLite性能对比 C#8

测试前要关闭IDE等工具,直接运行最终编译文件。
连续运行几次会有更好性能。

Ason演示例子, 三表连接操作。

package example;

import iBoxDB.LocalServer.*;
import static iBoxDB.LocalServer.Ason.*;
import static iBoxDB.LocalServer.IFunction.*;
import static example.AsonExample.Names.*;
import java.util.Map;

public class AsonExample {

    public static void main(String[] mainargs) {
        DB.root("../");
        
        var db = new DB(1);

        db.getConfig()
                .ensureTable(new Ason(Id, 0L), Table1);

        db.getConfig()
                .ensureTable(new Ason(Id, 0L), Table2)
                .ensureIndex(new Ason(JoinTable1, 0L), Table2);

        db.getConfig()
                .ensureTable(new Ason(Id, 0L), Table3)
                .ensureIndex(new Ason(JoinTable2, 0L), Table3);

        var auto = db.open();

        long id1start;

        try (var box = auto.cube()) {
            id1start = box.newId(1, 0);
            for (int t1 = 0; t1 < 100; t1++) {
                long id1 = box.newId(1, 1);
                var obj1 = new Ason(Id, id1, Value1, "T1-" + id1);
                box.d(Table1).insert(obj1);

                for (int t2 = 0; t2 < 3; t2++) {
                    long id2 = box.newId(2, 1);
                    var obj2 = new Ason(Id, id2, JoinTable1, id1, Value2, "T2-" + id2);
                    box.d(Table2).insert(obj2);

                    for (int t3 = 0; t3 < 2; t3++) {
                        long id3 = box.newId(3, 1);
                        var obj3 = new Ason(Id, id3, JoinTable2, id2, Value3, "T3-" + id3);
                        box.d(Table3).insert(obj3);

                    }

                }
            }
            CommitResult cr = box.commit();
        }

        var joinList = new JoinList();
        try (var box = auto.cube()) {
            box.selectCount("from Table1 where Id >= ? & Id <=? & [*]", id1start, id1start + 5,
                    func((_a, args1) -> {
                        var map1 = (Map<String, Object>) args1[0];
                        var id1 = map1.get(Id);

                        box.selectCount("from Table2 where JoinTable1 == ? & [*]", id1,
                                func((_b, args2) -> {
                                    var map2 = (Map<String, Object>) args2[0];
                                    var id2 = map2.get(Id);

                                    box.selectCount("from Table3 where JoinTable2 == ? & [*]", id2,
                                            func((_c, args3) -> {
                                                var map3 = (Map<String, Object>) args3[0];
                                                joinList.newRow(map1).join(map2).join(map3);
                                                return true;
                                            }));

                                    return true;
                                }));

                        return true;
                    })
            );
        }

        for (var row : joinList) {
            System.out.println(row.toString());
        }
        auto.getDatabase().close();
    }

    public static class Names {

        public static String Id = "Id";

        public static String JoinTable1 = "JoinTable1";
        public static String JoinTable2 = "JoinTable2";

        public static String Table1 = "Table1";
        public static String Table2 = "Table2";
        public static String Table3 = "Table3";

        public static String Value1 = "Value1";
        public static String Value2 = "Value2";
        public static String Value3 = "Value3";
    }
}

猜你喜欢

转载自www.oschina.net/news/115217/iboxdb-2-33-n-2-17-released
今日推荐