iBoxDB

双核高效事务NoSQL应用程序数据库引擎

iBoxDB NoSQL Database 敏捷开发 嵌入式文档数据库 iBoxDB NoSQL Document Database for JAVA C# Android ASP.NET Core Unity ORM Database Mobile Database MVCC Transactional Thread Safe

项目介绍

iBoxDB 是一个高性能的NoSQL应用程序数据库,提供事务支持,使用数据库表的风格存取任意结构的文档对象数据,包含无须安装配置的 JAVA 与 .NET 数据库引擎。

iBoxDB 提供一个优雅设计的编程接口,让应用程序无缝地与数据引擎溶为一体, 你能方便地把它发布到移动设备, 桌面设备和服务器上, 然后让它帮助你存取各种有结构的,或者无结构的数据,具备保持数据一致性的能力。

双引擎数据库
支持   JAVA   C#   Android   Unity3D   Xamarin   Mono   ASP.NET Core   Nashorn   Linux

特性

示例

每个 BOX 都是一个完全隔离的独立数据空间
  using(var box = db.Cube())
  {                            
     //select, insert, update, delete ...
     var result = box.Commit();
  }
  try(Box box = db.cube()){
     ...
     CommitResult r = box.commit();
  }
                    
普通对象操作
 box.Bind("Member").Insert(
       new Member() {  
             ID=box.NewId(Member.IncTableID, 1) ,
             LoginName = "Andy",
             Password = Member.EncodePassowrd("123"),
             Tags = new string[]{ "Nice" , "Strong" }
        }
      );
  Member m = new Member();
  m.ID = box.newId(Member.IncTableID, 1);
  m.setName("Andy");
  m.setTags(new Object[] { "Nice", "Strong" });
  box.bind("Table").insert(m);
                    
动态列的文档数据
  game["GameType"] = "ACT";
  box.Bind("Product").Insert(game);
  game.put("GameType", "ACT");
  box.bind("Table").insert(game);
                    
键-值风格的查询
  box.Bind("Table", 2L).Select<AClass>();
   //支持复合键
  box.Bind("Table2", 99, "ABC").Select<BClass>();
  box.bind("Table", ID).select(Member.class);
  //支持复合键
  box.bind("Table2",8, "MyID").select(Product.class);
                    
SQL 风格数据查询
  //from TABLE where A>? & B<=? order by C limit 0,10
  box.Select<Member>("from Member where LoginName==?", "MyName");
  //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");
                    
自定义查询函数
  box.Select<Member>("from Member where [Tags]", new QueryArray("Value"));
兼容 LINQ (.NET)
  from o in box.Select<Class>("from Class")
  where o.Text.Contains(text)
  select o;
兼容 Stream (Java8)
  StreamSupport.stream(db.select("from Table").spliterator(), true)
  .collect(Collectors.groupingBy((l) -> l.get("GroupID"),
   Collectors.summingLong((l) -> (Long) l.get("Value"))));
更新自增
作用域 触发条件 数据类型 数据来源
主键自增 主键 插入 数字 Table Max(ID)+1
更新自增 非主键 插入/更新 长整数 Database NewId(MaxPos,1)
查询追溯
线程 用法
数据锁 阻塞 读写同一数据行
查询追溯 不阻塞 读写不同的数据行
数据类型支持
.NET JAVA
 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
 MemoryStream STREAM ;
 Dictionary<string, object>
 bool[] 
 char[] 
 byte[]
 sbyte[] 
 short[]
 ushort[] 
 int[] 
 uint[] 
 long[]
 ulong[]
 float[]
 double[] 
 decimal[] 
 DateTime[] 
 Guid[]
             
 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
 byte[]
 HashMap<String,Object>
 Object[]
                            
数据持久层
.NET JAVA
 class BoxFileStreamConfig
 class BoxMemoryStreamConfig
 class ReadonlyStreamConfig
 class CacheStreamConfig 
 class BoxFileStreamConfig 
 class BoxMemoryStreamConfig
 class ReadonlyStreamConfig
 class CacheStreamConfig 
数据库路径设置
C# & JAVA,  把数据库文件放到项目工作目录外会有更好性能
iBoxDB.LocalServer.DB.Root("/data/");
                
ASP.NET 跨平台
iBoxDB.LocalServer.DB.Root(MapPath("~/App_Data/"));
                      
Xamarin
iBoxDB.LocalServer.DB.Root(System.Environment.GetFolderPath( 
       System.Environment.SpecialFolder.Personal));
                          
Unity3D
iBoxDB.LocalServer.DB.Root(Application.persistentDataPath);
                
Android
iBoxDB.LocalServer.DB.root(android.os.Environment.getDataDirectory()
       .getAbsolutePath() + "/data/" + packageName + "/");
                
JSP WebApplication
@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); 
    }
}
               
