Giter VIP home page Giter VIP logo

b-xiang / lunarbase Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lunarbaseengin/lunarbase

0.0 1.0 0.0 32.31 MB

LunarBase engine (in C and Java) targets a real-time and free style database engine, managing 2 billions of records in one table, where each record has a size limitation up to 32k bytes, and it can be used as a search engine as well. Seek more in the [Wiki](https://github.com/LunarBaseEngin/LunarBase/wiki) .

License: GNU General Public License v2.0

Java 100.00%

lunarbase's Introduction

#image10 minuts getting started

Current Lunarbase runs on Linux + X86 platform:

  1. X86 platform;
  2. 4GB memory;
  3. 2 cores of CPU;
  4. 64-bit Linux;
  5. JVM 1.8 or later;
  6. GCC 4.8.4 or later;

You may check out here and benchmark to verify your working enviroment.

Runnable examples are under the folder example, clone this project to your desktop, and run it for yourself.

creation.conf is the configure file that tells LunarBase how to initialize a database. Any parameters in the creation example can be changed to meet your requirements. For example, if you need to cache the hottest 1 million records in memory, you shall change the parameter cache_records_in_memory = 20, (1 << 20 = 1 million). Of course, all the runtime tunable parameters can be changed at any time the db running.

#step 1: create a new database

 String creation_conf = "/home/feiben/EclipseWorkspace/LunarBaseTutorial/creation.conf";  
 LunarDB.getInstance().createDB(creation_conf);  
 LunarDB.getInstance().closeDB();  

Where within the creation.conf, it tells us the database locates under root_path=/home/feiben/DBTest/, and the name is RTSeventhDB.

# ----------------#  
# Global settings #  
# --------------- #  

root_path=/home/feiben/DBTest/  

database_name = RTSeventhDB  

So the db root is /home/feiben/DBTest/RTSeventhDB. The DBTaskCenter knowns from where to create the engine instance:

#step 2: create a new table and insert data to it

String db_root = "/home/feiben/DBTest/RTSeventhDB";  
DBTaskCenter tc = new DBTaskCenter(db_root);  
String table = "order";
if(!tc.getActiveDB().hasTable(table))
{
    tc.getActiveDB().createTable(table); 
    tc.getActiveDB().openTable(table);  
}
		
LunarTable l_table = tc.getActiveDB().getTable(table);
l_table.addSearchable("string", "name");
l_table.addSearchable("int", "payment");
l_table.addSearchable("int", "age");
		
			
/*  
 * Step 1: construct an object of a records array  
 */  
 String[] records = new String[6];  
 records[0] = "{name=jackson8, payment=500, age=36}";  
 records[1] = "{name=jackson9, payment=500, age=25}";  
 records[2] = "{name=John8, payment=600, age=36}";  
 records[3] = "{name=Rafael8, payment=600, age=36}";  
 records[4] = "{name=Rafael9, payment=700, age=25}";  
 records[5] = "{name=John9, payment=700, age=36}";  
 		
 /*  
  * Step2: dispatch it. LunarBase engine handles it.  
  */  
 LFuture<Record32KBytes[]> inserted = tc.dispatch(new IncommingRecords(table, records));  
 tc.saveDB();  

#step 3: simple query

 /*  
  * Step 3: Test query, see if they are correctly inserted,   
  * and if property-value pair can be retrieved.   
  */  
 QuerySimple sq = new QuerySimple(table, "age", "36", 200);  
 tc.dispatch(sq);

#step 4: shut down the database

 /*  
  * Step 4: Must not forget to shut down the db.  
  */  
 tc.shutdownDB();

Embeded version

For elaboration on the features and use of LunarBase, please visit the wiki here

or download the knowledge base file at here

lunarbase's People

Contributors

feiben avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.