-
Notifications
You must be signed in to change notification settings - Fork 10
Getting Started
#
10 minuts getting started
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 is located 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();
1 Home
1.1 summary
1.2 System Preparation
1.3 When LunarBase is your best choice
1.4 Benchmark
1.5 Power consumption
2 Data Model And Process
2.1 Why internal big cache
2.2 Memory Management: LunarMMU
2.3 Garbage Collection
2.4 Transaction Log
2.5 JOIN via materialized view
3 Real Time Computation: LunarMax
3.1 In-Memory File System: Memory Estimation
3.2 Configuration
3.3 Use SSD as a cheaper memory
3.4 Data Safety
3.5 HE Server VS. Cluster
3.6 High Availability
4 Create a database
4.1 Three modes
4.2 creation.conf settings
4.3 Table space
4.4 Multiple Instance
4.5 Database Status
4.6 Remove and Restore a table
5 Insertion
5.1 Insert as normal record
5.2 Insert to search engine
6 Query
6.1 Point Query
6.2 Result Handler: register your own event handler
6.3 Interpreter Pattern: complex query conditions
6.4 Range Query
6.5 Full-text Search
6.6 Algebraic Logical Query
8 Deletion
9 Materialized view
9.1 Eventual consistency
9.2 Update
9.3 MVCC in LunarBase
9.4 Easy JOIN via denormalization
9.5 CRUD in view
10 Distributed integration with
10.1 Kafka
10.2 Storm
10.3 Spark
11 Storage: Lunar Virtual File System
13 Roadmap of LunarBase future
15 FAQ