支持索引提升查询速度
config.EnsureIndex<Member>("Member", "Field1", "Field2")
box.Select("from Member where Field1 == ? & Field2 == ?")
                
快速入门   C# and JAVA
 var server = new DB();
 server.GetConfig().EnsureTable<Record>("Table", "ID");
 DB.AutoBox auto = server.Open();
 auto.Insert("Table", new Record { ID = 1, Name = "Andy" });
 var o1 = auto.SelectKey<Record>("Table", 1);
 o1.Name = "Kelly";
 auto.Update("Table", o1);
 auto.Delete("Table", 1);
                    
 DB server = new DB();
 server.getConfig().ensureTable(Record.class, "Table", "ID");
 DB.AutoBox auto = server.open();
 auto.insert("Table", new Record(1, "Andy"));
 Record o1 = auto.selectKey(Record.class, "Table", 1);
 o1.Name = "Kelly";
 auto.update("Table", o1);
 auto.delete("Table", 1);
                
命令行方式   F# and JavaScript
 #r "iBoxDB.dll" 
 open iBoxDB.LocalServer 
 open System 
 DB.Root( "C:\\DB" ) 
 let server = new DB() 
 let db = server.Open() 
 for v in db.Select("from OT limit 0 , 2") do 
   Console.WriteLine(DB.ToString(v)) 
 for v in db.GetDatabase().GetSchemata() do 
   Console.WriteLine(v.Key) 
 server.Dispose()
                
 //jjs -cp iBoxDB.jar 
 var DB = Java.type("iBoxDB.LocalServer.DB") 
 DB.root("/db/") 
 var server = new DB() 
 var db = server.open() 
 db.select("from table1 limit 0,3") 
   .forEach( function(v){ print(v) }) 
 db.getDatabase().getSchemata() 
   .forEach( function(v){ print(v) }) 
 server.close() 
                
性能参照 与 MongoDB
iBoxDB.Java 32bit System Low Memory
iBoxDB.java v1.4.1 mongodb-win32-i386-2.5.4 mongo-java-driver-2.9.3.jar
Results:
threadCount=100000 , batchCount=10
MongoDB(Default)
 Database Transaction Test: None
 MongoDB Insert&Counting:1000000  AVG:10521 objects/s
 
iBoxDB(File Mode)
 Database Transaction Test: Succeeded
 iBoxDB Insert&Counting:1000000  AVG:17981 objects/s
 iBoxDB Update:1000000  AVG:12397 objects/s 
 iBoxDB Delete:1000000  AVG:22869 objects/s
            
iBoxDB(MemoryMappedFile Mode)
 Database Transaction Test: Succeeded
 iBoxDB Insert&Counting:1000000  AVG:38458 objects/s
 iBoxDB Update:1000000  AVG:20200 objects/s 
 iBoxDB Delete:1000000  AVG:33342 objects/s
 
iBoxDB(InMemory Mode)
 Database Transaction Test: Succeeded
 iBoxDB Insert&Counting:1000000  AVG:39132 objects/s
 iBoxDB Update:1000000  AVG:20226 objects/s 
 iBoxDB Delete:1000000  AVG:33658 objects/s
                

iBoxDB.NET 64bit System
iBoxDB v1.5 mongodb-win32-x86_64-2008plus-2.4.5 MongoDB.Driver v1.8.2.34
MongoDB(Default)
 Database Transaction Test: None
 MongoDB Insert&Counting:1,000,000 AVG: 32,702 objects/s
 
iBoxDB(File Mode)
 Database Transaction Test: Succeeded
 iBoxDB Insert&Counting:1,000,000 AVG: 33,368 objects/s
 iBoxDB Select&Update:1,000,000 AVG: 16,939 objects/s 
 iBoxDB Delete:1,000,000 AVG: 22,504 objects/s
 
iBoxDB(MemoryMappedFile Mode)
 Database Transaction Test: Succeeded
 iBoxDB Insert&Counting:1,000,000 AVG: 42,236 objects/s
 iBoxDB Select&Update:1,000,000 AVG: 17,765 objects/s 
 iBoxDB Delete:1,000,000 AVG: 23,147 objects/s
 
iBoxDB(InMemory Mode)
 Database Transaction Test: Succeeded
 iBoxDB Insert&Counting:1,000,000 AVG: 47,382 objects/s
 iBoxDB Select&Update:1,000,000 AVG: 26,806 objects/s 
 iBoxDB Delete:1,000,000 AVG: 35,092 objects/s
                
数据库同步,主从与多主
iBoxDB Fast Transactional NoSQL Application Database Replication
iBoxDB Fast Transactional NoSQL Application Database For Java, .Net, Android, Windows Phone, Mono, Unity3D, Xamarin, Nashorn, Node.js, Linux, Windows